Chats: make Truth Policies conditional

This commit is contained in:
Alex Gleason 2022-11-02 14:02:43 -05:00
parent 69d92b6f95
commit 4dc0ab2d00
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import { useMutation, useQuery } from '@tanstack/react-query';
import { useApi, useOwnAccount } from 'soapbox/hooks';
import { useApi, useFeatures, useOwnAccount } from 'soapbox/hooks';
import { queryClient } from './client';
@ -15,6 +15,7 @@ const PolicyKeys = {
function usePendingPolicy() {
const api = useApi();
const account = useOwnAccount();
const features = useFeatures();
const getPolicy = async() => {
const { data } = await api.get<IPolicy>('/api/v1/truth/policies/pending');
@ -27,7 +28,7 @@ function usePendingPolicy() {
refetchOnWindowFocus: true,
staleTime: 60000, // 1 minute
cacheTime: Infinity,
enabled: !!account,
enabled: !!account && features.truthPolicies,
});
}

View File

@ -641,6 +641,13 @@ const getInstanceFeatures = (instance: Instance) => {
v.software === TRUTHSOCIAL,
]),
/**
* Truth Social policies.
* @see GET /api/v1/truth/policies/pending
* @see PATCH /api/v1/truth/policies/:policyId/accept
*/
truthPolicies: v.software === TRUTHSOCIAL,
/**
* Supports Truth suggestions.
*/