Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes are documented here. Format based on [Keep a Changelog](http
- `force_cancel()` action in `StreamActions` for recipients (once contract support is merged)

### Fixed
- `refreshStreamData` now invalidates active queries once instead of immediately refetching the same queries a second time
- `scValToU64`/`scValToI128` and `streamsBySender`/`streamsByRecipient` now boundary-check the RPC
response shape instead of trusting it blindly; the streams list surfaces load failures inline
instead of silently logging to console
Expand Down
9 changes: 6 additions & 3 deletions lib/queryClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ describe('refreshStreamData', () => {
mockRefetchQueries.mockResolvedValue(undefined);
});

it('invalidates and refetches active queries after a stream mutation succeeds', async () => {
it('refetches active queries only once after a stream mutation succeeds', async () => {
await refreshStreamData();

expect(queryClient.invalidateQueries).toHaveBeenCalledWith({ refetchType: 'active' });
expect(queryClient.refetchQueries).toHaveBeenCalledWith({ type: 'active' });
expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1);
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
refetchType: 'active',
});
expect(queryClient.refetchQueries).not.toHaveBeenCalled();
});
});
5 changes: 1 addition & 4 deletions lib/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export const queryClient = new QueryClient({

export async function refreshStreamData(): Promise<void> {
try {
await Promise.all([
queryClient.invalidateQueries({ refetchType: 'active' }),
queryClient.refetchQueries({ type: 'active' }),
]);
await queryClient.invalidateQueries({ refetchType: 'active' });
} catch (error) {
console.warn('Failed to refresh stream data after a transaction.', error);
}
Expand Down
Loading