Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev mode #99

Merged
merged 5 commits into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ app.on('ready', () => {
},
width: store.get('isFullscreen', false) ? width : 1200,
height: 750,
focusable: process.env.NODE_ENV !== 'development',
},
tray,
showOnAllWorkspaces: false,
Expand All @@ -99,6 +98,22 @@ 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 @@ -246,6 +261,16 @@ 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 @@ -271,12 +296,20 @@ app.on('ready', () => {
if (e.ctrlKey || e.metaKey) {
const contextMenuTemplate = createContextMenuTemplate();
mb.tray.popUpContextMenu(Menu.buildFromTemplate(contextMenuTemplate));
} else {
quickOpen();
}
});

tray.on('double-click', () => {
quickOpen();
});
Comment on lines +304 to +306
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this break the click open?


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 @@ -382,13 +415,6 @@ app.on('ready', () => {
});
});

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

Comment on lines -385 to -391
Copy link
Contributor

@swyxio swyxio Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this completes our transition away from a menubar app towards just a straight up full app that happens to have a keyboard shortcut to activate

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