diff --git a/CHANGELOG.md b/CHANGELOG.md index 90a900d..8f34583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/queryClient.test.ts b/lib/queryClient.test.ts index c15665f..e007fbb 100644 --- a/lib/queryClient.test.ts +++ b/lib/queryClient.test.ts @@ -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(); }); }); diff --git a/lib/queryClient.ts b/lib/queryClient.ts index 615da72..d5d3bf4 100644 --- a/lib/queryClient.ts +++ b/lib/queryClient.ts @@ -11,10 +11,7 @@ export const queryClient = new QueryClient({ export async function refreshStreamData(): Promise { 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); }