Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

handle clip on unsupported platforms

Abhinav13773a58d03b
diff --git a/apps/photos/src/pages/gallery/index.tsx b/apps/photos/src/pages/gallery/index.tsx
index b055dbac9e..b81e6410c2 100644
--- a/apps/photos/src/pages/gallery/index.tsx
+++ b/apps/photos/src/pages/gallery/index.tsx
@@ -123,7 +123,6 @@ import { getLocalFamilyData } from 'utils/user/family';
import InMemoryStore, { MS_KEYS } from 'services/InMemoryStore';
import { syncEmbeddings } from 'services/embeddingService';
import { ClipService } from 'services/clipService';
-import isElectron from 'is-electron';
export const DeadCenter = styled('div')`
flex: 1;
@@ -711,7 +710,7 @@ export default function Gallery() {
await syncTrash(collections, setTrashedFiles);
await syncEntities();
await syncMapEnabled();
- if (isElectron()) {
+ if (await ClipService.isClipSupported()) {
await syncEmbeddings();
void ClipService.scheduleImageEmbeddingExtraction();
}
diff --git a/apps/photos/src/services/clipService.ts b/apps/photos/src/services/clipService.ts
index 1af3fe48e1..cabe4509f6 100644
--- a/apps/photos/src/services/clipService.ts
+++ b/apps/photos/src/services/clipService.ts
@@ -11,6 +11,7 @@ import { addLogLine } from 'utils/logging';
import { CustomError } from 'utils/error';
import { LS_KEYS, getData } from 'utils/storage/localStorage';
import { getPersonalFiles } from 'utils/file';
+import isElectron from 'is-electron';
const CLIP_EMBEDDING_LENGTH = 512;
@@ -33,6 +34,14 @@ class ClipServiceImpl {
this.electronAPIs = globalThis['ElectronAPIs'];
}
+ isClipSupported = async () => {
+ if (!isElectron()) {
+ return false;
+ }
+ const platform = await this.electronAPIs.getPlatform();
+ return platform !== 'windows';
+ };
+
setOnUpdateHandler = (handler: (status: ClipExtractionStatus) => void) => {
this.onUpdateHandler = handler;
handler(this.clipExtractionStatus);
diff --git a/apps/photos/src/services/electron/common.ts b/apps/photos/src/services/electron/common.ts
index c09a5fabd3..2ed24b3dd8 100644
--- a/apps/photos/src/services/electron/common.ts
+++ b/apps/photos/src/services/electron/common.ts
@@ -68,6 +68,11 @@ class ElectronService {
return this.electronAPIs.updateOptOutOfCrashReports(optOut);
}
}
+ getPlatform() {
+ if (this.electronAPIs?.getPlatform) {
+ return this.electronAPIs.getPlatform();
+ }
+ }
}
export default new ElectronService();
diff --git a/apps/photos/src/services/searchService.ts b/apps/photos/src/services/searchService.ts
index 6d28408464..26159ea901 100644
--- a/apps/photos/src/services/searchService.ts
+++ b/apps/photos/src/services/searchService.ts
@@ -63,7 +63,7 @@ export const getAutoCompleteSuggestions =
...(await getLocationTagSuggestions(searchPhrase)),
...(await getThingSuggestion(searchPhrase)),
await getClipSuggestion(searchPhrase),
- ];
+ ].filter((suggestion) => !!suggestion);
return convertSuggestionsToOptions(suggestions, files);
} catch (e) {
@@ -290,6 +290,9 @@ async function getThingSuggestion(searchPhrase: string): Promise<Suggestion[]> {
}
async function getClipSuggestion(searchPhrase: string): Promise<Suggestion> {
+ if (!(await ClipService.isClipSupported())) {
+ return null;
+ }
const clipResults = await searchClip(searchPhrase);
return {
type: SuggestionType.CLIP,
diff --git a/apps/photos/src/types/electron/index.ts b/apps/photos/src/types/electron/index.ts
index 868f53ed20..02a903d6fb 100644
--- a/apps/photos/src/types/electron/index.ts
+++ b/apps/photos/src/types/electron/index.ts
@@ -96,4 +96,5 @@ export interface ElectronAPIs {
updateOptOutOfCrashReports: (optOut: boolean) => Promise<void>;
computeImageEmbedding: (imageData: Uint8Array) => Promise<Float32Array>;
computeTextEmbedding: (text: string) => Promise<Float32Array>;
+ getPlatform: () => Promise<'mac' | 'windows' | 'linux'>;
}