Skip to content

Commit

Permalink
hotfix: allow for undefined oldData in websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipHarald committed Oct 9, 2024
1 parent 2a6c05d commit d9a0f7e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion services/explorer-ui/src/hooks/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const useWebSocketConnection = () => {
const d = JSON.parse(data);
const block = chicmozL2BlockSchema.parse(d);
queryClient.setQueryData(["latestBlock"], block);
queryClient.setQueryData(["latestBlocks"], (oldData: ChicmozL2Block[]) => {
queryClient.setQueryData(["latestBlocks"], (oldData: ChicmozL2Block[] | undefined) => {
if (!oldData) return [block];
if (oldData.find((b) => b.hash === block.hash)) return oldData;
return [block, ...oldData];
});
Expand Down

0 comments on commit d9a0f7e

Please sign in to comment.