Skip to content

Commit

Permalink
Condensed settings.load() ↞ [auto-sync from https://github.com/adam…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Jan 12, 2025
1 parent 3be7539 commit 7623f9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions chromium/extension/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ window.settings = {
this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle')
})
else // asynchronously load from browser extension storage
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => {
window.config[key] = result[key]
?? this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle'
resolve()
}))))
return Promise.all(keys.map(async key => // resolve promise when all keys load
window.config[key] = (await chrome.storage.sync.get(key))[key]
?? this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle'
))
},

save(key, val) {
Expand Down
11 changes: 4 additions & 7 deletions firefox/extension/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ window.settings = {
this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle')
})
else // asynchronously load from browser extension storage
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => {
window.config[key] = result[key]
?? this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle'
resolve()
}))))
return Promise.all(keys.map(async key => // resolve promise when all keys load
window.config[key] = (await chrome.storage.sync.get(key))[key]
?? this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle'
))
},

save(key, val) {
Expand Down

0 comments on commit 7623f9e

Please sign in to comment.