diff --git a/spec/__snapshots__/aboutApp.spec.ts.snap b/spec/__snapshots__/aboutApp.spec.ts.snap index 069d9d0a..478424af 100644 --- a/spec/__snapshots__/aboutApp.spec.ts.snap +++ b/spec/__snapshots__/aboutApp.spec.ts.snap @@ -6,7 +6,7 @@ exports[`about app should render correctly 1`] = ` > { + if (item.checked) { + await autoLaunch.enableAutoLaunch(); + } else { + await autoLaunch.disableAutoLaunch(); + } + launchOnStartup = item.checked; + await config.updateUserConfig({ launchOnStartup }); + }, + label: i18n.t('Auto Launch On Startup')(), + type: 'checkbox', + }, + { + checked: isAlwaysOnTop, + click: async (item) => { + isAlwaysOnTop = item.checked; + updateAlwaysOnTop(item.checked, true); + await config.updateUserConfig({ alwaysOnTop: item.checked }); + }, + label: i18n.t('Always on Top')(), + type: 'checkbox', + }, + { + checked: minimizeOnClose, + click: async (item) => { + minimizeOnClose = item.checked; + await config.updateUserConfig({ minimizeOnClose }); + }, + label: i18n.t('Minimize on Close')(), + type: 'checkbox', + }, + { + checked: bringToFront, + click: async (item) => { + bringToFront = item.checked; + await config.updateUserConfig({ bringToFront }); + }, + label: isWindowsOS + ? i18n.t('Flash Notification in Taskbar')() + : i18n.t('Bring to Front on Notifications')(), + type: 'checkbox', + }, + this.buildSeparator(), + { + checked: memoryRefresh, + click: async (item) => { + memoryRefresh = item.checked; + await config.updateUserConfig({ memoryRefresh }); + }, + label: i18n.t('Refresh app when idle')(), + type: 'checkbox', + }, + { + click: (_item, focusedWindow) => { + if (focusedWindow && !focusedWindow.isDestroyed()) { + const defaultSession = session.defaultSession; + if (defaultSession) { + defaultSession.clearCache(() => { + focusedWindow.reload(); + }); + } + } + }, + label: i18n.t('Clear cache and Reload')(), + }, + ]; + + if (isWindowsOS) { + submenu.push({ + label: i18n.t('About Symphony')(), + click(_menuItem, focusedWindow) { + const windowName = focusedWindow ? (focusedWindow as ICustomBrowserWindow).winName : ''; + windowHandler.createAboutAppWindow(windowName); + }, + }); + } + return { label: i18n.t('Window')(), role: 'window', - submenu: [ - this.assignRoleOrLabel('minimize', i18n.t('Minimize')()), - this.assignRoleOrLabel('close', i18n.t('Close')()), - this.buildSeparator(), - { - checked: launchOnStartup, - click: async (item) => { - if (item.checked) { - await autoLaunch.enableAutoLaunch(); - } else { - await autoLaunch.disableAutoLaunch(); - } - launchOnStartup = item.checked; - await config.updateUserConfig({ launchOnStartup }); - }, - label: i18n.t('Auto Launch On Startup')(), - type: 'checkbox', - }, - { - checked: isAlwaysOnTop, - click: async (item) => { - isAlwaysOnTop = item.checked; - updateAlwaysOnTop(item.checked, true); - await config.updateUserConfig({ alwaysOnTop: item.checked }); - }, - label: i18n.t('Always on Top')(), - type: 'checkbox', - }, - { - checked: minimizeOnClose, - click: async (item) => { - minimizeOnClose = item.checked; - await config.updateUserConfig({ minimizeOnClose }); - }, - label: i18n.t('Minimize on Close')(), - type: 'checkbox', - }, - { - checked: bringToFront, - click: async (item) => { - bringToFront = item.checked; - await config.updateUserConfig({ bringToFront }); - }, - label: isWindowsOS - ? i18n.t('Flash Notification in Taskbar')() - : i18n.t('Bring to Front on Notifications')(), - type: 'checkbox', - }, - this.buildSeparator(), - { - checked: memoryRefresh, - click: async (item) => { - memoryRefresh = item.checked; - await config.updateUserConfig({ memoryRefresh }); - }, - label: i18n.t('Refresh app when idle')(), - type: 'checkbox', - }, - { - click: (_item, focusedWindow) => { - if (focusedWindow && !focusedWindow.isDestroyed()) { - const defaultSession = session.defaultSession; - if (defaultSession) { - defaultSession.clearCache(() => { - focusedWindow.reload(); - }); - } - } - }, - label: i18n.t('Clear cache and Reload')(), - }, - ], + submenu, }; } diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 33edc89d..a190c44b 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -363,8 +363,28 @@ export class WindowHandler { /** * Creates a about app window */ - public createAboutAppWindow(): void { - this.aboutAppWindow = createComponentWindow('about-app'); + public createAboutAppWindow(windowName: string): void { + + // This prevents creating multiple instances of the + // about window + if (this.aboutAppWindow && windowExists(this.aboutAppWindow)) { + if (this.aboutAppWindow.isMinimized()) { + this.aboutAppWindow.restore(); + } + this.aboutAppWindow.focus(); + return; + } + + const allWindows = BrowserWindow.getAllWindows(); + const selectedParentWindow = allWindows.find((window) => { + return (window as ICustomBrowserWindow).winName === windowName; + }); + + this.aboutAppWindow = createComponentWindow( + 'about-app', + selectedParentWindow ? { parent: selectedParentWindow } : {}, + ); + this.aboutAppWindow.setVisibleOnAllWorkspaces(true); this.aboutAppWindow.webContents.once('did-finish-load', () => { if (!this.aboutAppWindow || !windowExists(this.aboutAppWindow)) { return; diff --git a/src/renderer/components/about-app.tsx b/src/renderer/components/about-app.tsx index 42de6c1c..bd9dead5 100644 --- a/src/renderer/components/about-app.tsx +++ b/src/renderer/components/about-app.tsx @@ -35,7 +35,7 @@ export default class AboutApp extends React.Component<{}, IState> { const copyright = `Copyright \xA9 ${new Date().getFullYear()} ${appName}`; return (
- + {appName} {versionString} {copyright}