Skip to content

Commit aac350a

Browse files
committed
fix(NextcloudBookmarks): Partial tree loading was broken
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 35691ac commit aac350a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/lib/Tree.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export class Bookmark<L extends TItemLocation> {
7878
return 0
7979
}
8080

81+
setHashCacheValue(hashSettings: IHashSettings, value: string): void {
82+
const cacheKey = `${hashSettings.preserveOrder}-${hashSettings.hashFn}`
83+
if (!this.hashValue) this.hashValue = {}
84+
this.hashValue[cacheKey] = value
85+
}
86+
8187
async hash({preserveOrder = false, hashFn = 'sha256'}):Promise<string> {
8288
if (!this.hashValue) {
8389
this.hashValue = {}
@@ -313,6 +319,12 @@ export class Folder<L extends TItemLocation> {
313319
return 0
314320
}
315321

322+
setHashCacheValue(hashSettings: IHashSettings, value: string): void {
323+
const cacheKey = `${hashSettings.preserveOrder}-${hashSettings.hashFn}`
324+
if (!this.hashValue) this.hashValue = {}
325+
this.hashValue[cacheKey] = value
326+
}
327+
316328
async hash({preserveOrder = false, hashFn = 'sha256'}: IHashSettings = {preserveOrder: false, hashFn: 'sha256'}): Promise<string> {
317329
const cacheKey = `${preserveOrder}-${hashFn}`
318330
if (this.hashValue && typeof this.hashValue[cacheKey] !== 'undefined') {

src/lib/adapters/NextcloudBookmarks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
310310

311311
this.list = null
312312
tree.loaded = false
313-
tree.hashValue = { true: await this._getFolderHash(tree.id) }
313+
const treeHash = await this._getFolderHash(tree.id)
314+
tree.setHashCacheValue(this.hashSettings, treeHash)
314315
this.tree = tree.copy(true) // we clone (withHash), so we can mess with our own version
315316
return tree
316317
}
@@ -386,7 +387,7 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
386387
}
387388
if (!child.loaded) {
388389
const folderHash = await this._getFolderHash(child.id)
389-
child.hashValue = { true: folderHash }
390+
child.setHashCacheValue(this.hashSettings, folderHash)
390391
}
391392
await recurse(child.children)
392393
}, 5)

0 commit comments

Comments
 (0)