@@ -407,14 +407,19 @@ const accountSlice = createSlice({
407407 const s = getGroupScopedState < AccountState , AccountSliceState > ( state , groupId ) ;
408408 removeEntity ( s . wipAccounts , accountId ) ;
409409 } ,
410+ setAccountStatus : ( state , action : PayloadAction < { groupId : number ; status : StateStatus } > ) => {
411+ const { groupId, status } = action . payload ;
412+ initializeGroupState ( state , groupId ) ;
413+ const s = getGroupScopedState < AccountState , AccountSliceState > ( state , groupId ) ;
414+ if ( s ) {
415+ s . status = status ;
416+ }
417+ } ,
410418 } ,
411419 extraReducers : ( builder ) => {
412420 builder . addCase ( fetchAccounts . pending , ( state , action ) => {
413421 const groupId = action . meta . arg . groupId ;
414- if ( ! state . byGroupId [ groupId ] ) {
415- // TODO: add separate base action to do this
416- initializeGroupState ( state , groupId ) ;
417- }
422+ initializeGroupState ( state , groupId ) ;
418423 } ) ;
419424 builder . addCase ( fetchAccounts . rejected , ( state , action ) => {
420425 const s = getGroupScopedState < AccountState , AccountSliceState > ( state , action . meta . arg . groupId ) ;
@@ -423,10 +428,6 @@ const accountSlice = createSlice({
423428 builder . addCase ( fetchAccounts . fulfilled , ( state , action ) => {
424429 const accounts = action . payload ;
425430 const groupId = action . meta . arg . groupId ;
426- if ( ! state . byGroupId [ groupId ] ) {
427- // TODO: add separate base action to do this
428- initializeGroupState ( state , groupId ) ;
429- }
430431 const s = getGroupScopedState < AccountState , AccountSliceState > ( state , groupId ) ;
431432 // TODO: optimize such that we maybe only update those who have actually changed??
432433 const byId = accounts . reduce < { [ k : number ] : Account } > ( ( byId , account ) => {
@@ -475,7 +476,13 @@ const accountSlice = createSlice({
475476// local reducers
476477const { advanceNextLocalAccountId } = accountSlice . actions ;
477478
478- export const { wipAccountUpdated, accountAdded, accountEditStarted, copyAccount, discardAccountChange } =
479- accountSlice . actions ;
479+ export const {
480+ wipAccountUpdated,
481+ accountAdded,
482+ accountEditStarted,
483+ copyAccount,
484+ discardAccountChange,
485+ setAccountStatus,
486+ } = accountSlice . actions ;
480487
481488export const { reducer : accountReducer } = accountSlice ;
0 commit comments