add Nostr-login package #217

Merged
enes merged 20 commits from nostr-login-9-30 into staging 2024-10-09 08:54:33 +00:00
4 changed files with 7 additions and 15 deletions
Showing only changes of commit ad2ec070be - Show all commits

View File

@ -8,7 +8,7 @@ const initialState: AuthState = {
const reducer = ( const reducer = (
state = initialState, state = initialState,
action: AuthDispatchTypes action: AuthDispatchTypes
): AuthState | null => { ): AuthState => {
switch (action.type) { switch (action.type) {
case ActionTypes.SET_AUTH_STATE: { case ActionTypes.SET_AUTH_STATE: {
const { loginMethod, nostrLoginAuthMethod, keyPair } = state const { loginMethod, nostrLoginAuthMethod, keyPair } = state
@ -48,7 +48,7 @@ const reducer = (
} }
case ActionTypes.RESTORE_STATE: case ActionTypes.RESTORE_STATE:
return action.payload.auth return action.payload.auth || initialState
default: default:
return state return state

View File

@ -2,15 +2,7 @@ import * as ActionTypes from '../actionTypes'
import { MetadataDispatchTypes } from './types' import { MetadataDispatchTypes } from './types'
import { Event } from 'nostr-tools' import { Event } from 'nostr-tools'
const initialState: Event = { const initialState: Event | null = null
content: '',
created_at: 0,
id: '',
kind: 0,
pubkey: '',
sig: '',
tags: []
}
const reducer = ( const reducer = (
state = initialState, state = initialState,
@ -23,7 +15,7 @@ const reducer = (
} }
case ActionTypes.RESTORE_STATE: case ActionTypes.RESTORE_STATE:
return action.payload.metadata || null return action.payload.metadata || initialState
default: default:
return state return state

View File

@ -10,7 +10,7 @@ const initialState: RelaysState = {
const reducer = ( const reducer = (
state = initialState, state = initialState,
action: RelaysDispatchTypes action: RelaysDispatchTypes
): RelaysState | null => { ): RelaysState => {
switch (action.type) { switch (action.type) {
case ActionTypes.SET_RELAY_MAP: case ActionTypes.SET_RELAY_MAP:
return { ...state, map: action.payload, mapUpdated: Date.now() } return { ...state, map: action.payload, mapUpdated: Date.now() }
@ -25,7 +25,7 @@ const reducer = (
} }
case ActionTypes.RESTORE_STATE: case ActionTypes.RESTORE_STATE:
return action.payload.relays return action.payload.relays || initialState
default: default:
return state return state

View File

@ -12,7 +12,7 @@ const reducer = (
return action.payload return action.payload
case ActionTypes.RESTORE_STATE: case ActionTypes.RESTORE_STATE:
return action.payload.userRobotImage return action.payload.userRobotImage || initialState
default: default:
return state return state