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) {
trayManager.destroyCurrentTray()
windowManager.closeQuickAskWindow()
waitingToInstallVersion = _info?.version
autoUpdater.quitAndInstall()
}

View File

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

View File

@ -45,7 +45,7 @@ class WindowManager {
windowManager.mainWindow?.on('close', function (evt) {
// Feature Toggle for Quick Ask
if (!getAppConfigurations().quick_ask) return
if (!isAppQuitting) {
evt.preventDefault()
windowManager.hideMainWindow()
@ -93,10 +93,20 @@ class WindowManager {
this._quickAskWindowVisible = true
}
closeQuickAskWindow(): void {
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindowVisible = false
}
isQuickAskWindowVisible(): boolean {
return this._quickAskWindowVisible
}
isQuickAskWindowDestroyed(): boolean {
return this._quickAskWindow?.isDestroyed() ?? true
}
expandQuickAskWindow(heightOffset: number): void {
const width = quickAskWindowConfig.width!
const height = quickAskWindowConfig.height! + heightOffset
@ -112,8 +122,12 @@ class WindowManager {
}
cleanUp(): void {
this.mainWindow?.close()
this.mainWindow?.destroy()
this.mainWindow = undefined
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
this._mainWindowVisible = false
}

View File

@ -48,7 +48,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
</span>
)
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}
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>
Jans in beta. Access&nbsp;
<span