diff --git a/src/store/auth/reducer.ts b/src/store/auth/reducer.ts index 9e09683..9413750 100644 --- a/src/store/auth/reducer.ts +++ b/src/store/auth/reducer.ts @@ -8,7 +8,7 @@ const initialState: AuthState = { const reducer = ( state = initialState, action: AuthDispatchTypes -): AuthState | null => { +): AuthState => { switch (action.type) { case ActionTypes.SET_AUTH_STATE: { const { loginMethod, nostrLoginAuthMethod, keyPair } = state @@ -48,7 +48,7 @@ const reducer = ( } case ActionTypes.RESTORE_STATE: - return action.payload.auth + return action.payload.auth || initialState default: return state diff --git a/src/store/metadata/reducer.ts b/src/store/metadata/reducer.ts index e81d675..edb0571 100644 --- a/src/store/metadata/reducer.ts +++ b/src/store/metadata/reducer.ts @@ -2,15 +2,7 @@ import * as ActionTypes from '../actionTypes' import { MetadataDispatchTypes } from './types' import { Event } from 'nostr-tools' -const initialState: Event = { - content: '', - created_at: 0, - id: '', - kind: 0, - pubkey: '', - sig: '', - tags: [] -} +const initialState: Event | null = null const reducer = ( state = initialState, @@ -23,7 +15,7 @@ const reducer = ( } case ActionTypes.RESTORE_STATE: - return action.payload.metadata || null + return action.payload.metadata || initialState default: return state diff --git a/src/store/relays/reducer.ts b/src/store/relays/reducer.ts index 1f7fd31..1b34a6f 100644 --- a/src/store/relays/reducer.ts +++ b/src/store/relays/reducer.ts @@ -10,7 +10,7 @@ const initialState: RelaysState = { const reducer = ( state = initialState, action: RelaysDispatchTypes -): RelaysState | null => { +): RelaysState => { switch (action.type) { case ActionTypes.SET_RELAY_MAP: return { ...state, map: action.payload, mapUpdated: Date.now() } @@ -25,7 +25,7 @@ const reducer = ( } case ActionTypes.RESTORE_STATE: - return action.payload.relays + return action.payload.relays || initialState default: return state diff --git a/src/store/userRobotImage/reducer.ts b/src/store/userRobotImage/reducer.ts index 913c2c5..db6bdbe 100644 --- a/src/store/userRobotImage/reducer.ts +++ b/src/store/userRobotImage/reducer.ts @@ -12,7 +12,7 @@ const reducer = ( return action.payload case ActionTypes.RESTORE_STATE: - return action.payload.userRobotImage + return action.payload.userRobotImage || initialState default: return state