|
@@ -1,17 +1,14 @@
|
|
|
|
+import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
|
|
import { Button, Dialog, DialogContent, Stack } from "@mui/material";
|
|
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 { t } from "i18next";
|
|
import { AppContext } from "pages/_app";
|
|
import { AppContext } from "pages/_app";
|
|
import { useContext, useEffect, useState } from "react";
|
|
import { useContext, useEffect, useState } from "react";
|
|
import watchFolderService from "services/watchFolder/watchFolderService";
|
|
import watchFolderService from "services/watchFolder/watchFolderService";
|
|
import { WatchMapping } from "types/watchFolder";
|
|
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 { getImportSuggestion } from "utils/upload";
|
|
|
|
+import { MappingList } from "./mappingList";
|
|
|
|
|
|
interface Iprops {
|
|
interface Iprops {
|
|
open: boolean;
|
|
open: boolean;
|
|
@@ -24,10 +21,10 @@ export default function WatchFolder({ open, onClose }: Iprops) {
|
|
const [choiceModalOpen, setChoiceModalOpen] = useState(false);
|
|
const [choiceModalOpen, setChoiceModalOpen] = useState(false);
|
|
const appContext = useContext(AppContext);
|
|
const appContext = useContext(AppContext);
|
|
|
|
|
|
|
|
+ const electron = globalThis.electron;
|
|
|
|
+
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- if (!isElectron()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!electron) return;
|
|
watchFolderService.getWatchMappings().then((m) => setMappings(m));
|
|
watchFolderService.getWatchMappings().then((m) => setMappings(m));
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
@@ -52,8 +49,10 @@ export default function WatchFolder({ open, onClose }: Iprops) {
|
|
};
|
|
};
|
|
|
|
|
|
const addFolderForWatching = async (path: string) => {
|
|
const addFolderForWatching = async (path: string) => {
|
|
|
|
+ if (!electron) return;
|
|
|
|
+
|
|
setInputFolderPath(path);
|
|
setInputFolderPath(path);
|
|
- const files = await ElectronAPIs.getDirFiles(path);
|
|
|
|
|
|
+ const files = await electron.getDirFiles(path);
|
|
const analysisResult = getImportSuggestion(
|
|
const analysisResult = getImportSuggestion(
|
|
PICKED_UPLOAD_TYPE.FOLDERS,
|
|
PICKED_UPLOAD_TYPE.FOLDERS,
|
|
files,
|
|
files,
|