Skip to content

Commit

Permalink
fix: quick ask blocks app update (janhq#2525)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Apr 2, 2024
1 parent f6d3b53 commit c6198ae
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions electron/handlers/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function handleAppUpdates() {
})
if (action.response === 0) {
trayManager.destroyCurrentTray()
windowManager.closeQuickAskWindow()
waitingToInstallVersion = _info?.version
autoUpdater.quitAndInstall()
}
Expand Down
10 changes: 7 additions & 3 deletions electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, Tray } from 'electron'
import { app, BrowserWindow } from 'electron'

import { join } from 'path'
/**
Expand All @@ -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'

/**
Expand Down Expand Up @@ -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()
})

Expand Down
16 changes: 15 additions & 1 deletion electron/managers/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions web/screens/Chat/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
}
}

Expand Down Expand Up @@ -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>
Jan’s in beta. Access&nbsp;
<span
Expand Down

0 comments on commit c6198ae

Please sign in to comment.