feat(fe/api): expose delete api in fe
This commit is contained in:
parent
0e77cfe335
commit
79ccda2a67
2 changed files with 26 additions and 2 deletions
|
@ -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<string> => {
|
||||
return this.updater.initAll(params);
|
||||
}
|
||||
};
|
||||
|
||||
addUploadArray = (fileArray: Array<File>): 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<string> => {
|
||||
return await this.updater.self();
|
||||
|
@ -34,6 +35,14 @@ export class QuickshareAPI {
|
|||
getProps = (): ICoreState => {
|
||||
return this.updater.props;
|
||||
};
|
||||
|
||||
delete = async (
|
||||
dir: string,
|
||||
items: Array<MetadataResp>,
|
||||
selectedItems: Array<string>
|
||||
): Promise<string> => {
|
||||
return await this.updater.delete2(dir, items, selectedItems);
|
||||
};
|
||||
}
|
||||
|
||||
const api = new QuickshareAPI();
|
||||
|
|
|
@ -221,6 +221,21 @@ export class Updater {
|
|||
return "";
|
||||
};
|
||||
|
||||
delete2 = async (
|
||||
dir: string,
|
||||
items: Array<MetadataResp>,
|
||||
selectedItems: Array<string>
|
||||
): Promise<string> => {
|
||||
const dirParts = List(dir.split("/")).filter((part) => part !== "");
|
||||
const itemsList = List(items);
|
||||
let selectedItemsMap = Map<string, boolean>();
|
||||
selectedItems.forEach((item) => {
|
||||
selectedItemsMap = selectedItemsMap.set(item, true);
|
||||
});
|
||||
|
||||
return this.delete(dirParts, itemsList, selectedItemsMap);
|
||||
};
|
||||
|
||||
delete = async (
|
||||
dirParts: List<string>,
|
||||
items: List<MetadataResp>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue