Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(mobile): sort lists by name (#3040)

Aditya Raj Singh3486c3aa9d66
diff --git a/apps/mobile/app/dashboard/(tabs)/(lists)/index.tsx b/apps/mobile/app/dashboard/(tabs)/(lists)/index.tsx
index db6af022..b4d4c320 100644
--- a/apps/mobile/app/dashboard/(tabs)/(lists)/index.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/(lists)/index.tsx
@@ -34,6 +34,10 @@ interface ListLink {
numBookmarks?: number;
}
+function byName(a: ZBookmarkListTreeNode, b: ZBookmarkListTreeNode) {
+ return a.item.name.localeCompare(b.item.name);
+}
+
function traverseTree(
node: ZBookmarkListTreeNode,
links: ListLink[],
@@ -55,16 +59,18 @@ function traverseTree(
});
if (node.children && showChildrenOf[node.item.id]) {
- node.children.forEach((child) =>
- traverseTree(
- child,
- links,
- showChildrenOf,
- listStats,
- node.item.id,
- level + 1,
- ),
- );
+ [...node.children]
+ .sort(byName)
+ .forEach((child) =>
+ traverseTree(
+ child,
+ links,
+ showChildrenOf,
+ listStats,
+ node.item.id,
+ level + 1,
+ ),
+ );
}
}
@@ -149,27 +155,31 @@ export default function Lists() {
// Add shared lists as children if section is expanded
if (showChildrenOf["shared-section"]) {
- Object.values(lists.root).forEach((list) => {
- if (list.item.userRole !== "owner") {
- traverseTree(
- list,
- links,
- showChildrenOf,
- listStats?.stats,
- "shared-section",
- 1,
- );
- }
- });
+ Object.values(lists.root)
+ .sort(byName)
+ .forEach((list) => {
+ if (list.item.userRole !== "owner") {
+ traverseTree(
+ list,
+ links,
+ showChildrenOf,
+ listStats?.stats,
+ "shared-section",
+ 1,
+ );
+ }
+ });
}
}
// Add owned lists only
- Object.values(lists.root).forEach((list) => {
- if (list.item.userRole === "owner") {
- traverseTree(list, links, showChildrenOf, listStats?.stats);
- }
- });
+ Object.values(lists.root)
+ .sort(byName)
+ .forEach((list) => {
+ if (list.item.userRole === "owner") {
+ traverseTree(list, links, showChildrenOf, listStats?.stats);
+ }
+ });
return (
<>