Fix local filetree page tree open performance
This commit is contained in:
@@ -1350,7 +1350,9 @@ pub(crate) async fn build_page_aggregate_snapshot(
|
||||
resolve_local_markdown_page_aggregate(&root_uri_for_build, &document_id)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| WebError::internal(format!("本地 Page Aggregate 构建任务失败: {error}")))??;
|
||||
.map_err(|error| {
|
||||
WebError::internal(format!("本地 Page Aggregate 构建任务失败: {error}"))
|
||||
})??;
|
||||
super::ui_preferences::apply_effective_page_preferences(
|
||||
state,
|
||||
context,
|
||||
@@ -1661,12 +1663,22 @@ pub(crate) fn render_local_sidebar_tree_html(
|
||||
active_document_id: Option<&str>,
|
||||
) -> Result<String, WebError> {
|
||||
let snapshot = load_local_folder_page_tree_snapshot(root_uri)?;
|
||||
Ok(render_local_sidebar_tree_html_from_snapshot(
|
||||
&snapshot,
|
||||
active_document_id,
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn render_local_sidebar_tree_html_from_snapshot(
|
||||
snapshot: &crate::routes::snapshot_support::ProjectionSnapshot,
|
||||
active_document_id: Option<&str>,
|
||||
) -> String {
|
||||
let rows = collect_page_tree_render_rows(&snapshot.projection);
|
||||
Ok(render_initial_page_tree_html(&PageTreeInitialRenderInput {
|
||||
render_initial_page_tree_html(&PageTreeInitialRenderInput {
|
||||
rows,
|
||||
active_node_id: active_document_id.map(ToOwned::to_owned),
|
||||
focused_node_id: None,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn render_local_file_tree_html(
|
||||
@@ -2436,8 +2448,7 @@ mod tests {
|
||||
let aggregate_uri = format!(
|
||||
"/api/page-aggregate/local-md:Cold~20Start~2FCold~20Start.md?sourceKind=local_folder&rootUri={root_uri}"
|
||||
);
|
||||
super::LOCAL_PAGE_AGGREGATE_TEST_BLOCK_MS
|
||||
.store(400, std::sync::atomic::Ordering::SeqCst);
|
||||
super::LOCAL_PAGE_AGGREGATE_TEST_BLOCK_MS.store(400, std::sync::atomic::Ordering::SeqCst);
|
||||
struct ResetLocalAggregateBlock;
|
||||
impl Drop for ResetLocalAggregateBlock {
|
||||
fn drop(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user