Add validation support to features
This commit is contained in:
parent
4886548889
commit
455030ef5b
2 changed files with 9 additions and 2 deletions
|
@ -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<Validation>('/api/v1/groups/validate', {
|
||||
|
@ -30,14 +32,14 @@ function useGroupValidation(name: string = '') {
|
|||
};
|
||||
|
||||
const queryInfo = useQuery<Validation>(ValidationKeys.validation(name), getValidation, {
|
||||
enabled: !!name,
|
||||
enabled: features.groupsValidation && !!name,
|
||||
});
|
||||
|
||||
return {
|
||||
...queryInfo,
|
||||
data: {
|
||||
...queryInfo.data,
|
||||
isValid: !queryInfo.data?.error,
|
||||
isValid: !queryInfo.data?.error ?? true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue