diff --git a/src/App.jsx b/src/App.jsx index 5773fb1..71ee98c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -4,7 +4,7 @@ import { RestfulProvider } from "restful-react"; import sdk from "matrix-js-sdk"; import { MatrixClientContext } from "./contexts"; -import * as StorageManager from "./StorageManager"; +import idbLoad from "./StorageManager"; import AdminHome from "./AdminHome"; import DelayedSpinner from "./DelayedSpinner"; import Login from "./Login"; @@ -54,7 +54,7 @@ export default () => { useEffect(() => { Promise.resolve(getHsBaseUrl()).then(baseUrl => { let client; - StorageManager.idbLoad("account", "mx_access_token").then(accessToken => { + idbLoad("account", "mx_access_token").then(accessToken => { if (!accessToken) { accessToken = localStorage.getItem("mx_access_token"); } diff --git a/src/StorageManager.js b/src/StorageManager.js index 2bc7fb9..1dc2c50 100644 --- a/src/StorageManager.js +++ b/src/StorageManager.js @@ -41,7 +41,7 @@ async function idbInit() { }); } -export async function idbLoad(table, key) { +export default async function idbLoad(table, key) { if (!idb) { await idbInit(); } @@ -57,37 +57,3 @@ export async function idbLoad(table, key) { }; }); } - -export async function idbSave(table: string, key: string | string[], data: any): Promise { - if (!idb) { - await idbInit(); - } - return new Promise((resolve, reject) => { - const txn = idb.transaction([table], "readwrite"); - txn.onerror = reject; - - const objectStore = txn.objectStore(table); - const request = objectStore.put(data, key); - request.onerror = reject; - request.onsuccess = () => { - resolve(); - }; - }); -} - -export async function idbDelete(table: string, key: string | string[]): Promise { - if (!idb) { - await idbInit(); - } - return new Promise((resolve, reject) => { - const txn = idb.transaction([table], "readwrite"); - txn.onerror = reject; - - const objectStore = txn.objectStore(table); - const request = objectStore.delete(key); - request.onerror = reject; - request.onsuccess = () => { - resolve(); - }; - }); -}