2024-02-28 21:49:44 +05:00
|
|
|
import { Event } from 'nostr-tools'
|
|
|
|
import { combineReducers } from 'redux'
|
2024-07-05 13:38:04 +05:00
|
|
|
import { UserAppData } from '../types'
|
|
|
|
import * as ActionTypes from './actionTypes'
|
2024-02-28 21:49:44 +05:00
|
|
|
import authReducer from './auth/reducer'
|
|
|
|
import { AuthState } from './auth/types'
|
|
|
|
import metadataReducer from './metadata/reducer'
|
2024-05-28 12:22:31 +03:00
|
|
|
import relaysReducer from './relays/reducer'
|
2024-07-05 13:38:04 +05:00
|
|
|
import { RelaysState } from './relays/types'
|
|
|
|
import UserAppDataReducer from './userAppData/reducer'
|
|
|
|
import userRobotImageReducer from './userRobotImage/reducer'
|
2024-02-28 21:49:44 +05:00
|
|
|
|
|
|
|
export interface State {
|
|
|
|
auth: AuthState
|
|
|
|
metadata?: Event
|
2024-05-17 13:33:01 +02:00
|
|
|
userRobotImage?: string
|
2024-05-28 12:22:31 +03:00
|
|
|
relays: RelaysState
|
2024-07-05 13:38:04 +05:00
|
|
|
userAppData?: UserAppData
|
2024-02-28 21:49:44 +05:00
|
|
|
}
|
|
|
|
|
2024-05-28 12:22:31 +03:00
|
|
|
export const appReducer = combineReducers({
|
2024-02-28 21:49:44 +05:00
|
|
|
auth: authReducer,
|
2024-05-17 13:33:01 +02:00
|
|
|
metadata: metadataReducer,
|
2024-05-28 12:22:31 +03:00
|
|
|
userRobotImage: userRobotImageReducer,
|
2024-07-05 13:38:04 +05:00
|
|
|
relays: relaysReducer,
|
|
|
|
userAppData: UserAppDataReducer
|
2024-02-28 21:49:44 +05:00
|
|
|
})
|
2024-05-28 12:22:31 +03:00
|
|
|
|
|
|
|
// FIXME: define types
|
|
|
|
export default (state: any, action: any) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.USER_LOGOUT:
|
|
|
|
return appReducer(undefined, action)
|
|
|
|
|
|
|
|
default:
|
|
|
|
return appReducer(state, action)
|
|
|
|
}
|
|
|
|
}
|