Skip to content

armgit / ente

Public Imported from GitHub
0

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

Final stretch

Manav Rathic729516fafe4
diff --git a/web/apps/photos/src/components/WatchFolder/index.tsx b/web/apps/photos/src/components/WatchFolder/index.tsx
index 9c8d536e00..4ccfd41387 100644
--- a/web/apps/photos/src/components/WatchFolder/index.tsx
+++ b/web/apps/photos/src/components/WatchFolder/index.tsx
@@ -1,17 +1,14 @@
+import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
import { Button, Dialog, DialogContent, Stack } from "@mui/material";
+import UploadStrategyChoiceModal from "components/Upload/UploadStrategyChoiceModal";
+import { PICKED_UPLOAD_TYPE, UPLOAD_STRATEGY } from "constants/upload";
import { t } from "i18next";
import { AppContext } from "pages/_app";
import { useContext, useEffect, useState } from "react";
import watchFolderService from "services/watchFolder/watchFolderService";
import { WatchMapping } from "types/watchFolder";
-import { MappingList } from "./mappingList";
-
-import ElectronAPIs from "@/next/electron";
-import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
-import UploadStrategyChoiceModal from "components/Upload/UploadStrategyChoiceModal";
-import { PICKED_UPLOAD_TYPE, UPLOAD_STRATEGY } from "constants/upload";
-import isElectron from "is-electron";
import { getImportSuggestion } from "utils/upload";
+import { MappingList } from "./mappingList";
interface Iprops {
open: boolean;
@@ -24,10 +21,10 @@ export default function WatchFolder({ open, onClose }: Iprops) {
const [choiceModalOpen, setChoiceModalOpen] = useState(false);
const appContext = useContext(AppContext);
+ const electron = globalThis.electron;
+
useEffect(() => {
- if (!isElectron()) {
- return;
- }
+ if (!electron) return;
watchFolderService.getWatchMappings().then((m) => setMappings(m));
}, []);
@@ -52,8 +49,10 @@ export default function WatchFolder({ open, onClose }: Iprops) {
};
const addFolderForWatching = async (path: string) => {
+ if (!electron) return;
+
setInputFolderPath(path);
- const files = await ElectronAPIs.getDirFiles(path);
+ const files = await electron.getDirFiles(path);
const analysisResult = getImportSuggestion(
PICKED_UPLOAD_TYPE.FOLDERS,
files,
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index 38b30d49b1..4594b2e20a 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -1,5 +1,4 @@
import { CustomHead } from "@/next/components/Head";
-import ElectronAPIs from "@/next/electron";
import { setupI18n } from "@/next/i18n";
import log from "@/next/log";
import { logStartupBanner } from "@/next/log-web";
@@ -154,7 +153,8 @@ export default function App({ Component, pageProps }: AppProps) {
}, []);
useEffect(() => {
- if (isElectron()) {
+ const electron = globalThis.electron;
+ if (electron) {
const showUpdateDialog = (updateInfo: AppUpdateInfo) => {
if (updateInfo.autoUpdatable) {
setDialogMessage(
@@ -174,7 +174,7 @@ export default function App({ Component, pageProps }: AppProps) {
});
}
};
- ElectronAPIs.registerUpdateEventListener(showUpdateDialog);
+ electron.registerUpdateEventListener(showUpdateDialog);
}
}, []);
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts
index a0c13a48a8..a838003d06 100644
--- a/web/apps/photos/src/utils/file/index.ts
+++ b/web/apps/photos/src/utils/file/index.ts
@@ -489,8 +489,9 @@ const convertToJPEGInElectron = async (
try {
const startTime = Date.now();
const inputFileData = new Uint8Array(await fileBlob.arrayBuffer());
- const convertedFileData = isElectron()
- ? await ElectronAPIs.convertToJPEG(inputFileData, filename)
+ const electron = globalThis.electron;
+ const convertedFileData = electron
+ ? await electron.convertToJPEG(inputFileData, filename)
: await workerBridge.convertToJPEG(inputFileData, filename);
log.info(
`originalFileSize:${convertBytesToHumanReadable(