From c8be213069a01257b3d16f3a295c07955b096809 Mon Sep 17 00:00:00 2001 From: "swyx.io" Date: Sat, 5 Aug 2023 16:23:33 -0700 Subject: [PATCH] Revert "Dev mode" (#112) --- index.js | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/index.js b/index.js index 1a5210d..c668ccf 100644 --- a/index.js +++ b/index.js @@ -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; @@ -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, @@ -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(); @@ -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) => {