mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 16:56:22 +02:00
fix: scope pending doc warning to folder subtree on folder export
This commit is contained in:
parent
b5f6e44fc3
commit
a81fff299a
1 changed files with 23 additions and 3 deletions
|
|
@ -503,13 +503,33 @@ export function DocumentsSidebar({
|
|||
setExportWarningContext(null);
|
||||
}, [exportWarningContext, searchSpaceId, doExport]);
|
||||
|
||||
const getPendingCountInSubtree = useCallback(
|
||||
(folderId: number): number => {
|
||||
const subtreeIds = new Set<number>();
|
||||
function collect(id: number) {
|
||||
subtreeIds.add(id);
|
||||
for (const child of foldersByParent[String(id)] ?? []) {
|
||||
collect(child.id);
|
||||
}
|
||||
}
|
||||
collect(folderId);
|
||||
return treeDocuments.filter(
|
||||
(d) =>
|
||||
subtreeIds.has(d.folderId ?? -1) &&
|
||||
(d.status?.state === "pending" || d.status?.state === "processing")
|
||||
).length;
|
||||
},
|
||||
[foldersByParent, treeDocuments]
|
||||
);
|
||||
|
||||
const handleExportFolder = useCallback(
|
||||
async (folder: FolderDisplay) => {
|
||||
if (pendingDocuments.length > 0) {
|
||||
const folderPendingCount = getPendingCountInSubtree(folder.id);
|
||||
if (folderPendingCount > 0) {
|
||||
setExportWarningContext({
|
||||
type: "folder",
|
||||
folder,
|
||||
pendingCount: pendingDocuments.length,
|
||||
pendingCount: folderPendingCount,
|
||||
});
|
||||
setExportWarningOpen(true);
|
||||
return;
|
||||
|
|
@ -531,7 +551,7 @@ export function DocumentsSidebar({
|
|||
toast.error(err instanceof Error ? err.message : "Export failed");
|
||||
}
|
||||
},
|
||||
[searchSpaceId, pendingDocuments.length, doExport]
|
||||
[searchSpaceId, getPendingCountInSubtree, doExport]
|
||||
);
|
||||
|
||||
const handleExportDocument = useCallback(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue