Skip to content

Commit

Permalink
Merge pull request #796 from AppFlowy-IO/filter-by-parent-view
Browse files Browse the repository at this point in the history
fix: filter out children which the view's parent does not match the actual parent view id
  • Loading branch information
khorshuheng authored Sep 5, 2024
2 parents d3b5b4f + 50f24a1 commit bfc8b0d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/biz/collab/publish_outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,24 @@ pub fn collab_folder_to_published_outline(
.children
.iter()
.filter(|v| !unviewable.contains(&v.id))
.filter_map(|v| to_publish_view(&v.id, folder, &unviewable, publish_view_ids, 0, max_depth))
.filter_map(|v| {
to_publish_view(
&root.id,
&v.id,
folder,
&unviewable,
publish_view_ids,
0,
max_depth,
)
})
.collect(),
};
Ok(published_view)
}

fn to_publish_view(
parent_view_id: &str,
view_id: &str,
folder: &Folder,
unviewable: &HashSet<String>,
Expand All @@ -77,6 +88,12 @@ fn to_publish_view(
return None;
},
};

// There is currently a bug, in which the parent_view_id is not always set correctly
if view.parent_view_id != parent_view_id {
return None;
}

let extra = view.extra.as_deref().map(|extra| {
serde_json::from_str::<serde_json::Value>(extra).unwrap_or_else(|e| {
tracing::warn!("failed to parse extra field({}): {}", extra, e);
Expand All @@ -87,9 +104,10 @@ fn to_publish_view(
.children
.iter()
.filter(|v| !unviewable.contains(&v.id))
.filter_map(|view_id| {
.filter_map(|child_view_id| {
to_publish_view(
&view_id.id,
view_id,
&child_view_id.id,
folder,
unviewable,
publish_view_ids,
Expand Down

0 comments on commit bfc8b0d

Please sign in to comment.