Reduce API
This commit is contained in:
parent
afec29d6e7
commit
9a6f3133b1
2 changed files with 12 additions and 9 deletions
|
@ -111,9 +111,10 @@ export const WatchFolder: React.FC<WatchFolderProps> = ({ 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);
|
||||
|
|
|
@ -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<WatchMapping[]> {
|
||||
|
|
Loading…
Add table
Reference in a new issue