Merge pull request #184 from v0l/feed-cache

feed cache
This commit is contained in:
2023-02-02 13:55:31 +00:00
committed by GitHub
21 changed files with 372 additions and 291 deletions

View File

@ -61,8 +61,14 @@ export interface UserPreferences {
*/
imgProxyConfig: ImgProxySettings | null
}
export type DbType = "indexdDb" | "redux";
export interface LoginStore {
/**
* Which db we will use to cache data
*/
useDb: DbType,
/**
* If there is no login
*/
@ -146,6 +152,7 @@ const DefaultImgProxy = {
};
export const InitState = {
useDb: "redux",
loggedOut: undefined,
publicKey: undefined,
privateKey: undefined,
@ -186,7 +193,8 @@ const LoginSlice = createSlice({
name: "Login",
initialState: InitState,
reducers: {
init: (state) => {
init: (state, action: PayloadAction<DbType>) => {
state.useDb = action.payload;
state.privateKey = window.localStorage.getItem(PrivateKeyItem) ?? undefined;
if (state.privateKey) {
window.localStorage.removeItem(PublicKeyItem); // reset nip07 if using private key