Skip to content

Commit

Permalink
Revert "Dev mode" (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
swyxio authored Aug 5, 2023
1 parent 9479d74 commit c8be213
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,6 @@ app.on('ready', () => {
icon: image,
});

// Flag to detect if the window was hidden manually
let manualHide = false;

// Prevent window from hiding when in development mode if not hidden manually
// (for debugging)
if (process.env.NODE_ENV === 'development') {
const originalHideWindow = mb.hideWindow.bind(mb);

mb.hideWindow = () => {
if (manualHide) {
manualHide = false; // Reset the flag
originalHideWindow(); // Call the original hideWindow method
}
};
}

// On menubar ready, the following code will execute
mb.on('ready', () => {
const { window } = mb;
Expand Down Expand Up @@ -264,16 +248,6 @@ app.on('ready', () => {
},
];

// FYI to the user that they are in development mode
if (process.env.NODE_ENV === 'development') {
menuHeader.unshift(
{
label: '👨‍💻 IN DEV MODE 👨‍💻',
},
separator,
);
}

// Return the complete context menu template
return [
...menuHeader,
Expand All @@ -300,20 +274,12 @@ app.on('ready', () => {
if (e.ctrlKey || e.metaKey) {
const contextMenuTemplate = createContextMenuTemplate();
mb.tray.popUpContextMenu(Menu.buildFromTemplate(contextMenuTemplate));
} else {
quickOpen();
}
});

tray.on('double-click', () => {
quickOpen();
});

const menu = new Menu();

function quickOpen() {
if (window.isVisible()) {
manualHide = true; // Honor manual hide in development mode
mb.hideWindow();
} else {
mb.showWindow();
Expand Down Expand Up @@ -407,6 +373,13 @@ app.on('ready', () => {
});
});

if (process.platform == 'darwin') {
// restore focus to previous app on hiding
mb.on('after-hide', () => {
mb.app.hide();
});
}

// open links in new window
// app.on("web-contents-created", (event, contents) => {
// contents.on("will-navigate", (event, navigationUrl) => {
Expand Down

0 comments on commit c8be213

Please sign in to comment.