klaudiosinani / ao

Elegant Microsoft To-Do desktop app
https://klaussinani.github.io/ao
MIT License
2.1k stars 198 forks source link

Fixes #80: Check if already shown on dom-ready #130

Open oxiez opened 4 years ago

oxiez commented 4 years ago

Fixes #80. Changing the callback on webContents for dom-ready to this:

webContents.on('dom-ready', () => {
    const stylesheets = fs.readdirSync(file.style);
    stylesheets.forEach(x => webContents.insertCSS(readSheet(x)));

   console.log("dom-ready");
    if (settings.get('launchMinimized')) {
      mainWindow.minimize();
    } else {
      mainWindow.show();
    }
  });

outputs the following on npm start:

> electron .

dom-ready
dom-ready
dom-ready
dom-ready
dom-ready
dom-ready

I believe repeated dom-ready fires was the reason for the window repeatedly stealing focus on startup. The window should now load in the background if clicked away from.

Using ready-to-show might also be an option, if the version of electron is updated: https://github.com/electron/electron/issues/7779

825i commented 3 years ago

Pushed to my own branch. Thanks. Added your name in the credits.