π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
replace usage of window['ElectronAPIs'] with globalThis['ElectronAPIs'] to make it worker safe
Abhinavb58d18b00378
diff --git a/apps/photos/src/services/electron/ffmpeg.ts b/apps/photos/src/services/electron/ffmpeg.tsindex 3bb89770c9..f45a575b9f 100644--- a/apps/photos/src/services/electron/ffmpeg.ts+++ b/apps/photos/src/services/electron/ffmpeg.ts@@ -1,13 +1,12 @@import { IFFmpeg } from 'services/ffmpeg/ffmpegFactory';import { ElectronAPIs } from 'types/electron';import { ElectronFile } from 'types/upload';-import { runningInBrowser } from 'utils/common';export class ElectronFFmpeg implements IFFmpeg {private electronAPIs: ElectronAPIs;constructor() {- this.electronAPIs = runningInBrowser() && globalThis['ElectronAPIs'];+ this.electronAPIs = globalThis['ElectronAPIs'];}async run(diff --git a/apps/photos/src/services/electron/fs.ts b/apps/photos/src/services/electron/fs.tsindex e918edb620..6e57ff2908 100644--- a/apps/photos/src/services/electron/fs.ts+++ b/apps/photos/src/services/electron/fs.ts@@ -1,12 +1,11 @@import { ElectronAPIs } from 'types/electron';-import { runningInBrowser } from 'utils/common';import { logError } from 'utils/sentry';class ElectronFSService {private electronAPIs: ElectronAPIs;constructor() {- this.electronAPIs = runningInBrowser() && window['ElectronAPIs'];+ this.electronAPIs = globalThis['ElectronAPIs'];}getDirFiles(dirPath: string) {diff --git a/apps/photos/src/services/export/index.ts b/apps/photos/src/services/export/index.tsindex e2c34d8f30..daf5eb3718 100644--- a/apps/photos/src/services/export/index.ts+++ b/apps/photos/src/services/export/index.ts@@ -1,4 +1,4 @@-import { runningInBrowser, sleep } from 'utils/common';+import { sleep } from 'utils/common';import {getUnExportedFiles,getGoogleLikeMetadataFile,@@ -96,9 +96,7 @@ class ExportService {};constructor() {- if (runningInBrowser()) {- this.electronAPIs = window['ElectronAPIs'];- }+ this.electronAPIs = globalThis['ElectronAPIs'];}getExportSettings(): ExportSettings {diff --git a/apps/photos/src/services/importService.ts b/apps/photos/src/services/importService.tsindex e9d35eb231..de6d8026fb 100644--- a/apps/photos/src/services/importService.ts+++ b/apps/photos/src/services/importService.ts@@ -2,7 +2,6 @@ import { PICKED_UPLOAD_TYPE } from 'constants/upload';import { Collection } from 'types/collection';import { ElectronAPIs } from 'types/electron';import { ElectronFile, FileWithCollection } from 'types/upload';-import { runningInBrowser } from 'utils/common';import { logError } from 'utils/sentry';interface PendingUploads {@@ -20,7 +19,7 @@ class ImportService {private allElectronAPIsExist: boolean = false;constructor() {- this.electronAPIs = runningInBrowser() && window['ElectronAPIs'];+ this.electronAPIs = globalThis['ElectronAPIs'];this.allElectronAPIsExist = !!this.electronAPIs?.getPendingUploads;}diff --git a/apps/photos/src/services/watchFolder/watchFolderService.ts b/apps/photos/src/services/watchFolder/watchFolderService.tsindex d0e47fb2b7..ba7edbf019 100644--- a/apps/photos/src/services/watchFolder/watchFolderService.ts+++ b/apps/photos/src/services/watchFolder/watchFolderService.ts@@ -1,7 +1,6 @@import { Collection } from 'types/collection';import { EncryptedEnteFile } from 'types/file';import { ElectronFile, FileWithCollection } from 'types/upload';-import { runningInBrowser } from 'utils/common';import { removeFromCollection } from '../collectionService';import { getLocalFiles } from '../fileService';import { logError } from 'utils/sentry';@@ -42,8 +41,7 @@ class watchFolderService {private setWatchFolderServiceIsRunning: (isRunning: boolean) => void;constructor() {- this.electronAPIs = (runningInBrowser() &&- window['ElectronAPIs']) as ElectronAPIs;+ this.electronAPIs = globalThis['ElectronAPIs'];this.allElectronAPIsExist = !!this.electronAPIs?.getWatchMappings;}