mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-16 12:23:12 +00:00
chore: remove unused code
This commit is contained in:
parent
afbf935a71
commit
c4388fb211
@ -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;
|
@ -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();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
# Services
|
||||
|
||||
What should service do?
|
||||
|
||||
- request data api and throw error;
|
||||
- dispatch state actions;
|
@ -1,7 +1,6 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface State {
|
||||
// user is the user who is currently logged in
|
||||
user?: User;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user