Skip to content

Commit ac8df0a

Browse files
fix(files): stale state in fileTree
This commit attempts to fix the stale files state issue occuring from Internal State of fileTree. regression: to be found, how it occurred recently.
1 parent 76d297d commit ac8df0a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/lib/openFolder.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ function execOperation(type, action, url, $target, name) {
624624

625625
toast(strings.success);
626626
FileList.remove(url);
627+
removeEntryFromFileTree(url);
627628
}
628629

629630
async function renameFile() {
@@ -1055,6 +1056,24 @@ async function refreshOpenFolder(folderUrl) {
10551056
);
10561057
}
10571058

1059+
async function removeEntryFromFileTree(url){
1060+
const filesApp = sidebarApps.get("files");
1061+
const $els = filesApp.getAll(`[data-url="${folderUrl}"]`);
1062+
1063+
await Promise.all(
1064+
Array.from($els).map(async ($el) => {
1065+
if (!(helpers.isDir($el.dataset.type) || $el.dataset.type === "root")) {
1066+
return;
1067+
}
1068+
1069+
const fileTree = getLoadedFileTree($el);
1070+
if (fileTree) {
1071+
await fileTree.removeEntity(url);
1072+
}
1073+
}),
1074+
);
1075+
}
1076+
10581077
/**
10591078
* Create a folder tile
10601079
* @param {string} name

0 commit comments

Comments
 (0)