Skip to content

Commit

Permalink
fix: object is destroyed block app exit
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Apr 5, 2024
1 parent 089e311 commit e53c33d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion core/src/node/api/restful/helper/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 335,6 @@ export const chatCompletions = async (request: any, reply: any) => {
headers['Authorization'] = `Bearer ${apiKey}`
headers['api-key'] = apiKey
}
console.debug(apiUrl)

if (requestedModel.engine === 'openai' && request.body.stop) {
// openai only allows max 4 stop words
Expand Down
22 changes: 14 additions & 8 deletions electron/managers/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 94,10 @@ class WindowManager {
}

closeQuickAskWindow(): void {
if (this._quickAskWindow?.isDestroyed()) return
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
}

Expand All @@ -122,14 124,18 @@ 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
if (!this.mainWindow?.isDestroyed()) {
this.mainWindow?.close()
this.mainWindow?.destroy()
this.mainWindow = undefined
this._mainWindowVisible = false
}
if (!this._quickAskWindow?.isDestroyed()) {
this._quickAskWindow?.close()
this._quickAskWindow?.destroy()
this._quickAskWindow = undefined
this._quickAskWindowVisible = false
}
}
}

Expand Down

0 comments on commit e53c33d

Please sign in to comment.