This commit is contained in:
parent
a0aca8c9b1
commit
060cbd81cd
@ -1,19 +1,22 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { del, get, set } from "idb-keyval";
|
import { createStore, del, get, set } from "idb-keyval";
|
||||||
import { StateStorage } from "zustand/middleware";
|
import { StateStorage } from "zustand/middleware";
|
||||||
|
|
||||||
|
const storage = createStore("scoresaber-reloaded", "storage");
|
||||||
|
|
||||||
export const IDBStorage: StateStorage = {
|
export const IDBStorage: StateStorage = {
|
||||||
getItem: async (name: string): Promise<string | null> => {
|
getItem: async (name: string): Promise<string | null> => {
|
||||||
//console.log(name, "has been retrieved");
|
//console.log(name, "has been retrieved");
|
||||||
return (await get(name)) || null;
|
|
||||||
|
return (await get(name, storage)) || null;
|
||||||
},
|
},
|
||||||
setItem: async (name: string, value: string): Promise<void> => {
|
setItem: async (name: string, value: string): Promise<void> => {
|
||||||
//console.log(name, "with value", value, "has been saved");
|
//console.log(name, "with value", value, "has been saved");
|
||||||
await set(name, value);
|
await set(name, value, storage);
|
||||||
},
|
},
|
||||||
removeItem: async (name: string): Promise<void> => {
|
removeItem: async (name: string): Promise<void> => {
|
||||||
//console.log(name, "has been deleted");
|
//console.log(name, "has been deleted");
|
||||||
await del(name);
|
await del(name, storage);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user