import { Reducer } from 'redux' ; import { AccountsSection , AccountsStore , AliasStore } from '../../state/accounts' ; import { IAccountsReset } from '../actions/actionTypes' ; const ResetNonPermanentAccounts = ( accounts ) : AccountsStore => { const ret = { } ; for ( const key of Object . keys ( accounts ) ) { if ( accounts [ key ] . permanent ) { ret [ key ] = accounts [ key ] ; } } return ret ; } ; const ResetNonPermanentAliases = ( accounts , aliases ) : AliasStore => { const ret = { } ; for ( const key of Object . keys ( aliases ) ) { if ( accounts [ aliases [ key ] ] . permanent ) { ret [ key ] = aliases [ key ] ; } } return ret ; } ; export const AccountsResetReducer = ( state , action ) : AccountsSection => ( { accounts : ResetNonPermanentAccounts ( state . accounts ) , alias : ResetNonPermanentAliases ( state . accounts , state . alias ) } ) ;