From a1b25e1e520bc62bba2044c30cf29d433dd0d885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:52:30 -0500 Subject: [PATCH] fix: discard shot on tank change --- src/app/tools/tankopedia/[id]/page.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/tools/tankopedia/[id]/page.tsx b/src/app/tools/tankopedia/[id]/page.tsx index b4309a206..9680fd91f 100644 --- a/src/app/tools/tankopedia/[id]/page.tsx +++ b/src/app/tools/tankopedia/[id]/page.tsx @@ -57,6 +57,19 @@ export default function Page({ params }: { params: { id: string } }) { }; }, [initialId, assigned]); + useEffect(() => { + const unsubscribe = useDuel.subscribe( + (state) => state.protagonist?.tank.id, + () => { + mutateTankopediaTemporary((draft) => { + draft.shot = undefined; + }); + }, + ); + + return unsubscribe; + }, []); + return ( {assigned && (