Do not make requests to api/v1/groups if fffeature not available

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
develop^2
marcin mikołajczak 2023-03-19 20:32:53 +01:00
rodzic 3a94736285
commit 7329c0bf25
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -5,11 +5,15 @@ import { useEntities, useEntity } from 'soapbox/entity-store/hooks';
import { groupSchema, Group } from 'soapbox/schemas/group';
import { groupRelationshipSchema, GroupRelationship } from 'soapbox/schemas/group-relationship';
import { useFeatures } from './useFeatures';
function useGroups() {
const features = useFeatures();
const { entities, ...result } = useEntities<Group>(
[Entities.GROUPS, ''],
'/api/v1/groups',
{ schema: groupSchema },
{ enabled: features.groups, schema: groupSchema },
);
const { relationships } = useGroupRelationships(entities.map(entity => entity.id));