refactor: indexedDB handler with TS code
This commit is contained in:
@@ -5,7 +5,9 @@ export type BaseOperation = "add" | "remove" | "reset";
|
||||
|
||||
export interface Params {
|
||||
operation: string;
|
||||
data: {};
|
||||
data: {
|
||||
[key: string]: object;
|
||||
};
|
||||
payload: {
|
||||
["id"]: number;
|
||||
};
|
||||
@@ -23,7 +25,7 @@ export default async function handler({ operation, data = {}, payload }: Params)
|
||||
{
|
||||
const { id } = payload;
|
||||
|
||||
await table?.setItem(id + "", data[id]);
|
||||
await table?.setItem(id + "", data[`${id}`]);
|
||||
}
|
||||
break;
|
||||
case "removeChannelSession":
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data, payload }) {
|
||||
interface Params {
|
||||
data: any;
|
||||
payload: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data, payload }: Params) {
|
||||
const table = window.CACHE["channels"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("channels");
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {}, payload }) {
|
||||
interface Params {
|
||||
data: any;
|
||||
payload: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {}, payload }: Params) {
|
||||
const table = window.CACHE["messageDM"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("messageDM");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {} }) {
|
||||
interface Params {
|
||||
data: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {} }: Params) {
|
||||
const table = window.CACHE["messageFile"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("messageFile");
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {}, payload }) {
|
||||
interface Params {
|
||||
payload: any;
|
||||
data: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {}, payload }: Params) {
|
||||
const table = window.CACHE["footprint"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("footprint");
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {}, payload }) {
|
||||
interface Params {
|
||||
payload: any;
|
||||
data: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {}, payload }: Params) {
|
||||
const table = window.CACHE["message"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("message");
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {}, payload }) {
|
||||
interface Params {
|
||||
payload: any;
|
||||
data: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {}, payload }: Params) {
|
||||
const table = window.CACHE["messageReaction"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("messageReaction");
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, payload }) {
|
||||
interface Params {
|
||||
payload: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, payload }: Params) {
|
||||
const table = window.CACHE["server"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("server");
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import clearTable from "./clear.handler";
|
||||
|
||||
export default async function handler({ operation, data = {} }) {
|
||||
interface Params {
|
||||
data: any;
|
||||
operation: string;
|
||||
}
|
||||
export default async function handler({ operation, data = {} }: Params) {
|
||||
const table = window.CACHE["ui"];
|
||||
if (operation.startsWith("reset")) {
|
||||
clearTable("ui");
|
||||
|
||||
Reference in New Issue
Block a user