From 1f465fe9103d1190a63fca85f31a3c3ac92c2d48 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Tue, 16 May 2023 19:32:15 +0000 Subject: [PATCH] added `StoragedState` utill --- packages/app/src/utils/storagedState/index.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 packages/app/src/utils/storagedState/index.js diff --git a/packages/app/src/utils/storagedState/index.js b/packages/app/src/utils/storagedState/index.js new file mode 100644 index 00000000..17609c5f --- /dev/null +++ b/packages/app/src/utils/storagedState/index.js @@ -0,0 +1,24 @@ +import Dexie from "dexie" + +export default class StoragedState { + constructor() { + this.db = new Dexie("storaged_states") + + this.db.version(1).stores({ + states: "id,value", + }) + } + + getState = async (stateKey) => { + const data = await this.db.table("states").get(stateKey) + + return data.value + } + + setState = async (stateKey, value) => { + return await this.db.table("states").put({ + id: stateKey, + value, + }) + } +} \ No newline at end of file