Skip to content

Commit 59c6fe0

Browse files
committed
#RI-4881 - [Regression] Application can be opened via application icon if the application is in tray
1 parent 0bd19dc commit 59c6fe0

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

redisinsight/desktop/src/lib/app/app.handlers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { app } from 'electron'
22
import log from 'electron-log'
3-
import { getBackendGracefulShutdown, WindowType, getWindows, windowFactory } from 'desktopSrc/lib'
3+
import { getBackendGracefulShutdown } from 'desktopSrc/lib'
44
import { deepLinkHandler, deepLinkWindowHandler } from 'desktopSrc/lib/app/deep-link.handlers'
5+
import { showOrCreateWindow } from 'desktopSrc/utils'
56

67
export const initAppHandlers = () => {
7-
app.on('activate', () => {
8+
app.on('activate', async () => {
89
// On macOS it's common to re-create a window in the app when the
910
// dock icon is clicked and there are no other windows open.
10-
if (getWindows()?.size === 0) windowFactory(WindowType.Main)
11+
await showOrCreateWindow()
1112
})
1213

1314
app.on('certificate-error', (event, _webContents, _url, _error, _certificate, callback) => {

redisinsight/desktop/src/lib/app/deep-link.handlers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const deepLinkWindowHandler = async (parsedDeepLink?: IParsedDeepLink) =>
4343
if (parsedDeepLink?.target === '_blank') {
4444
await windowFactory(WindowType.Main, null, { parsedDeepLink })
4545
} else if (currentWindow) {
46+
currentWindow?.show()
4647
currentWindow?.webContents.send(IpcOnEvent.deepLinkAction, parsedDeepLink)
4748
focusWindow(currentWindow)
4849
} else {

redisinsight/desktop/src/lib/tray/tray.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { app, Menu, shell, Tray, nativeImage, BrowserWindow, MenuItemConstructorOptions } from 'electron'
1+
import { app, Menu, shell, Tray, nativeImage, MenuItemConstructorOptions } from 'electron'
22
import path from 'path'
3-
import { WindowType, getWindows, windowFactory } from 'desktopSrc/lib'
3+
import { getWindows } from 'desktopSrc/lib'
4+
import { showOrCreateWindow } from 'desktopSrc/utils'
45
// eslint-disable-next-line import/no-cycle
56
import { setToQuiting } from './trayManager'
67

@@ -100,14 +101,7 @@ export class TrayBuilder {
100101
this.tray.setToolTip(name)
101102
}
102103

103-
private openApp() {
104-
if (getWindows()?.size) {
105-
getWindows()?.forEach((window: BrowserWindow) => window.show())
106-
app.dock?.show()
107-
}
108-
109-
if (!getWindows()?.size) {
110-
windowFactory(WindowType.Main)
111-
}
104+
private async openApp() {
105+
await showOrCreateWindow()
112106
}
113107
}

redisinsight/desktop/src/lib/window/window.handlers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
WindowType,
1111
} from 'desktopSrc/lib'
1212
import { IpcInvokeEvent, ElectronStorageItem, IpcOnEvent } from 'uiSrc/electron/constants'
13-
import { Pages } from 'uiSrc/constants/pages'
1413

1514
export const initWindowHandlers = (
1615
newWindow: BrowserWindow,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './resolveHtmlPath'
22
export * from './wrapErrorSensitiveData'
33
export * from './getAssetPath'
4+
export * from './showOrCreateWindow'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { BrowserWindow, app } from 'electron'
2+
import { WindowType, getWindows, windowFactory } from 'desktopSrc/lib'
3+
4+
export const showOrCreateWindow = async () => {
5+
if (getWindows()?.size) {
6+
getWindows()?.forEach((window: BrowserWindow) => window.show())
7+
app.dock?.show()
8+
}
9+
10+
if (!getWindows()?.size) {
11+
await windowFactory(WindowType.Main)
12+
}
13+
}

0 commit comments

Comments
 (0)