From 455030ef5bc0eda510c4865d36ad3e3683ad3981 Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Wed, 29 Mar 2023 15:44:00 -0400 Subject: [PATCH] Add validation support to features --- app/soapbox/hooks/api/groups/useGroupValidation.ts | 6 ++++-- app/soapbox/utils/features.ts | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/soapbox/hooks/api/groups/useGroupValidation.ts b/app/soapbox/hooks/api/groups/useGroupValidation.ts index e20499fd2..bfcd3bbb0 100644 --- a/app/soapbox/hooks/api/groups/useGroupValidation.ts +++ b/app/soapbox/hooks/api/groups/useGroupValidation.ts @@ -1,6 +1,7 @@ import { useQuery } from '@tanstack/react-query'; import { useApi } from 'soapbox/hooks/useApi'; +import { useFeatures } from 'soapbox/hooks/useFeatures'; type Validation = { error: string @@ -13,6 +14,7 @@ const ValidationKeys = { function useGroupValidation(name: string = '') { const api = useApi(); + const features = useFeatures(); const getValidation = async() => { const { data } = await api.get('/api/v1/groups/validate', { @@ -30,14 +32,14 @@ function useGroupValidation(name: string = '') { }; const queryInfo = useQuery(ValidationKeys.validation(name), getValidation, { - enabled: !!name, + enabled: features.groupsValidation && !!name, }); return { ...queryInfo, data: { ...queryInfo.data, - isValid: !queryInfo.data?.error, + isValid: !queryInfo.data?.error ?? true, }, }; } diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 5230546b5..8558e3b9d 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -554,6 +554,11 @@ const getInstanceFeatures = (instance: Instance) => { */ groupsSearch: v.software === TRUTHSOCIAL, + /** + * Can validate group names. + */ + groupsValidation: v.software === TRUTHSOCIAL, + /** * Can hide follows/followers lists and counts. * @see PATCH /api/v1/accounts/update_credentials