Skip to content

Commit

Permalink
Fix duplicate collection items in collection tree (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasuillard authored Feb 4, 2025
1 parent d010116 commit a0dde0f
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 155 deletions.
7 changes: 6 additions & 1 deletion src/client/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export class CollectionApi extends _CollectionApi {
a.data.title.localeCompare(b.data.title) || a.data._id - b.data._id,
);

const rootNode = makeTree(null, source);
// ? Deduplicate items; can't explain the detail because it's been a while since I wrote this.
const sourceDedupe = source.filter(
(obj1, idx, arr) => arr.findIndex((obj2) => obj2.id === obj1.id) === idx,
);

const rootNode = makeTree(null, sourceDedupe);
return rootNode;
}
}
Loading

0 comments on commit a0dde0f

Please sign in to comment.