usePatronUser: disable unless patron is enabled
This commit is contained in:
parent
13c7fbd6e8
commit
984185051a
|
@ -1,15 +1,19 @@
|
|||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntity } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks/useApi';
|
||||
import { useSoapboxConfig } from 'soapbox/hooks/useSoapboxConfig';
|
||||
import { type PatronUser, patronUserSchema } from 'soapbox/schemas';
|
||||
|
||||
function usePatronUser(url?: string) {
|
||||
const api = useApi();
|
||||
const soapboxConfig = useSoapboxConfig();
|
||||
|
||||
const patronEnabled = soapboxConfig.getIn(['extensions', 'patron', 'enabled']) === true;
|
||||
|
||||
const { entity: patronUser, ...result } = useEntity<PatronUser>(
|
||||
[Entities.PATRON_USERS, url || ''],
|
||||
() => api.get(`/api/patron/v1/accounts/${encodeURIComponent(url!)}`),
|
||||
{ schema: patronUserSchema, enabled: !!url },
|
||||
{ schema: patronUserSchema, enabled: patronEnabled && !!url },
|
||||
);
|
||||
|
||||
return { patronUser, ...result };
|
||||
|
|
Loading…
Reference in New Issue