Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
refactor: extract duplicated window instance object into helper (#7938)
BitCompass630385b7ced0
diff --git a/web-app/src/services/window/tauri.ts b/web-app/src/services/window/tauri.tsindex a0e976ced..bcd8b4abf 100644--- a/web-app/src/services/window/tauri.ts+++ b/web-app/src/services/window/tauri.ts@@ -57,24 +57,7 @@ export class TauriWindowService extends DefaultWindowService {// Setup theme listener for this windowthis.setupThemeListenerForWindow(webviewWindow)- return {- label: config.label,- async close() {- await webviewWindow.close()- },- async show() {- await webviewWindow.show()- },- async hide() {- await webviewWindow.hide()- },- async focus() {- await webviewWindow.setFocus()- },- async setTitle(title: string) {- await webviewWindow.setTitle(title)- },- }+ return this.toWindowInstance(config.label, webviewWindow)} catch (error) {console.error('Error creating Tauri window:', error)throw error@@ -88,24 +71,7 @@ export class TauriWindowService extends DefaultWindowService {const existingWindow = await WebviewWindow.getByLabel(label)if (existingWindow) {- return {- label: label,- async close() {- await existingWindow.close()- },- async show() {- await existingWindow.show()- },- async hide() {- await existingWindow.hide()- },- async focus() {- await existingWindow.setFocus()- },- async setTitle(title: string) {- await existingWindow.setTitle(title)- },- }+ return this.toWindowInstance(label, existingWindow)}return null@@ -180,6 +146,30 @@ export class TauriWindowService extends DefaultWindowService {}}+ private toWindowInstance(+ label: string,+ webviewWindow: WebviewWindow+ ): WebviewWindowInstance {+ return {+ label,+ async close() {+ await webviewWindow.close()+ },+ async show() {+ await webviewWindow.show()+ },+ async hide() {+ await webviewWindow.hide()+ },+ async focus() {+ await webviewWindow.setFocus()+ },+ async setTitle(title: string) {+ await webviewWindow.setTitle(title)+ },+ }+ }+private setupThemeListenerForWindow(window: WebviewWindow): void {// Listen to theme change events from Tauri backendimport('@tauri-apps/api/event')