Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
UI content shown with delay after opening the app from the system tray
Browse files Browse the repository at this point in the history
[fix] (macOS) Clicking the icon in Launchpad or system dock does not open the app main window after system boot

https://privatus.atlassian.net/browse/WC-1182
https://privatus.atlassian.net/browse/WC-1183
  • Loading branch information
stenya committed Apr 22, 2021
1 parent 190a471 commit 4435bdf
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,15 @@ if (gotTheLock) {
if (store.state.settings.minimizeToTray && WasOpenedAtLogin()) {
// do not show main application window when application was started automatically on login
// (if enabled minimizeToTray)
const doNotShowWhenReady = true;
createWindow(doNotShowWhenReady);
} else {
createWindow();
}
});

app.on("activate", () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow();
}
menuOnShow();
});

// Quit when all windows are closed.
Expand Down Expand Up @@ -518,7 +516,7 @@ function createBrowserWindow(config) {
}

// CREATE WINDOW
function createWindow() {
function createWindow(doNotShowWhenReady) {
// Create the browser window.

let windowConfig = {
Expand Down Expand Up @@ -575,12 +573,13 @@ function createWindow() {
win.loadURL("app://./index.html");
}

// show\hide app from system dock
updateAppDockVisibility();

win.once("ready-to-show", () => {
win.show();
});
if (doNotShowWhenReady != true) {
win.once("ready-to-show", () => {
win.show();
// show\hide app from system dock
updateAppDockVisibility();
});
}

win.on("close", async event => {
// save last window position in order to be able to restore it
Expand All @@ -591,8 +590,14 @@ function createWindow() {
isTrayInitialized == true &&
store.state.settings.minimizeToTray == true
) {
// Prevent closing the window to be able to show it back immediately.
// Just hide it.
win.hide();
event.preventDefault();
return;

// 'window-all-closed' event will be raised
return; // close window
//return; // close window
}

event.preventDefault();
Expand Down

0 comments on commit 4435bdf

Please sign in to comment.