Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: quick ask blocks app update #2525

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading