mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-06 07:56:56 +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() {
|
#onRunning() {
|
||||||
|
let pendingActivateWindowTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
app.on('second-instance', (_, commandLine, workingDirectory) => {
|
app.on('second-instance', (_, commandLine, workingDirectory) => {
|
||||||
logger.info('detect second instance')
|
logger.info('detect second instance')
|
||||||
|
if (pendingActivateWindowTimer !== null) {
|
||||||
|
clearTimeout(pendingActivateWindowTimer)
|
||||||
|
pendingActivateWindowTimer = null
|
||||||
|
}
|
||||||
const result = handleStartUpFiles(commandLine, workingDirectory)
|
const result = handleStartUpFiles(commandLine, workingDirectory)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
windowManager.create(IWindowList.SETTING_WINDOW)
|
windowManager.create(IWindowList.SETTING_WINDOW)
|
||||||
@@ -235,7 +241,13 @@ class LifeCycle {
|
|||||||
})
|
})
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (!windowManager.has(IWindowList.SETTING_WINDOW)) {
|
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
|
const storedAutoStartEnabled = picgo.getConfig<boolean>(configPaths.settings.autoStart) || false
|
||||||
|
|||||||
Reference in New Issue
Block a user