diff --git a/web/apps/photos/src/components/WatchFolder.tsx b/web/apps/photos/src/components/WatchFolder.tsx index 8001dd992..b5ff00b29 100644 --- a/web/apps/photos/src/components/WatchFolder.tsx +++ b/web/apps/photos/src/components/WatchFolder.tsx @@ -111,9 +111,10 @@ export const WatchFolder: React.FC = ({ open, onClose }) => { setMappings(await watchFolderService.getWatchMappings()); }; - const handleRemoveWatchMapping = async (mapping: WatchMapping) => { - await watchFolderService.removeWatchMapping(mapping.folderPath); - setMappings(await watchFolderService.getWatchMappings()); + const handleRemoveWatchMapping = (mapping: WatchMapping) => { + watchFolderService + .mappingsAfterRemovingFolder(mapping.folderPath) + .then((ms) => setMappings(ms)); }; const closeChoiceModal = () => setChoiceModalOpen(false); diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.ts index 1c26addf0..2d5ef0228 100644 --- a/web/apps/photos/src/services/watch.ts +++ b/web/apps/photos/src/services/watch.ts @@ -1,3 +1,8 @@ +/** + * @file Interface with the Node.js layer of our desktop app to provide the + * watch folders functionality. + */ + import { ensureElectron } from "@/next/electron"; import log from "@/next/log"; import { UPLOAD_RESULT, UPLOAD_STRATEGY } from "constants/upload"; @@ -190,12 +195,9 @@ class WatchFolderService { } } - async removeWatchMapping(folderPath: string) { - try { - await ensureElectron().removeWatchMapping(folderPath); - } catch (e) { - log.error("error while removing watch mapping", e); - } + async mappingsAfterRemovingFolder(folderPath: string) { + await ensureElectron().removeWatchMapping(folderPath); + return await this.getWatchMappings(); } async getWatchMappings(): Promise {