Skip to content

Commit 81807ed

Browse files
committed
[IMP] streamsnap: start minimized on login
Modified login item registration to include hidden flags, and added logic in main to minimize the window automatically if it was launched via autostart.
1 parent 917b4a5 commit 81807ed

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class StreamSnapApp {
116116
} catch (e) {}
117117
}
118118

119-
await this.windowManager.createMainWindow()
119+
const isHiddenLaunch = app.getLoginItemSettings().wasOpenedAsHidden || process.argv.includes('--hidden')
120+
await this.windowManager.createMainWindow(isHiddenLaunch)
120121
this.isInitialized = true
121122

122123
try {

src/handlers/WindowHandlers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ class WindowHandlers {
174174
try {
175175
electronApp.setLoginItemSettings({
176176
openAtLogin: enabled,
177-
path: electronApp.getPath('exe')
177+
path: electronApp.getPath('exe'),
178+
openAsHidden: true,
179+
args: ['--hidden']
178180
})
179181
return { success: true }
180182
} catch (error) {

src/services/WindowManager.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class WindowManager {
9191
}
9292
}
9393

94-
async createMainWindow() {
94+
async createMainWindow(startMinimized = false) {
9595
try {
9696
this.windows.main = new BrowserWindow({
9797
...WINDOW_CONFIG.main,
@@ -109,18 +109,14 @@ class WindowManager {
109109

110110
await this.windows.main.loadFile('src/windows/main.html')
111111

112-
this.windows.main.webContents.once('dom-ready', () => {
113-
this.windows.main.show()
114-
})
115-
116112
this.windows.main.once('ready-to-show', () => {
117-
if (!this.windows.main.isVisible()) {
113+
if (startMinimized) {
114+
this.windows.main.minimize()
115+
} else {
118116
this.windows.main.show()
119117
}
120118
})
121119

122-
this.windows.main.show()
123-
124120
this.windows.main.on('closed', () => {
125121
this.windows.main = null
126122
})

0 commit comments

Comments
 (0)