Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Jan 19, 2025
1 parent 8e92717 commit cf413c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/composables/useBrowserStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export function useBrowserLocalStorage<T>(key: string, defaultValue: T) {

function useBrowserStorage<T>(key: string, defaultValue: T, storageType: "sync" | "local" = "sync") {
const data = ref<T>(defaultValue)
// Blocking setting storage if it is updating from storage
let isUpdatingFromStorage = true
const defaultIsObject = isObject(defaultValue)
// Initialize storage with the value from chrome.storage.local
// Initialize storage with the value from chrome.storage
const promise = new Promise((resolve) => {
chrome.storage[storageType].get(key, async (result) => {
if (result?.[key] !== undefined) {
Expand All @@ -59,7 +60,7 @@ function useBrowserStorage<T>(key: string, defaultValue: T, storageType: "sync"
})
})

// Watch for changes in the storage and update chrome.storage.local
// Watch for changes in the storage and update chrome.storage
watch(
data,
(newValue) => {
Expand Down

0 comments on commit cf413c5

Please sign in to comment.