Skip to content

Commit

Permalink
Use depth for page tree serializer root_or_leaf
Browse files Browse the repository at this point in the history
Depth is a cached attribute on the page that does not need calculation and will always be correct even if the root page has been removed.

This commit helps to migrate to Alchemy 5 without making further changes to the page tree serializer. Without that change page trees that already have been migrated to "root-page-less" Alchemy 5 will have page toggle switches disappear in the first level.
  • Loading branch information
tvdeyen committed Jun 2, 2020
1 parent 5434465 commit d7d2f1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/serializers/alchemy/page_tree_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def page_hash(page, has_children, level, folded)
urlname: page.urlname,
external_urlname: page.definition['redirects_to_external'] ? page.external_urlname : nil,
level: level,
root: level == 1,
root_or_leaf: level == 1 || !has_children,
root: page.depth == 1,
root_or_leaf: page.depth == 1 || !has_children,
children: []
}

Expand Down

0 comments on commit d7d2f1f

Please sign in to comment.