Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

bug fixed

daniel31x1313ed7b6cdce1
diff --git a/components/CollectionListing.tsx b/components/CollectionListing.tsx
index 628f3ff1..21b676dd 100644
--- a/components/CollectionListing.tsx
+++ b/components/CollectionListing.tsx
@@ -126,7 +126,7 @@ const CollectionListing = () => {
// Remove from source index
children.splice(source.index, 1);
// Insert at destination index
- if (destination.index) {
+ if (destination.index !== undefined) {
children.splice(destination.index, 0, movedCollectionId);
}
@@ -167,15 +167,19 @@ const CollectionListing = () => {
return tree;
}
- function flattenTreeIds(tree: TreeData, nodeId: ItemId = 'root', result: Array<ItemId> = []) {
+ function flattenTreeIds(
+ tree: TreeData,
+ nodeId: ItemId = "root",
+ result: Array<ItemId> = []
+ ) {
const node = tree.items[nodeId];
- if (nodeId !== 'root') {
+ if (nodeId !== "root") {
result.push(node.id);
}
if (node.children && node.children.length > 0) {
- node.children.forEach(childId => {
+ node.children.forEach((childId) => {
flattenTreeIds(tree, childId, result);
});
}
@@ -219,7 +223,12 @@ const CollectionListing = () => {
setTree((currentTree) => moveItemOnTree(currentTree!, source, destination));
- const newTree = reorderTreeItems(tree, movedCollectionId, source, destination);
+ const newTree = reorderTreeItems(
+ tree,
+ movedCollectionId,
+ source,
+ destination
+ );
if (source.parentId !== destination.parentId) {
await updateCollection.mutateAsync(
diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsx
index c1c457b3..e6457e1d 100644
--- a/components/InputSelect/CollectionSelection.tsx
+++ b/components/InputSelect/CollectionSelection.tsx
@@ -66,21 +66,24 @@ export default function CollectionSelection({
};
useEffect(() => {
- const formatedCollections = collections.map((e) => {
- return {
- value: e.id,
- label: e.name,
- parentsLabel: ((e.parentId && getParentNames(e.parentId).join(" > ") + " > ") || "") + e.name,
- ownerId: e.ownerId,
- count: e._count,
- parentId: e.parentId,
- };
- })
+ const formattedCollections = collections
+ .map((e) => {
+ return {
+ value: e.id,
+ label: e.name,
+ parentsLabel:
+ ((e.parentId && getParentNames(e.parentId).join(" > ") + " > ") ||
+ "") + e.name,
+ ownerId: e.ownerId,
+ count: e._count,
+ parentId: e.parentId,
+ };
+ })
.sort((a, b) => {
return a.parentsLabel.localeCompare(b.parentsLabel);
});
- setOptions(formatedCollections);
+ setOptions(formattedCollections);
}, [collections]);
const customOption = ({ data, innerProps }: any) => {