pl-fe: migrate /api/v*/instance to tanstack query

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2024-12-03 15:03:17 +01:00
parent 2086e027ad
commit 1f8b79f309
79 changed files with 240 additions and 337 deletions

View File

@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react';
import { IntlProvider } from 'react-intl';
import { fetchInstance } from 'pl-fe/actions/instance';
import { fetchMe } from 'pl-fe/actions/me';
import { loadPlFeConfig } from 'pl-fe/actions/pl-fe';
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
import LoadingScreen from 'pl-fe/components/loading-screen';
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
@ -17,8 +17,6 @@ const loadInitial = () => {
return async(dispatch, getState) => {
// Await for authenticated fetch
await dispatch(fetchMe());
// Await for feature detection
await dispatch(fetchInstance());
// Await for configuration
await dispatch(loadPlFeConfig());
};
@ -31,6 +29,7 @@ interface IPlFeLoad {
/** Initial data loader. */
const PlFeLoad: React.FC<IPlFeLoad> = ({ children }) => {
const dispatch = useAppDispatch();
const { isLoading: isLoadingInstance } = useInstance();
const me = useAppSelector(state => state.me);
const { account } = useOwnAccount();
@ -46,6 +45,7 @@ const PlFeLoad: React.FC<IPlFeLoad> = ({ children }) => {
me && !account,
!isLoaded,
localeLoading,
isLoadingInstance,
].some(Boolean);
// Load the user's locale