better resilience of account selection
This commit is contained in:
parent
b3ada67b11
commit
3c45a3de0b
|
@ -44,22 +44,16 @@ export class AccountsState {
|
||||||
@Action(SelectAccount)
|
@Action(SelectAccount)
|
||||||
SelectAccount(ctx: StateContext<AccountsStateModel>, action: SelectAccount){
|
SelectAccount(ctx: StateContext<AccountsStateModel>, action: SelectAccount){
|
||||||
const state = ctx.getState();
|
const state = ctx.getState();
|
||||||
// const multiSelection = action.multiselection;
|
|
||||||
const selectedAccount = action.account;
|
const selectedAccount = action.account;
|
||||||
|
|
||||||
|
|
||||||
// const copyAccounts = [...state.accounts];
|
|
||||||
// copyAccounts
|
|
||||||
// .filter(x => x.id !== selectedAccount.id)
|
|
||||||
// .forEach(x => x.isSelected = false);
|
|
||||||
|
|
||||||
const oldSelectedAccount = state.accounts.find(x => x.isSelected);
|
const oldSelectedAccount = state.accounts.find(x => x.isSelected);
|
||||||
|
|
||||||
if(selectedAccount.id === oldSelectedAccount.id) return;
|
if(oldSelectedAccount != null && selectedAccount.id === oldSelectedAccount.id) return;
|
||||||
|
|
||||||
const acc = state.accounts.find(x => x.id === selectedAccount.id);
|
const acc = state.accounts.find(x => x.id === selectedAccount.id);
|
||||||
acc.isSelected = true;
|
acc.isSelected = true;
|
||||||
oldSelectedAccount.isSelected = false;
|
|
||||||
|
if(oldSelectedAccount != null) oldSelectedAccount.isSelected = false;
|
||||||
|
|
||||||
ctx.patchState({
|
ctx.patchState({
|
||||||
accounts: [...state.accounts]
|
accounts: [...state.accounts]
|
||||||
|
|
Loading…
Reference in New Issue