mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-12 02:18:32 -05:00
only push recently viewed if exists
This commit is contained in:
@@ -201,9 +201,15 @@ export const usePushRecentlyViewed = ({ type, id }: Types.ResourceTarget) => {
|
||||
onSuccess: userInvalidate,
|
||||
}).mutate;
|
||||
|
||||
const exists = useRead(`List${type as UsableResource}s`, {}).data?.find(
|
||||
(r) => r.id === id
|
||||
)
|
||||
? true
|
||||
: false;
|
||||
|
||||
useEffect(() => {
|
||||
!!type && !!id && push({ resource: { type, id } });
|
||||
}, [type, id, push]);
|
||||
exists && push({ resource: { type, id } });
|
||||
}, [exists, push]);
|
||||
|
||||
return () => push({ resource: { type, id } });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user