File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,4 +43,8 @@ export default class CacheTree extends CachingAdapter implements IResource<typeo
4343 isAvailable ( ) : Promise < boolean > {
4444 return Promise . resolve ( true )
4545 }
46+
47+ setHighestId ( id : number ) {
48+ this . highestId = Math . max ( this . highestId , id )
49+ }
4650}
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ export default class CachingTreeWrapper implements OrderFolderResource<typeof It
2424
2525 async createBookmark ( bookmark :Bookmark < typeof ItemLocation . LOCAL > ) : Promise < string | number > {
2626 const id = await this . innerTree . createBookmark ( bookmark )
27+ // In case the browser uses positive int IDs, we need to reset the highestId counter here
28+ // to avoid collisions with the cache tree's auto-generated IDs
29+ this . cacheTree . setHighestId ( Number ( id ) || 0 )
2730 const cacheId = await this . cacheTree . createBookmark ( bookmark . copy ( false ) )
2831 const cacheBookmark = this . cacheTree . bookmarksCache . findBookmark ( cacheId )
2932 this . cacheTree . bookmarksCache . removeFromIndex ( cacheBookmark )
@@ -46,6 +49,9 @@ export default class CachingTreeWrapper implements OrderFolderResource<typeof It
4649
4750 async createFolder ( folder :Folder < typeof ItemLocation . LOCAL > ) : Promise < string | number > {
4851 const id = await this . innerTree . createFolder ( folder )
52+ // In case the browser uses positive int IDs, we need to reset the highestId counter here
53+ // to avoid collisions with the cache tree's auto-generated IDs
54+ this . cacheTree . setHighestId ( Number ( id ) || 0 )
4955 const cacheId = await this . cacheTree . createFolder ( folder . copy ( false ) )
5056 const cacheFolder = this . cacheTree . bookmarksCache . findFolder ( cacheId )
5157 this . cacheTree . bookmarksCache . removeFromIndex ( cacheFolder )
You can’t perform that action at this time.
0 commit comments