meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
2 changed files with
10 additions and
7 deletions
-
src/actions/accounts.js
-
src/reducers/accounts.js
|
|
@ -67,9 +67,8 @@ export const fetchAccounts: FetchAccounts = () => (dispatch, getState) => { |
|
|
|
export type UpdateAccountWithUpdater = (accountId: string, (Account) => Account) => * |
|
|
|
|
|
|
|
export const updateAccountWithUpdater: UpdateAccountWithUpdater = (accountId, updater) => ({ |
|
|
|
type: 'UPDATE_ACCOUNT', |
|
|
|
accountId, |
|
|
|
updater, |
|
|
|
type: 'DB:UPDATE_ACCOUNT', |
|
|
|
payload: { accountId, updater }, |
|
|
|
}) |
|
|
|
|
|
|
|
export type UpdateAccount = ($Shape<Account>) => (Function, Function) => void |
|
|
@ -78,9 +77,11 @@ export const updateAccount: UpdateAccount = payload => (dispatch, getState) => { |
|
|
|
settings: { orderAccounts }, |
|
|
|
} = getState() |
|
|
|
dispatch({ |
|
|
|
type: 'UPDATE_ACCOUNT', |
|
|
|
updater: account => ({ ...account, ...payload }), |
|
|
|
accountId: payload.id, |
|
|
|
type: 'DB:UPDATE_ACCOUNT', |
|
|
|
payload: { |
|
|
|
updater: account => ({ ...account, ...payload }), |
|
|
|
accountId: payload.id, |
|
|
|
}, |
|
|
|
}) |
|
|
|
dispatch(updateOrderAccounts(orderAccounts)) |
|
|
|
// TODO should not be here IMO.. feels wrong for perf, probably better to move in reducer too
|
|
|
|
|
|
@ -30,7 +30,9 @@ const handlers: Object = { |
|
|
|
|
|
|
|
UPDATE_ACCOUNT: ( |
|
|
|
state: AccountsState, |
|
|
|
{ accountId, updater }: { accountId: string, updater: Account => Account }, |
|
|
|
{ |
|
|
|
payload: { accountId, updater }, |
|
|
|
}: { payload: { accountId: string, updater: Account => Account } }, |
|
|
|
): AccountsState => |
|
|
|
state.map(existingAccount => { |
|
|
|
if (existingAccount.id !== accountId) { |
|
|
|