improve recently viewed to avoid calling conditionally

This commit is contained in:
karamvir
2023-08-17 15:03:12 -07:00
parent 0b79f125ed
commit 89dba2dbc0
+3 -3
View File
@@ -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;
};