refactor: extract filetree document workspace preflight
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user