Skip to content

Commit 545bddb

Browse files
committed
fix(NextcloudBookmarks): Fix incremental index updates
Signed-off-by: Marcel Klehr <[email protected]>
1 parent b11a7b6 commit 545bddb

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/lib/adapters/NextcloudBookmarks.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -749,20 +749,23 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
749749
throw e
750750
}
751751

752-
if (oldParentId) {
753-
const oldParentFolder = this.tree.findFolder(oldParentId)
754-
const oldBm = oldParentFolder.findBookmark(newBm.id)
755-
oldParentFolder.children = oldParentFolder.children.filter(
756-
(item) => !(item.type === 'bookmark' && item.id === newBm.id)
757-
)
758-
if (oldBm && this.tree) {
759-
this.tree.removeFromIndex(oldBm)
760-
}
752+
const oldParentFolder = this.tree.findFolder(oldParentId)
753+
if (!oldParentFolder) {
754+
throw new UnknownFolderParentUpdateError()
755+
}
756+
const oldBm = oldParentFolder.findBookmark(newBm.id)
757+
oldParentFolder.children = oldParentFolder.children.filter(
758+
(item) => !(item.type === 'bookmark' && item.id === newBm.id)
759+
)
760+
if (oldBm && this.tree) {
761+
this.tree.removeFromIndex(oldBm)
761762
}
763+
oldBm.title = newBm.title
764+
oldBm.parentId = newBm.parentId
762765
if (!newFolder.children.find(item => String(item.id) === String(newBm.id) && item.type === 'bookmark')) {
763-
newFolder.children.push(newBm)
766+
newFolder.children.push(oldBm)
764767
}
765-
newBm.id = upstreamId + ';' + newBm.parentId
768+
oldBm.id = upstreamId + ';' + newBm.parentId
766769
this.tree.updateIndex(newBm)
767770

768771
return newBm.id

0 commit comments

Comments
 (0)