Skip to content

Commit

Permalink
removed $isReady
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Jan 19, 2025
1 parent a7c36b8 commit 8e92717
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Added disabled Settings Page
- Changed Popup UI a little
- BUG: playOnFullScreen switch was not working

## 1.1.59

Expand Down
7 changes: 2 additions & 5 deletions src/composables/useBrowserStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ export function useBrowserLocalStorage<T>(key: string, defaultValue: T) {
function useBrowserStorage<T>(key: string, defaultValue: T, storageType: "sync" | "local" = "sync") {
const data = ref<T>(defaultValue)
let isUpdatingFromStorage = true
const isObjectc = isObject(defaultValue)
// check if the data is ready to be used and not just the default value
if (isObjectc) data.value.$ready = false
const defaultIsObject = isObject(defaultValue)
// Initialize storage with the value from chrome.storage.local
const promise = new Promise((resolve) => {
chrome.storage[storageType].get(key, async (result) => {
if (result?.[key] !== undefined) {
if (isObjectc && isObject(result[key])) {
if (defaultIsObject && isObject(result[key])) {
data.value = mergeDeep(defaultValue, result[key])
} else if (checkType(defaultValue, result[key])) {
data.value = result[key]
}
}
if (isObjectc) data.value.$ready = true
await nextTick()
isUpdatingFromStorage = false
resolve(true)
Expand Down

0 comments on commit 8e92717

Please sign in to comment.