diff --git a/apps/web/src/pages/home/feed/Feed.tsx b/apps/web/src/pages/home/feed/Feed.tsx index da9bfedb..0bdefde2 100644 --- a/apps/web/src/pages/home/feed/Feed.tsx +++ b/apps/web/src/pages/home/feed/Feed.tsx @@ -46,15 +46,22 @@ function Feed() { }, 3000); }; - ws.onmessage = (event) => { + ws.onmessage = async (event) => { if (event.data === "pong") { return; } const message = JSON.parse(event.data); - queryClient.setQueryData(["feed"], message.scrobbles); - queryClient.setQueryData(["now-playings"], message.nowPlayings); - queryClient.setQueryData(["scrobblesChart"], message.scrobblesChart); + queryClient.setQueryData(["feed"], () => message.scrobbles); + queryClient.setQueryData(["now-playings"], () => message.nowPlayings); + queryClient.setQueryData( + ["scrobblesChart"], + () => message.scrobblesChart, + ); + + await queryClient.invalidateQueries({ queryKey: ["feed"] }); + await queryClient.invalidateQueries({ queryKey: ["now-playings"] }); + await queryClient.invalidateQueries({ queryKey: ["scrobblesChart"] }); }; return () => {