From 89dba2dbc09bc7a2df998722646fdbfc79735116 Mon Sep 17 00:00:00 2001 From: karamvir Date: Thu, 17 Aug 2023 15:03:12 -0700 Subject: [PATCH] improve recently viewed to avoid calling conditionally --- frontend/src/hooks.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/hooks.ts b/frontend/src/hooks.ts index 044958127..09c9b004a 100644 --- a/frontend/src/hooks.ts +++ b/frontend/src/hooks.ts @@ -106,7 +106,7 @@ export const useServerStats = (server_id: string) => { export const useAddRecentlyViewed = ( type: Types.ResourceTarget["type"], - id: string + id: string | undefined ) => { const invalidate = useInvalidate(); const push = useWrite("PushRecentlyViewed", { @@ -114,8 +114,8 @@ export const useAddRecentlyViewed = ( }).mutate; useEffect(() => { - push({ resource: { type, id } } as any); - }, []); + id && push({ resource: { type, id } }); + }, [id]); return push; };