This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-09-25 20:46:13 -07:00
|
|
|
import { ACCOUNT_IMPORT, ACCOUNTS_IMPORT } from '../actions/importer';
|
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
|
|
|
|
2022-10-21 01:06:03 -07:00
|
|
|
export const normalizeForLookup = str => str.toLowerCase();
|
|
|
|
|
2021-09-25 20:46:13 -07:00
|
|
|
const initialState = ImmutableMap();
|
|
|
|
|
|
|
|
export default function accountsMap(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
case ACCOUNT_IMPORT:
|
2022-10-21 01:06:03 -07:00
|
|
|
return state.set(normalizeForLookup(action.account.acct), action.account.id);
|
2021-09-25 20:46:13 -07:00
|
|
|
case ACCOUNTS_IMPORT:
|
2022-10-21 01:06:03 -07:00
|
|
|
return state.withMutations(map => action.accounts.forEach(account => map.set(normalizeForLookup(account.acct), account.id)));
|
2021-09-25 20:46:13 -07:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|