diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index d6e9941..42395cf 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -49,14 +49,14 @@ export const Header: FC = ({ client }) => { async () => { return await client.getVersion(); }, - { refetchOnMount: 'always', refetchInterval: 60000, onSuccess: (res) => setVersion(res) } + { refetchInterval: 120000, onSuccess: (res) => setVersion(res) } ); useQuery( ['health', currentInstance?.host], async () => { return (await client.health()).status === 'available'; }, - { refetchOnMount: 'always', refetchInterval: 5000, onSuccess: (res) => setHealth(res) } + { refetchInterval: 30000, onSuccess: (res) => setHealth(res) } ); const onClickHost = useCallback(() => { diff --git a/src/components/Settings/baseInfo.tsx b/src/components/Settings/baseInfo.tsx index b53d4b2..b504bb2 100644 --- a/src/components/Settings/baseInfo.tsx +++ b/src/components/Settings/baseInfo.tsx @@ -24,8 +24,6 @@ export const BaseInfo: FC = ({ host, client }) => { }, { keepPreviousData: true, - refetchOnMount: 'always', - refetchInterval: 3000, onSuccess: () => { // change display data when not editing !isRawInfoEditing && resetRawInfo(); diff --git a/src/components/Settings/config/detail/displayedAttributes.tsx b/src/components/Settings/config/detail/displayedAttributes.tsx index e5e8471..8633a88 100644 --- a/src/components/Settings/config/detail/displayedAttributes.tsx +++ b/src/components/Settings/config/detail/displayedAttributes.tsx @@ -14,7 +14,6 @@ export const DisplayedAttributes: FC = ({ }) => { const query = useQuery({ queryKey: ['getDisplayedAttributes', host, client.uid], - refetchInterval: 4500, async queryFn(ctx) { return await client.getDisplayedAttributes(); }, diff --git a/src/components/Settings/config/detail/distinctAttribute.tsx b/src/components/Settings/config/detail/distinctAttribute.tsx index f5ded22..b89fd5c 100644 --- a/src/components/Settings/config/detail/distinctAttribute.tsx +++ b/src/components/Settings/config/detail/distinctAttribute.tsx @@ -10,7 +10,6 @@ import _ from 'lodash'; export const DistinctAttribute: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getDistinctAttribute', host, client.uid], - refetchInterval: 4500, async queryFn(ctx) { return await client.getDistinctAttribute(); }, diff --git a/src/components/Settings/config/detail/faceting.tsx b/src/components/Settings/config/detail/faceting.tsx index 0d47cdf..d3d15cc 100644 --- a/src/components/Settings/config/detail/faceting.tsx +++ b/src/components/Settings/config/detail/faceting.tsx @@ -8,7 +8,6 @@ import _ from 'lodash'; export const Faceting: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getFaceting', host, client.uid], - refetchInterval: 4500, async queryFn(ctx) { return (await client.getFaceting()) as TFaceting; }, diff --git a/src/components/Settings/config/detail/filterableAttributes.tsx b/src/components/Settings/config/detail/filterableAttributes.tsx index 84b0638..79e53af 100644 --- a/src/components/Settings/config/detail/filterableAttributes.tsx +++ b/src/components/Settings/config/detail/filterableAttributes.tsx @@ -15,7 +15,6 @@ export const FilterableAttributes: FC = ({ }) => { const query = useQuery({ queryKey: ['getFilterableAttributes', host, client.uid], - refetchInterval: 4500, async queryFn(ctx) { return await client.getFilterableAttributes(); }, diff --git a/src/components/Settings/config/detail/pagination.tsx b/src/components/Settings/config/detail/pagination.tsx index 5ffcadd..73622dd 100644 --- a/src/components/Settings/config/detail/pagination.tsx +++ b/src/components/Settings/config/detail/pagination.tsx @@ -8,7 +8,6 @@ import _ from 'lodash'; export const Pagination: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getPagination', host, client.uid], - refetchInterval: 4500, async queryFn(ctx) { return (await client.getPagination()) as TPagination; }, diff --git a/src/components/Settings/config/detail/rankingRules.tsx b/src/components/Settings/config/detail/rankingRules.tsx index f327500..2534cc1 100644 --- a/src/components/Settings/config/detail/rankingRules.tsx +++ b/src/components/Settings/config/detail/rankingRules.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; export const RankingRules: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getRankingRules', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return await client.getRankingRules(); }, diff --git a/src/components/Settings/config/detail/searchableAttributes.tsx b/src/components/Settings/config/detail/searchableAttributes.tsx index e5de108..df28715 100644 --- a/src/components/Settings/config/detail/searchableAttributes.tsx +++ b/src/components/Settings/config/detail/searchableAttributes.tsx @@ -15,7 +15,7 @@ export const SearchableAttributes: FC = ({ }) => { const query = useQuery({ queryKey: ['getSearchableAttributes', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return await client.getSearchableAttributes(); }, diff --git a/src/components/Settings/config/detail/sortableAttributes.tsx b/src/components/Settings/config/detail/sortableAttributes.tsx index 5c477d4..a63fbad 100644 --- a/src/components/Settings/config/detail/sortableAttributes.tsx +++ b/src/components/Settings/config/detail/sortableAttributes.tsx @@ -15,7 +15,7 @@ export const SortableAttributes: FC = ({ }) => { const query = useQuery({ queryKey: ['getSortableAttributes', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return await client.getSortableAttributes(); }, diff --git a/src/components/Settings/config/detail/stopWords.tsx b/src/components/Settings/config/detail/stopWords.tsx index 2785bfe..f7fa00e 100644 --- a/src/components/Settings/config/detail/stopWords.tsx +++ b/src/components/Settings/config/detail/stopWords.tsx @@ -10,7 +10,7 @@ import { IconAlertTriangleFilled, IconInfoCircleFilled } from '@tabler/icons-rea export const StopWords: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getStopWords', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return await client.getStopWords(); }, diff --git a/src/components/Settings/config/detail/synonyms.tsx b/src/components/Settings/config/detail/synonyms.tsx index 0009e2e..7e09639 100644 --- a/src/components/Settings/config/detail/synonyms.tsx +++ b/src/components/Settings/config/detail/synonyms.tsx @@ -36,7 +36,7 @@ export const Synonyms: FC = ({ client, classNa const query = useQuery({ queryKey: ['getSynonyms', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return (await client.getSynonyms()) as TSynonyms; }, diff --git a/src/components/Settings/config/detail/typoTolerance.tsx b/src/components/Settings/config/detail/typoTolerance.tsx index 6b03394..982702d 100644 --- a/src/components/Settings/config/detail/typoTolerance.tsx +++ b/src/components/Settings/config/detail/typoTolerance.tsx @@ -9,7 +9,7 @@ import _ from 'lodash'; export const TypoTolerance: FC = ({ client, className, host, toggleLoading }) => { const query = useQuery({ queryKey: ['getTypoTolerance', host, client.uid], - refetchInterval: 4500, + async queryFn(ctx) { return (await client.getTypoTolerance()) as TTypoTolerance; }, diff --git a/src/components/Settings/config/editor.tsx b/src/components/Settings/config/editor.tsx index b21f9d7..3159933 100644 --- a/src/components/Settings/config/editor.tsx +++ b/src/components/Settings/config/editor.tsx @@ -37,8 +37,6 @@ export const Editor: FC = ({ client, host, cla }, { keepPreviousData: true, - refetchInterval: 5000, - refetchOnMount: 'always', onSuccess: (data) => { // change display data when not editing !isSettingsEditing && resetSettings(data); diff --git a/src/hooks/useIndexes.ts b/src/hooks/useIndexes.ts index acd48e4..224e035 100644 --- a/src/hooks/useIndexes.ts +++ b/src/hooks/useIndexes.ts @@ -15,7 +15,7 @@ export const useIndexes = (client: MeiliSearch, params?: IndexesQuery): [Index[] async () => { return (await client.getIndexes(params)).results; }, - { refetchOnMount: 'always', refetchInterval: 10000, onSuccess: (res) => setIndexes(res) } + { onSuccess: (res) => setIndexes(res) } ); return [indexes, query]; diff --git a/src/hooks/useInstanceStats.ts b/src/hooks/useInstanceStats.ts index 7cedf21..d187cba 100644 --- a/src/hooks/useInstanceStats.ts +++ b/src/hooks/useInstanceStats.ts @@ -14,8 +14,6 @@ export const useInstanceStats = (client: MeiliSearch) => { return await client.getStats(); }, { - refetchOnMount: 'always', - refetchInterval: 10000, onSuccess: (res) => setStats(res), onError: (err) => { console.warn('get meilisearch stats error', err); diff --git a/src/pages/index/documents.tsx b/src/pages/index/documents.tsx index 5faba78..72e0c58 100644 --- a/src/pages/index/documents.tsx +++ b/src/pages/index/documents.tsx @@ -88,8 +88,6 @@ export const Documents = () => { { enabled: !!currentIndex, keepPreviousData: true, - refetchOnMount: 'always', - refetchInterval: 30000, } ); @@ -124,8 +122,6 @@ export const Documents = () => { { enabled: !!currentIndex, keepPreviousData: true, - refetchOnMount: 'always', - refetchInterval: 5000, } ); const [isAddDocumentsByEditorModalOpen, setIsAddDocumentsByEditorModalOpen] = useState(false); diff --git a/src/pages/key/index.tsx b/src/pages/key/index.tsx index 5f57dad..bcf065f 100644 --- a/src/pages/key/index.tsx +++ b/src/pages/key/index.tsx @@ -42,7 +42,6 @@ function Keys() { }, { keepPreviousData: true, - refetchOnMount: 'always', getNextPageParam: (lastPage) => { const limit = lastPage.limit ?? 20; const offset = lastPage.offset ?? 0; diff --git a/src/pages/task/index.tsx b/src/pages/task/index.tsx index 16a66e8..9f61a36 100644 --- a/src/pages/task/index.tsx +++ b/src/pages/task/index.tsx @@ -36,7 +36,6 @@ function Tasks() { }, { keepPreviousData: true, - refetchOnMount: 'always', getNextPageParam: (lastPage, pages) => ({ from: lastPage.next }), onError: (err) => { console.warn('get meilisearch tasks error', err); diff --git a/src/providers/react-query.tsx b/src/providers/react-query.tsx index 063e034..502ec5a 100644 --- a/src/providers/react-query.tsx +++ b/src/providers/react-query.tsx @@ -10,6 +10,11 @@ const queryClient = new QueryClient({ queries: { suspense: true, useErrorBoundary: true, + refetchIntervalInBackground: false, + refetchOnReconnect: 'always', + refetchOnMount: 'always', + refetchOnWindowFocus: 'always', + refetchInterval: 30000, }, }, });