Skip to content

Commit

Permalink
refactor: use an interval that invalidates both order detail and orde…
Browse files Browse the repository at this point in the history
…r trades list queries
  • Loading branch information
findolor committed Sep 18, 2024
1 parent 30ef862 commit 95392c2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tauri-app/src/lib/components/detail/OrderDetail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,32 @@
import OrderTradesListTable from '../tables/OrderTradesListTable.svelte';
import OrderTradesChart from '../charts/OrderTradesChart.svelte';
import OrderQuote from '../detail/TanstackOrderQuote.svelte';
import { onDestroy } from 'svelte';
import { queryClient } from '$lib/queries/queryClient';
export let id: string;
$: orderDetailQuery = createQuery({
queryKey: [QKEY_ORDER + id],
queryKey: [id, QKEY_ORDER + id],
queryFn: () => {
return orderDetail(id, $subgraphUrl || '');
},
enabled: !!$subgraphUrl,
});
const interval = setInterval(async () => {
// This invalidate function invalidates
// both order detail and order trades list queries
await queryClient.invalidateQueries({
queryKey: [id],
refetchType: 'active',
exact: false,
});
}, 10000);
onDestroy(() => {
clearInterval(interval);
});
</script>

<TanstackPageContentDetail query={orderDetailQuery} emptyMessage="Order not found">
Expand Down

0 comments on commit 95392c2

Please sign in to comment.