Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#505 #509

Merged
merged 20 commits into from
Dec 13, 2023
Merged

#505 #509

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cb,fb,param,return value fix for callFileApi
mrmatthewnguyen105 committed Dec 13, 2023
commit ed3ed87b92336802f8a1af8b8b9b81b5d0bc2c2d
100 changes: 49 additions & 51 deletions src/_node/file/actions.ts
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ const remove = async ({
}): Promise<boolean> => {
return new Promise<boolean>((resolve, reject) => {
try {
let Alldone = true;
let allDone = true;
uids.map((uid) => {
const done = FileSystemApis[projectContext].removeSingleDirectoryOrFile(
{
@@ -32,9 +32,9 @@ const remove = async ({
fileHandlers: fileHandlers || {},
},
);
if (!done) Alldone = false;
if (!done) allDone = false;
});
resolve(Alldone);
resolve(allDone);
} catch (err) {
reject(err);
}
@@ -50,54 +50,52 @@ export const doFileActions = async (
params: TFileApiPayload,
fb?: (...params: any[]) => void,
cb?: (...params: any[]) => void,
): Promise<void> => {
return new Promise((resolve, reject) => {
try {
const {
projectContext,
action,
uids,
fileTree,
fileHandlers,
osType = "Windows",
} = params;

switch (action) {
case "create":
create();
break;
case "remove":
remove({
projectContext,
uids,
fileTree,
fileHandlers,
});
break;
case "cut":
cut();
break;
case "copy":
copy();
break;
case "duplicate":
duplicate();
break;
case "move":
move();
break;
case "rename":
rename();
break;
default:
break;
}
) => {
try {
const {
projectContext,
action,
uids,
fileTree,
fileHandlers,
osType = "Windows",
} = params;

resolve();
} catch (err) {
LogAllow && console.error(err);
fb && fb();
reject();
let allDone = true;
switch (action) {
case "create":
create();
break;
case "remove":
allDone = await remove({
projectContext,
uids,
fileTree,
fileHandlers,
});
break;
case "cut":
cut();
break;
case "copy":
copy();
break;
case "duplicate":
duplicate();
break;
case "move":
move();
break;
case "rename":
rename();
break;
default:
break;
}
});

cb && cb(allDone);
} catch (err) {
LogAllow && console.error(err);
fb && fb();
}
};
Original file line number Diff line number Diff line change
@@ -305,18 +305,23 @@ export const useNodeActionsHandler = ({

addRunningActions(["fileTreeView-delete"]);
addInvalidNodes(...uids);
const allDone = callFileApi(
callFileApi(
{
projectContext: project.context,
action: "remove",
fileTree,
fileHandlers,
uids,
},
() => {},
() => {},
() => {
console.error("error while removing file system");
},
(allDone: boolean) => {
console.log(
allDone ? "all is successfully removed" : "some is not removed",
);
},
);
console.log({ allDone });
removeInvalidNodes(...uids);
removeRunningActions(["fileTreeView-delete"]);
}, [