kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Merge branch 'patron-enabled' into 'main'
usePatronUser: disable unless patron is enabled See merge request soapbox-pub/soapbox!3037environments/review-main-yi2y9f/deployments/4642
commit
0767392f76
|
@ -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 };
|
||||
|
|
Ładowanie…
Reference in New Issue