diff --git a/app/soapbox/api/hooks/groups/useGroupLookup.ts b/app/soapbox/api/hooks/groups/useGroupLookup.ts index 6e41975e5..a9cb2b369 100644 --- a/app/soapbox/api/hooks/groups/useGroupLookup.ts +++ b/app/soapbox/api/hooks/groups/useGroupLookup.ts @@ -12,7 +12,7 @@ function useGroupLookup(slug: string) { Entities.GROUPS, (group) => group.slug === slug, () => api.get(`/api/v1/groups/lookup?name=${slug}`), - { schema: groupSchema }, + { schema: groupSchema, enabled: !!slug }, ); const { entity: relationship } = useGroupRelationship(group?.id); diff --git a/app/soapbox/entity-store/hooks/useEntityLookup.ts b/app/soapbox/entity-store/hooks/useEntityLookup.ts index a49a659a4..73b2ef938 100644 --- a/app/soapbox/entity-store/hooks/useEntityLookup.ts +++ b/app/soapbox/entity-store/hooks/useEntityLookup.ts @@ -25,6 +25,7 @@ function useEntityLookup( const [isFetching, setPromise] = useLoading(true); const entity = useAppSelector(state => findEntity(state, entityType, lookupFn)); + const isEnabled = opts.enabled ?? true; const isLoading = isFetching && !entity; const fetchEntity = async () => { @@ -38,10 +39,12 @@ function useEntityLookup( }; useEffect(() => { + if (!isEnabled) return; + if (!entity || opts.refetch) { fetchEntity(); } - }, []); + }, [isEnabled]); return { entity,