pl-fe: migrate /api/v*/instance to tanstack query
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import IconButton from 'pl-fe/components/icon-button';
|
||||
import { DatePicker } from 'pl-fe/features/ui/util/async-components';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
|
||||
const messages = defineMessages({
|
||||
birthdayPlaceholder: { id: 'edit_profile.fields.birthday_placeholder', defaultMessage: 'Your birthday' },
|
||||
@ -23,7 +23,7 @@ interface IBirthdayInput {
|
||||
const BirthdayInput: React.FC<IBirthdayInput> = ({ value, onChange, required }) => {
|
||||
const intl = useIntl();
|
||||
const features = useFeatures();
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
|
||||
const supportsBirthdays = features.birthdays;
|
||||
const minAge = instance.pleroma.metadata.birthday_min_age;
|
||||
|
||||
@ -2,12 +2,12 @@ import clsx from 'clsx';
|
||||
import React, { useState } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import Banner from 'pl-fe/components/ui/banner';
|
||||
import Button from 'pl-fe/components/ui/button';
|
||||
import HStack from 'pl-fe/components/ui/hstack';
|
||||
import Stack from 'pl-fe/components/ui/stack';
|
||||
import Text from 'pl-fe/components/ui/text';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { usePlFeConfig } from 'pl-fe/hooks/use-pl-fe-config';
|
||||
|
||||
const acceptedGdpr = !!localStorage.getItem('plfe:gdpr');
|
||||
@ -18,7 +18,7 @@ const GdprBanner: React.FC = () => {
|
||||
const [shown, setShown] = useState<boolean>(acceptedGdpr);
|
||||
const [slideout, setSlideout] = useState(false);
|
||||
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const { gdprUrl } = usePlFeConfig();
|
||||
|
||||
const handleAccept = () => {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Helmet as ReactHelmet } from 'react-helmet-async';
|
||||
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import { useStatContext } from 'pl-fe/contexts/stat-context';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||
import { RootState } from 'pl-fe/store';
|
||||
import FaviconService from 'pl-fe/utils/favicon-service';
|
||||
@ -22,7 +22,7 @@ interface IHelmet {
|
||||
}
|
||||
|
||||
const Helmet: React.FC<IHelmet> = ({ children }) => {
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const { unreadChatsCount } = useStatContext();
|
||||
const unreadCount = useAppSelector((state) => getNotifTotals(state) + unreadChatsCount);
|
||||
const { demetricator } = useSettings();
|
||||
|
||||
@ -6,6 +6,7 @@ import { Link, NavLink } from 'react-router-dom';
|
||||
|
||||
import { fetchOwnAccounts, logOut, switchAccount } from 'pl-fe/actions/auth';
|
||||
import { useAccount } from 'pl-fe/api/hooks/accounts/use-account';
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import { useInteractionRequestsCount } from 'pl-fe/api/hooks/statuses/use-interaction-requests';
|
||||
import Account from 'pl-fe/components/account';
|
||||
import Divider from 'pl-fe/components/ui/divider';
|
||||
@ -17,7 +18,6 @@ import ProfileStats from 'pl-fe/features/ui/components/profile-stats';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useRegistrationStatus } from 'pl-fe/hooks/use-registration-status';
|
||||
import { makeGetOtherAccounts } from 'pl-fe/selectors';
|
||||
import { useSettingsStore } from 'pl-fe/stores/settings';
|
||||
@ -106,7 +106,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
|
||||
const touchEnd = useRef<number | null>(null);
|
||||
const { isOpen } = useRegistrationStatus();
|
||||
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const restrictUnauth = instance.pleroma.metadata.restrict_unauthenticated;
|
||||
|
||||
const containerRef = React.useRef<HTMLDivElement>(null);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import { useInteractionRequestsCount } from 'pl-fe/api/hooks/statuses/use-interaction-requests';
|
||||
import Icon from 'pl-fe/components/ui/icon';
|
||||
import Stack from 'pl-fe/components/ui/stack';
|
||||
@ -9,7 +10,6 @@ import ComposeButton from 'pl-fe/features/ui/components/compose-button';
|
||||
import ProfileDropdown from 'pl-fe/features/ui/components/profile-dropdown';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useLogo } from 'pl-fe/hooks/use-logo';
|
||||
import { useOwnAccount } from 'pl-fe/hooks/use-own-account';
|
||||
import { useRegistrationStatus } from 'pl-fe/hooks/use-registration-status';
|
||||
@ -40,7 +40,7 @@ const SidebarNavigation = () => {
|
||||
const intl = useIntl();
|
||||
const { unreadChatsCount } = useStatContext();
|
||||
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const features = useFeatures();
|
||||
const { isDeveloper } = useSettings();
|
||||
const { account } = useOwnAccount();
|
||||
|
||||
@ -17,6 +17,7 @@ import { useBlockGroupMember } from 'pl-fe/api/hooks/groups/use-block-group-memb
|
||||
import { useDeleteGroupStatus } from 'pl-fe/api/hooks/groups/use-delete-group-status';
|
||||
import { useGroup } from 'pl-fe/api/hooks/groups/use-group';
|
||||
import { useGroupRelationship } from 'pl-fe/api/hooks/groups/use-group-relationship';
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import { useTranslationLanguages } from 'pl-fe/api/hooks/instance/use-translation-languages';
|
||||
import DropdownMenu from 'pl-fe/components/dropdown-menu';
|
||||
import StatusActionButton from 'pl-fe/components/status-action-button';
|
||||
@ -27,7 +28,6 @@ import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useCanInteract } from 'pl-fe/hooks/use-can-interact';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useOwnAccount } from 'pl-fe/hooks/use-own-account';
|
||||
import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||
import { useChats } from 'pl-fe/queries/chats';
|
||||
@ -595,7 +595,7 @@ const MenuButton: React.FC<IMenuButton> = ({
|
||||
|
||||
const { groupRelationship } = useGroupRelationship(status.group_id || undefined);
|
||||
const features = useFeatures();
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const { autoTranslate, deleteModal, knownLanguages } = useSettings();
|
||||
|
||||
const { translationLanguages } = useTranslationLanguages();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
|
||||
import { useTranslationLanguages } from 'pl-fe/api/hooks/instance/use-translation-languages';
|
||||
import { useStatusTranslation } from 'pl-fe/api/hooks/statuses/use-status-translation';
|
||||
import HStack from 'pl-fe/components/ui/hstack';
|
||||
@ -9,7 +10,6 @@ import Stack from 'pl-fe/components/ui/stack';
|
||||
import Text from 'pl-fe/components/ui/text';
|
||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||
import { useStatusMetaStore } from 'pl-fe/stores/status-meta';
|
||||
|
||||
@ -22,7 +22,7 @@ interface ITranslateButton {
|
||||
const TranslateButton: React.FC<ITranslateButton> = ({ status }) => {
|
||||
const intl = useIntl();
|
||||
const features = useFeatures();
|
||||
const instance = useInstance();
|
||||
const { data: instance } = useInstance();
|
||||
const settings = useSettings();
|
||||
const autoTranslate = settings.autoTranslate;
|
||||
const knownLanguages = autoTranslate ? [...settings.knownLanguages, intl.locale] : [intl.locale];
|
||||
|
||||
Reference in New Issue
Block a user