-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: save ambianic edge connection settings to persistent browser st…
…orage that survives between sessions and browser reloads
- Loading branch information
Showing
2 changed files
with
29 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { openDB } from 'idb' | ||
|
||
const dbPromise = openDB('ambianic-keyval-store', 1, { | ||
upgrade (db) { | ||
db.createObjectStore('settings') | ||
console.log('db upgrade invoked') | ||
} | ||
}) | ||
|
||
export const settingsDB = { | ||
async get (key) { | ||
return (await dbPromise).get('settings', key) | ||
}, | ||
async set (key, val) { | ||
return (await dbPromise).put('settings', val, key) | ||
}, | ||
async delete (key) { | ||
return (await dbPromise).delete('settings', key) | ||
}, | ||
async clear () { | ||
return (await dbPromise).clear('settings') | ||
}, | ||
async keys () { | ||
return (await dbPromise).getAllKeys('settings') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters