fix: hide on launch after layout ready to prevent refocusing of minimised window

This commit is contained in:
dragonwocky 2023-04-09 21:34:30 +10:00
parent 7f9ec58cfa
commit fbce51895d
Signed by: dragonwocky
GPG Key ID: 7998D08F7D7BD7A8

12
main.js
View File

@ -238,8 +238,16 @@ class TrayPlugin extends obsidian.Plugin {
setLaunchOnStartup(this);
if (settings.createTrayIcon) createTrayIcon(this);
if (settings.runInBackground) interceptWindowClose();
// bug: obsidian will refocus/reshow self if minimised but not fully hidden
if (settings.hideOnLaunch) hideWindows(settings.runInBackground);
if (settings.hideOnLaunch) {
let _hidden;
this.registerEvent(
this.app.workspace.onLayoutReady(() => {
if (_hidden) return;
_hidden = true;
hideWindows(settings.runInBackground);
})
);
}
}
onunload() {
unregisterHotkey(this);