Skip to content

armgit / ente

Public Imported from GitHub
0

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

add get platform API

Abhinav7d3c0b3c0981
diff --git a/src/api/common.ts b/src/api/common.ts
index a097e290ab..fb8cf5224e 100644
--- a/src/api/common.ts
+++ b/src/api/common.ts
@@ -27,6 +27,15 @@ export const openDirectory = async (dirPath: string): Promise<void> => {
}
};
+export const getPlatform = async (): Promise<'mac' | 'windows' | 'linux'> => {
+ try {
+ return await ipcRenderer.invoke('get-platform');
+ } catch (e) {
+ logError(e, 'failed to get platform');
+ throw e;
+ }
+};
+
export {
logToDisk,
openLogDirectory,
diff --git a/src/preload.ts b/src/preload.ts
index 275a3a76e5..8ae4ce936e 100644
--- a/src/preload.ts
+++ b/src/preload.ts
@@ -41,6 +41,7 @@ import {
getAppVersion,
openDirectory,
updateOptOutOfCrashReports,
+ getPlatform,
} from './api/common';
import { fixHotReloadNext12 } from './utils/preload';
import {
@@ -117,4 +118,5 @@ windowObject['ElectronAPIs'] = {
updateOptOutOfCrashReports,
computeImageEmbedding,
computeTextEmbedding,
+ getPlatform,
};
diff --git a/src/utils/ipcComms.ts b/src/utils/ipcComms.ts
index aa896fd371..40029041eb 100644
--- a/src/utils/ipcComms.ts
+++ b/src/utils/ipcComms.ts
@@ -31,6 +31,7 @@ import {
computeImageEmbedding,
computeTextEmbedding,
} from '../services/clipService';
+import { getPlatform } from './common/platform';
export default function setupIpcComs(
tray: Tray,
@@ -176,4 +177,7 @@ export default function setupIpcComs(
ipcMain.handle('compute-text-embedding', (_, text) => {
return computeTextEmbedding(text);
});
+ ipcMain.handle('get-platform', () => {
+ return getPlatform();
+ });
}