refactor: externalize local folder watch marker
This commit is contained in:
@@ -2442,6 +2442,14 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
return applied;
|
||||
}
|
||||
|
||||
function markLocalFolderWatchApplied(value) {
|
||||
var runtimeFn = fileTreeRuntimeFunction('markLocalFolderWatchApplied');
|
||||
if (runtimeFn) return runtimeFn(value);
|
||||
var appliedValue = String(value || 'projection');
|
||||
document.documentElement.setAttribute('data-mnote-local-folder-watch-applied', appliedValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
async function refreshLocalFolderSidebarSnapshot() {
|
||||
var workspaceId = currentWorkspaceId();
|
||||
var rootUri = currentRootUri();
|
||||
@@ -2474,7 +2482,7 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
schedulePendingLocalFolderRestoreFocus();
|
||||
restoreSidebarTreeTab();
|
||||
refreshEditorLocalAttachmentExistence();
|
||||
document.documentElement.setAttribute('data-mnote-local-folder-watch-applied', 'projection');
|
||||
markLocalFolderWatchApplied('projection');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11111,6 +11119,7 @@ mod tests {
|
||||
assert!(
|
||||
SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('applyLocalFolderSidebarSnapshot')")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('markLocalFolderWatchApplied')"));
|
||||
let document_id_body = js_function_body(SIDEBAR_TREE_JS, "fileTreeRowDocumentId");
|
||||
assert!(
|
||||
document_id_body.contains("data-document-id")
|
||||
@@ -11131,6 +11140,12 @@ mod tests {
|
||||
&& apply_body.contains("replaceSidebarTreeFromDocument(nextDocument, fileRootId)"),
|
||||
"inline fallback 必须保留 sidebar/page tree DOM 应用行为"
|
||||
);
|
||||
let watch_applied_body = js_function_body(SIDEBAR_TREE_JS, "markLocalFolderWatchApplied");
|
||||
assert!(
|
||||
watch_applied_body.contains("data-mnote-local-folder-watch-applied")
|
||||
&& watch_applied_body.contains("String(value || 'projection')"),
|
||||
"inline fallback 必须保留 local folder watch projection 标记"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -11161,12 +11176,15 @@ mod tests {
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function groupRowsByParent"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function replaceSidebarTreeFromDocument"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function applyLocalFolderSidebarSnapshot"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function markLocalFolderWatchApplied"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("appendUploadedAssetRow: appendUploadedAssetRow"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("groupRowsByParent: groupRowsByParent"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("markLocalFolderWatchApplied: markLocalFolderWatchApplied"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
|
||||
Reference in New Issue
Block a user