Skip to content

Commit

Permalink
feat: spread favicon to children nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed May 27, 2024
1 parent 5a06446 commit 35b6dcd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/domain/entities/LandingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const updateLandingNodes = (
permissions: LandingPagePermission[],
user: User
): LandingNode[] => {
return _(nodes)
const updatedNodes = _(nodes)
.map(node => {
const pagePermission = permissions?.find(permission => permission.id === node.id);

Expand All @@ -96,6 +96,25 @@ export const updateLandingNodes = (
})
.compact()
.value();

return updatedNodes.map(node => applyFavicon(node));
};

const applyFavicon = (parent: LandingNode): LandingNode => {
const spreadFaviconToChildren = (children: LandingNode[], favicon: string): LandingNode[] => {
return _.map(children, child => {
const updatedChild: LandingNode = { ...child, favicon };
if (child.children) {
updatedChild.children = spreadFaviconToChildren(child.children, favicon);
}
return updatedChild;
});
};

return {
...parent,
children: parent.children ? spreadFaviconToChildren(parent.children, parent.favicon) : [],
};
};

/* Return a redirect URL if there is only one visible action on primary nodes */
Expand Down

0 comments on commit 35b6dcd

Please sign in to comment.