diff --git a/src/client/web/src/components/api.ts b/src/client/web/src/components/api.ts index 6b6faa7..b5208c8 100644 --- a/src/client/web/src/components/api.ts +++ b/src/client/web/src/components/api.ts @@ -1,6 +1,7 @@ import { ICoreState } from "./core_state"; import { updater, Updater } from "./state_updater"; import { UploadEntry } from "../worker/interface"; +import { MetadataResp } from "../client"; export class QuickshareAPI { private updater: Updater; @@ -9,7 +10,7 @@ export class QuickshareAPI { } initAll = async (params: URLSearchParams): Promise => { return this.updater.initAll(params); - } + }; addUploadArray = (fileArray: Array): string => { return this.updater.addUploadArray(fileArray); @@ -25,7 +26,7 @@ export class QuickshareAPI { stopUploading = (filePath: string): string => { return this.updater.stopUploading(filePath); - } + }; self = async (): Promise => { return await this.updater.self(); @@ -34,6 +35,14 @@ export class QuickshareAPI { getProps = (): ICoreState => { return this.updater.props; }; + + delete = async ( + dir: string, + items: Array, + selectedItems: Array + ): Promise => { + return await this.updater.delete2(dir, items, selectedItems); + }; } const api = new QuickshareAPI(); diff --git a/src/client/web/src/components/state_updater.ts b/src/client/web/src/components/state_updater.ts index be0109a..3e5b072 100644 --- a/src/client/web/src/components/state_updater.ts +++ b/src/client/web/src/components/state_updater.ts @@ -221,6 +221,21 @@ export class Updater { return ""; }; + delete2 = async ( + dir: string, + items: Array, + selectedItems: Array + ): Promise => { + const dirParts = List(dir.split("/")).filter((part) => part !== ""); + const itemsList = List(items); + let selectedItemsMap = Map(); + selectedItems.forEach((item) => { + selectedItemsMap = selectedItemsMap.set(item, true); + }); + + return this.delete(dirParts, itemsList, selectedItemsMap); + }; + delete = async ( dirParts: List, items: List,