Skip to content

Commit

Permalink
Notify on action errors
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 17, 2025
1 parent a2aad98 commit 36b6420
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 132 deletions.
31 changes: 15 additions & 16 deletions packages/loot-core/src/client/accounts/accountsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { type AppDispatch } from '../store';

const sliceName = 'account';

type AccountState = {
failedAccounts: {
[key: AccountEntity['id']]: { type: string; code: string };
};
accountsSyncing: Array<AccountEntity['id']>;
};

const initialState: AccountState = {
failedAccounts: {},
accountsSyncing: [],
Expand All @@ -32,13 +39,6 @@ type MarkAccountSuccessPayload = {
id: AccountEntity['id'];
};

type AccountState = {
failedAccounts: {
[key: AccountEntity['id']]: { type: string; code: string };
};
accountsSyncing: Array<AccountEntity['id']>;
};

const accountsSlice = createSlice({
name: sliceName,
initialState,
Expand Down Expand Up @@ -69,13 +69,12 @@ type UnlinkAccountPayload = {
};

export const unlinkAccount = createAppAsyncThunk(
'accounts/unlinkAccount',
`${sliceName}/unlinkAccount`,
async ({ id }: UnlinkAccountPayload, { dispatch }) => {
const { markAccountSuccess } = accountsSlice.actions;

await send('account-unlink', { id });
dispatch(markAccountSuccess({ id }));
await dispatch(getAccounts());
dispatch(getAccounts());
},
);

Expand All @@ -98,8 +97,8 @@ export const linkAccount = createAppAsyncThunk(
upgradingId,
offBudget,
});
await dispatch(getPayees());
await dispatch(getAccounts());
dispatch(getPayees());
dispatch(getAccounts());
},
);

Expand All @@ -120,8 +119,8 @@ export const linkAccountSimpleFin = createAppAsyncThunk(
upgradingId,
offBudget,
});
await dispatch(getPayees());
await dispatch(getAccounts());
dispatch(getPayees());
dispatch(getAccounts());
},
);

Expand Down Expand Up @@ -311,8 +310,8 @@ export const moveAccount = createAppAsyncThunk(
`${sliceName}/moveAccount`,
async ({ id, targetId }: MoveAccountPayload, { dispatch }) => {
await send('account-move', { id, targetId });
await dispatch(getAccounts());
await dispatch(getPayees());
dispatch(getAccounts());
dispatch(getPayees());
},
);

Expand Down
Loading

0 comments on commit 36b6420

Please sign in to comment.