chore: remove unused code

This commit is contained in:
Steven 2023-06-23 22:54:10 +08:00
parent afbf935a71
commit c4388fb211
4 changed files with 0 additions and 74 deletions

View File

@ -1,8 +0,0 @@
// UNKNOWN_ID is the symbol for unknown id
export const UNKNOWN_ID = -1;
// default animation duration
export const ANIMATION_DURATION = 200;
// millisecond in a day
export const DAILY_TIMESTAMP = 3600 * 24 * 1000;

View File

@ -1,59 +0,0 @@
/**
* Define storage data type
*/
interface StorageData {
placeholder: string;
}
type StorageKey = keyof StorageData;
/**
* storage helper
*/
export function get(keys: StorageKey[]): Partial<StorageData> {
const data: Partial<StorageData> = {};
for (const key of keys) {
try {
const stringifyValue = localStorage.getItem(key);
if (stringifyValue !== null) {
const val = JSON.parse(stringifyValue);
data[key] = val;
}
} catch (error: any) {
console.error("Get storage failed in ", key, error);
}
}
return data;
}
export function set(data: Partial<StorageData>) {
for (const key in data) {
try {
const stringifyValue = JSON.stringify(data[key as StorageKey]);
localStorage.setItem(key, stringifyValue);
} catch (error: any) {
console.error("Save storage failed in ", key, error);
}
}
}
export function remove(keys: StorageKey[]) {
for (const key of keys) {
try {
localStorage.removeItem(key);
} catch (error: any) {
console.error("Remove storage failed in ", key, error);
}
}
}
export function emitStorageChangedEvent() {
const iframeEl = document.createElement("iframe");
iframeEl.style.display = "none";
document.body.appendChild(iframeEl);
iframeEl.contentWindow?.localStorage.setItem("t", Date.now().toString());
iframeEl.remove();
}

View File

@ -1,6 +0,0 @@
# Services
What should service do?
- request data api and throw error;
- dispatch state actions;

View File

@ -1,7 +1,6 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
interface State {
// user is the user who is currently logged in
user?: User;
}