refactor: remove useless functions

develop
c-cal 3 years ago
parent 9061868f40
commit fe3e07c397
  1. 4
      src/App.jsx
  2. 36
      src/StorageManager.js

@ -4,7 +4,7 @@ import { RestfulProvider } from "restful-react";
import sdk from "matrix-js-sdk"; import sdk from "matrix-js-sdk";
import { MatrixClientContext } from "./contexts"; import { MatrixClientContext } from "./contexts";
import * as StorageManager from "./StorageManager"; import idbLoad from "./StorageManager";
import AdminHome from "./AdminHome"; import AdminHome from "./AdminHome";
import DelayedSpinner from "./DelayedSpinner"; import DelayedSpinner from "./DelayedSpinner";
import Login from "./Login"; import Login from "./Login";
@ -54,7 +54,7 @@ export default () => {
useEffect(() => { useEffect(() => {
Promise.resolve(getHsBaseUrl()).then(baseUrl => { Promise.resolve(getHsBaseUrl()).then(baseUrl => {
let client; let client;
StorageManager.idbLoad("account", "mx_access_token").then(accessToken => { idbLoad("account", "mx_access_token").then(accessToken => {
if (!accessToken) { if (!accessToken) {
accessToken = localStorage.getItem("mx_access_token"); accessToken = localStorage.getItem("mx_access_token");
} }

@ -41,7 +41,7 @@ async function idbInit() {
}); });
} }
export async function idbLoad(table, key) { export default async function idbLoad(table, key) {
if (!idb) { if (!idb) {
await idbInit(); await idbInit();
} }
@ -57,37 +57,3 @@ export async function idbLoad(table, key) {
}; };
}); });
} }
export async function idbSave(table: string, key: string | string[], data: any): Promise<void> {
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<void> {
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();
};
});
}

Loading…
Cancel
Save