mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-26 12:18:15 +03:00
71b50382e9
For now, this only works for unsent unsaved drafts e.g. the browser kill the page without giving the user the chance to discard
28 lines
570 B
JavaScript
28 lines
570 B
JavaScript
import {
|
|
clear,
|
|
createStore,
|
|
del,
|
|
delMany,
|
|
get,
|
|
getMany,
|
|
keys,
|
|
set,
|
|
} from 'idb-keyval';
|
|
|
|
const draftsStore = createStore('drafts-db', 'drafts-store');
|
|
|
|
// Add additonal `draftsStore` parameter to all methods
|
|
|
|
const drafts = {
|
|
set: (key, val) => set(key, val, draftsStore),
|
|
get: (key) => get(key, draftsStore),
|
|
getMany: (keys) => getMany(keys, draftsStore),
|
|
del: (key) => del(key, draftsStore),
|
|
delMany: (keys) => delMany(keys, draftsStore),
|
|
clear: () => clear(draftsStore),
|
|
keys: () => keys(draftsStore),
|
|
};
|
|
|
|
export default {
|
|
drafts,
|
|
};
|