refactor: extract filetree document workspace preflight

This commit is contained in:
lix-2026
2026-05-25 09:28:50 +08:00
parent 5e427a469a
commit 812504924f
3 changed files with 43 additions and 1 deletions
@@ -475,6 +475,21 @@ function fileTreeDropPreflightRows(deps) {
});
}
function fileTreeDocumentWorkspacesForUploadPreflight(workspaceId, deps) {
deps = deps || {};
var rows = typeof deps.fileTreeRowsForUploadPreflight === 'function'
? deps.fileTreeRowsForUploadPreflight()
: fileTreeRowsForUploadPreflight(deps);
var seen = new Set();
return rows.filter(function(row) {
if (!row.documentId || seen.has(row.documentId)) return false;
seen.add(row.documentId);
return true;
}).map(function(row) {
return { documentId: row.documentId, workspaceId: workspaceId || null };
});
}
window.__mnoteFileTreeRuntime = {
readProjection: readProjection,
readSidebarDataset: readSidebarDataset,
@@ -509,5 +524,6 @@ window.__mnoteFileTreeRuntime = {
fileTreeRowsForUploadPreflight: fileTreeRowsForUploadPreflight,
fileTreeDocumentParentsForPreflight: fileTreeDocumentParentsForPreflight,
fileTreeTargetChildrenForPreflight: fileTreeTargetChildrenForPreflight,
fileTreeDropPreflightRows: fileTreeDropPreflightRows
fileTreeDropPreflightRows: fileTreeDropPreflightRows,
fileTreeDocumentWorkspacesForUploadPreflight: fileTreeDocumentWorkspacesForUploadPreflight
};