Skip to content

Commit

Permalink
fix(BrowserTree): Make sure all actions are awaited
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 31, 2023
1 parent e05cf0a commit c21f053
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/lib/browser/BrowserTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class BrowserTree implements IResource {
}
try {
if (self.location.protocol === 'moz-extension:' && url.parse(bookmark.url).hostname === 'separator.floccus.org') {
const node = await this.queue.add(() => {
const node = await this.queue.add(async() => {
Logger.log('(local)CREATE: executing create ', bookmark)
return browser.bookmarks.create({
parentId: bookmark.parentId,
Expand All @@ -131,7 +131,7 @@ export default class BrowserTree implements IResource {
})
return node.id
}
const node = await this.queue.add(() => {
const node = await this.queue.add(async() => {
Logger.log('(local)CREATE: executing create ', bookmark)
return browser.bookmarks.create({
parentId: bookmark.parentId,
Expand All @@ -155,17 +155,17 @@ export default class BrowserTree implements IResource {
if (self.location.protocol === 'moz-extension:' && url.parse(bookmark.url).hostname === 'separator.floccus.org') {
// noop
} else {
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)UPDATE: executing update ', bookmark)
browser.bookmarks.update(bookmark.id, {
return browser.bookmarks.update(bookmark.id, {
title: bookmark.title,
url: bookmark.url
})
})
}
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)UPDATE: executing move ', bookmark)
browser.bookmarks.move(bookmark.id, {
return browser.bookmarks.move(bookmark.id, {
parentId: bookmark.parentId
})
})
Expand All @@ -182,9 +182,9 @@ export default class BrowserTree implements IResource {
const bookmarkId = bookmark.id
Logger.log('(local)REMOVE', bookmark)
try {
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)REMOVE: executing remove ', bookmark)
browser.bookmarks.remove(bookmarkId)
return browser.bookmarks.remove(bookmarkId)
})
} catch (e) {
Logger.log('Could not remove ' + bookmark.inspect() + ': ' + e.message + '\n Moving on')
Expand All @@ -199,7 +199,7 @@ export default class BrowserTree implements IResource {
return
}
try {
const node = await this.queue.add(() => {
const node = await this.queue.add(async() => {
Logger.log('(local)CREATEFOLDER: executing create ', folder)
return browser.bookmarks.create({
parentId,
Expand Down Expand Up @@ -257,9 +257,9 @@ export default class BrowserTree implements IResource {
return
}
try {
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)UPDATEFOLDER: executing update ', folder)
browser.bookmarks.update(id, {
return browser.bookmarks.update(id, {
title
})
})
Expand All @@ -271,9 +271,9 @@ export default class BrowserTree implements IResource {
throw new Error('Detected creation of folder loop. Moving ' + id + ' into its descendant ' + parentId)
}
try {
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)CREATEFOLDER: executing move ', folder)
browser.bookmarks.move(id, { parentId })
return browser.bookmarks.move(id, { parentId })
})
} catch (e) {
throw new Error('Failed to move folder ' + id + ': ' + e.message)
Expand All @@ -292,9 +292,9 @@ export default class BrowserTree implements IResource {
return
}
try {
await this.queue.add(() => {
await this.queue.add(async() => {
Logger.log('(local)REMOVEFOLDER: executing remove ', folder)
browser.bookmarks.removeTree(id)
return browser.bookmarks.removeTree(id)
})
} catch (e) {
Logger.log('Could not remove ' + folder.inspect() + ': ' + e.message + '\n Moving on.')
Expand Down

0 comments on commit c21f053

Please sign in to comment.