Final stretch

This commit is contained in:
Manav Rathi
2024-04-09 12:18:18 +05:30
parent 56ce5c0b0e
commit c729516faf
3 changed files with 16 additions and 16 deletions

View File

@@ -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,

View File

@@ -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);
}
}, []);

View File

@@ -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(