fix: quick ask blocks app update (#2525)

This commit is contained in:
Louis 2024-04-02 12:32:12 +07:00 committed by GitHub
parent f6d3b53ab5
commit c6198ae423
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 6 deletions

View File

@ -39,6 +39,7 @@ export function handleAppUpdates() {
}) })
if (action.response === 0) { if (action.response === 0) {
trayManager.destroyCurrentTray() trayManager.destroyCurrentTray()
windowManager.closeQuickAskWindow()
waitingToInstallVersion = _info?.version waitingToInstallVersion = _info?.version
autoUpdater.quitAndInstall() autoUpdater.quitAndInstall()
} }

View File

@ -1,4 +1,4 @@
import { app, BrowserWindow, Tray } from 'electron' import { app, BrowserWindow } from 'electron'
import { join } from 'path' import { join } from 'path'
/** /**
@ -11,7 +11,7 @@ import { getAppConfigurations, log } from '@janhq/core/node'
* IPC Handlers * IPC Handlers
**/ **/
import { injectHandler } from './handlers/common' import { injectHandler } from './handlers/common'
import { handleAppUpdates, waitingToInstallVersion } from './handlers/update' import { handleAppUpdates } from './handlers/update'
import { handleAppIPCs } from './handlers/native' import { handleAppIPCs } from './handlers/native'
/** /**
@ -96,7 +96,11 @@ app.once('quit', () => {
app.once('window-all-closed', () => { app.once('window-all-closed', () => {
// Feature Toggle for Quick Ask // Feature Toggle for Quick Ask
if (getAppConfigurations().quick_ask && !waitingToInstallVersion) return if (
getAppConfigurations().quick_ask &&
!windowManager.isQuickAskWindowDestroyed()
)
return
cleanUpAndQuit() cleanUpAndQuit()
}) })

View File

@ -93,10 +93,20 @@ class WindowManager {
this._quickAskWindowVisible = true this._quickAskWindowVisible = true
} }
closeQuickAskWindow(): void {
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindowVisible = false
}
isQuickAskWindowVisible(): boolean { isQuickAskWindowVisible(): boolean {
return this._quickAskWindowVisible return this._quickAskWindowVisible
} }
isQuickAskWindowDestroyed(): boolean {
return this._quickAskWindow?.isDestroyed() ?? true
}
expandQuickAskWindow(heightOffset: number): void { expandQuickAskWindow(heightOffset: number): void {
const width = quickAskWindowConfig.width! const width = quickAskWindowConfig.width!
const height = quickAskWindowConfig.height! + heightOffset const height = quickAskWindowConfig.height! + heightOffset
@ -112,8 +122,12 @@ class WindowManager {
} }
cleanUp(): void { cleanUp(): void {
this.mainWindow?.close()
this.mainWindow?.destroy() this.mainWindow?.destroy()
this.mainWindow = undefined
this._quickAskWindow?.close()
this._quickAskWindow?.destroy() this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false this._quickAskWindowVisible = false
this._mainWindowVisible = false this._mainWindowVisible = false
} }

View File

@ -48,7 +48,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
</span> </span>
) )
default: default:
return message.content[0]?.text?.value return <AutoLink text={message.content[0]?.text?.value} />
} }
} }
@ -113,7 +113,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
key={message.id} key={message.id}
className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500" className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500"
> >
<AutoLink text={getErrorTitle()} /> {getErrorTitle()}
<p> <p>
Jans in beta. Access&nbsp; Jans in beta. Access&nbsp;
<span <span