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

Fixing macOS tray #2936

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ cert.crt
server-package.json
.idea/httpRequests/
data/
*.log
pnpm-lock.yaml
package.json
.gitignore
.gitignore
package.json
Copy link
Owner

Choose a reason for hiding this comment

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

Most of these changes seem either irrelevant (*.log) or wrong (package.json, .gitignore).

6 changes: 4 additions & 2 deletions electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ require('electron-debug')();
appIconService.installLocalAppIcon();

require('electron-dl')({ saveAs: true });

if (process.platform === 'darwin') {
app.dock.hide()
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
if (process.platform === 'darwin') {
app.quit();
}
else if (process.platform === 'win32') {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"electron-debug": "3.2.0",
"electron-dl": "3.3.1",
"electron-window-state": "5.0.3",
"escape-html": "^1.0.3",
"express": "4.18.1",
"express-partial-content": "1.0.2",
"express-rate-limit": "6.4.0",
Expand Down Expand Up @@ -82,6 +83,7 @@
"turndown": "7.1.1",
"unescape": "1.0.1",
"ws": "8.8.0",
"xml2js": "^0.4.23",
"yauzl": "2.10.0"
Copy link
Owner

Choose a reason for hiding this comment

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

Why are these extra dependencies added?

},
"devDependencies": {
Expand Down
64 changes: 34 additions & 30 deletions src/services/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,47 @@ const registerVisibilityListener = () => {
}

const updateTrayMenu = () => {
const mainWindow = windowService.getMainWindow();
if (process.platform != 'darwin') {
// Menus under macos cause multiple changeVisibility triggers
const mainWindow = windowService.getMainWindow();

const contextMenu = Menu.buildFromTemplate([
{
label: isVisible ? 'Hide' : 'Show',
type: 'normal',
click: () => {
if (isVisible) {
mainWindow.hide();
} else {
mainWindow.show();
const contextMenu = Menu.buildFromTemplate([
{
label: isVisible ? 'Hide' : 'Show',
type: 'normal',
click: () => {
if (isVisible) {
mainWindow.hide();
} else {
mainWindow.show();
mainWindow.focus();
}
}
},
{
type: 'separator'
},
{
label: 'Quit',
type: 'normal',
click: () => {
mainWindow.close();
}
}
},
{
type: 'separator'
},
{
label: 'Quit',
type: 'normal',
click: () => {
mainWindow.close();
}
},
]);
},
]);
Copy link
Owner

Choose a reason for hiding this comment

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

There seem to be many whitespace changes which are unnecessary and obscure the real change..


tray?.setContextMenu(contextMenu);
tray?.setContextMenu(contextMenu);
}
}
const changeVisibility = () => {
const window = windowService.getMainWindow();

if (isVisible) {
window.hide();
} else {
window.show();
window.focus();
}
if (isVisible) {
window.hide();
} else {
window.show();
window.focus();
}
Copy link
Owner

Choose a reason for hiding this comment

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

Indent seems to be wrong here.

}

function createTray() {
Expand Down