From ef2b42f3f759c0e9c722a0f2399bc744c9193923 Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 10 Mar 2025 22:17:12 +0100 Subject: [PATCH] fix: update environment detection to use Tauri instead of Electron for service worker registration --- src/app/app.module.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7642881f5..1303161c3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,6 +13,7 @@ import { StoreModule } from '@ngrx/store'; import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; +import { isTauri } from '@tauri-apps/api/core'; import { NgxIndexedDBModule, NgxIndexedDBService } from 'ngx-indexed-db'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxWhatsNewModule } from 'ngx-whats-new'; @@ -33,17 +34,6 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } -/** - * Returns true if the application runs in the electron based environment. - */ -function isElectron() { - return !!(window && window.process && (window.process as any).type); -} - -function isTauri() { - return '__TAURI_INTERNALS__' in window || '__TAURI__' in window; -} - /** * Conditionally imports the necessary service based on the current environment */ @@ -78,7 +68,7 @@ export function DataFactory() { }, }), ServiceWorkerModule.register('ngsw-worker.js', { - enabled: AppConfig.production && !isElectron(), + enabled: AppConfig.production && !isTauri(), registrationStrategy: 'registerWhenStable:30000', }), StoreModule.forRoot({