mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-17 20:07:36 +08:00
✨ Feature(custom): improve handling of second instance activation with timer
ISSUES CLOSED: #522
This commit is contained in:
@@ -226,8 +226,14 @@ class LifeCycle {
|
||||
}
|
||||
|
||||
#onRunning() {
|
||||
let pendingActivateWindowTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
app.on('second-instance', (_, commandLine, workingDirectory) => {
|
||||
logger.info('detect second instance')
|
||||
if (pendingActivateWindowTimer !== null) {
|
||||
clearTimeout(pendingActivateWindowTimer)
|
||||
pendingActivateWindowTimer = null
|
||||
}
|
||||
const result = handleStartUpFiles(commandLine, workingDirectory)
|
||||
if (!result) {
|
||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||
@@ -235,7 +241,13 @@ class LifeCycle {
|
||||
})
|
||||
app.on('activate', () => {
|
||||
if (!windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||
if (pendingActivateWindowTimer !== null) clearTimeout(pendingActivateWindowTimer)
|
||||
pendingActivateWindowTimer = setTimeout(() => {
|
||||
pendingActivateWindowTimer = null
|
||||
if (!windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||
}
|
||||
}, 300)
|
||||
}
|
||||
})
|
||||
const storedAutoStartEnabled = picgo.getConfig<boolean>(configPaths.settings.autoStart) || false
|
||||
|
||||
Reference in New Issue
Block a user