From 4bc1b90f9f0de41851cb4288d4614edc35b63144 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Mon, 26 Jan 2026 11:51:21 +0000 Subject: feat(mobile): show num bookmarks in the all lists view --- apps/mobile/app/dashboard/(tabs)/lists.tsx | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'apps/mobile/app/dashboard') diff --git a/apps/mobile/app/dashboard/(tabs)/lists.tsx b/apps/mobile/app/dashboard/(tabs)/lists.tsx index 2e107868..45c23a28 100644 --- a/apps/mobile/app/dashboard/(tabs)/lists.tsx +++ b/apps/mobile/app/dashboard/(tabs)/lists.tsx @@ -40,12 +40,14 @@ interface ListLink { numChildren: number; collapsed: boolean; isSharedSection?: boolean; + numBookmarks?: number; } function traverseTree( node: ZBookmarkListTreeNode, links: ListLink[], showChildrenOf: Record, + listStats?: Map, parent?: string, level = 0, ) { @@ -58,11 +60,19 @@ function traverseTree( parent, numChildren: node.children?.length ?? 0, collapsed: !showChildrenOf[node.item.id], + numBookmarks: listStats?.get(node.item.id), }); if (node.children && showChildrenOf[node.item.id]) { node.children.forEach((child) => - traverseTree(child, links, showChildrenOf, node.item.id, level + 1), + traverseTree( + child, + links, + showChildrenOf, + listStats, + node.item.id, + level + 1, + ), ); } } @@ -75,6 +85,7 @@ export default function Lists() { {}, ); const apiUtils = api.useUtils(); + const { data: listStats } = api.lists.stats.useQuery(); // Check if there are any shared lists const hasSharedLists = useMemo(() => { @@ -106,6 +117,7 @@ export default function Lists() { const onRefresh = () => { apiUtils.lists.list.invalidate(); + apiUtils.lists.stats.invalidate(); }; const links: ListLink[] = [ @@ -151,7 +163,14 @@ export default function Lists() { if (showChildrenOf["shared-section"]) { Object.values(lists.root).forEach((list) => { if (list.item.userRole !== "owner") { - traverseTree(list, links, showChildrenOf, "shared-section", 1); + traverseTree( + list, + links, + showChildrenOf, + listStats?.stats, + "shared-section", + 1, + ); } }); } @@ -160,7 +179,7 @@ export default function Lists() { // Add owned lists only Object.values(lists.root).forEach((list) => { if (list.item.userRole === "owner") { - traverseTree(list, links, showChildrenOf); + traverseTree(list, links, showChildrenOf, listStats?.stats); } }); @@ -237,7 +256,14 @@ export default function Lists() { {l.item.logo} {l.item.name} - + + {l.item.numBookmarks !== undefined && ( + + {l.item.numBookmarks} + + )} + + )} -- cgit v1.2.3-70-g09d2