Files
OmniRoute/electron/lib/windowLifecycle.js
Diego Rodrigues de Sa e Souza 7d0b264eda chore(electron): drop openAsHidden/wasOpenedAsHidden, removed in Electron 44 (#12554)
CI verde: 18 checks passando (4 shards de unit, Vitest, CodeQL, Fast Quality Gates, No new ESLint warnings, semgrep). Local: 8/8 no teste atualizado e 165/165 nos 16 arquivos tests/unit/electron-*.test.ts.
2026-09-03 08:32:22 -03:00

29 lines
933 B
JavaScript

/** Pure helpers for deciding and driving the Electron dashboard window lifecycle. */
// Electron 44 removed `openAsHidden`/`wasOpenedAsHidden` from
// `app.set/getLoginItemSettings()` (they only ever worked on macOS 12 and below, which
// Electron 44 no longer supports). The hidden-autostart contract is now carried solely by
// the `--hidden` argument registered with the login item.
function shouldStartHidden({ argv = [] } = {}) {
return argv.includes("--hidden") || argv.includes("--minimized");
}
function showOrCreateWindow({ appReady, getWindow, createWindow }) {
if (!appReady) return null;
const currentWindow = getWindow();
if (!currentWindow || currentWindow.isDestroyed()) {
return createWindow();
}
if (currentWindow.isMinimized()) currentWindow.restore();
currentWindow.show();
currentWindow.focus();
return currentWindow;
}
module.exports = {
shouldStartHidden,
showOrCreateWindow,
};