Await chrome storage calls

This commit is contained in:
2025-09-24 22:44:57 +02:00
parent 14b114c46f
commit ae0e87c41d
2 changed files with 11 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ import { createBookmarks, removeBookmarks } from "./bookmark.js";
import { saveRevision, getRevision } from "./revision.js";
const syncBookmarks = async (id, bookmark) => {
console.log('Syncing bookmarks!');
console.log('Syncing bookmarks! id: ' + id + ' bookmark: ' + JSON.stringify(bookmark));
await saveRevision();
}
@@ -17,9 +17,12 @@ const loadBookmarks = async () => {
return;
}
console.log('Different revision IDs found! Old: ' + data.revId + ' New:' + savedRev.revId);
removeListeners();
chrome.storage.sync.set({ revId: data.revId });
await chrome.storage.sync.set({ revId: data.revId });
// TODO GD: "Raw" replacement, make this more efficient to avoid flickering
for (var child of data.bookmarks[0].children) {
@@ -35,8 +38,8 @@ function removeListeners() {
chrome.bookmarks.onRemoved.removeListener(syncBookmarks);
chrome.bookmarks.onChanged.removeListener(syncBookmarks);
chrome.bookmarks.onMoved.removeListener(syncBookmarks);
chrome.bookmarks.onChildrenReordered.removeListener(syncBookmarks);
chrome.bookmarks.onImportEnded.removeListener(syncBookmarks);
chrome.bookmarks.onChildrenReordered.removeLisstener(syncBookmarks);
//chrome.bookmarks.onImportEnded.removeListener(syncBookmarks);
}
function addListeners() {
@@ -45,9 +48,11 @@ function addListeners() {
chrome.bookmarks.onChanged.addListener(syncBookmarks);
chrome.bookmarks.onMoved.addListener(syncBookmarks);
chrome.bookmarks.onChildrenReordered.addListener(syncBookmarks);
chrome.bookmarks.onImportEnded.addListener(syncBookmarks);
//chrome.bookmarks.onImportEnded.addListener(syncBookmarks);
}
addListeners();
loadBookmarks();
// TODO GD: Make this websocket based