mirror of https://github.com/langgenius/dify.git
fix: improve TanStack Query client setup and fix queryKey bug (#32422)
This commit is contained in:
parent
00e52796e6
commit
6a3db151a8
|
|
@ -1,4 +1,4 @@
|
||||||
import type { SearchParams } from 'nuqs'
|
import type { SearchParams } from 'nuqs/server'
|
||||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query'
|
import { dehydrate, HydrationBoundary } from '@tanstack/react-query'
|
||||||
import { createLoader } from 'nuqs/server'
|
import { createLoader } from 'nuqs/server'
|
||||||
import { getQueryClientServer } from '@/context/query-client-server'
|
import { getQueryClientServer } from '@/context/query-client-server'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { QueryClient } from '@tanstack/react-query'
|
import { QueryClient } from '@tanstack/react-query'
|
||||||
import { cache } from 'react'
|
import { cache } from 'react'
|
||||||
|
|
||||||
const STALE_TIME = 1000 * 60 * 30 // 30 minutes
|
const STALE_TIME = 1000 * 60 * 5 // 5 minutes
|
||||||
|
|
||||||
export function makeQueryClient() {
|
export function makeQueryClient() {
|
||||||
return new QueryClient({
|
return new QueryClient({
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import type { QueryClient } from '@tanstack/react-query'
|
import type { QueryClient } from '@tanstack/react-query'
|
||||||
import type { FC, PropsWithChildren } from 'react'
|
|
||||||
import { QueryClientProvider } from '@tanstack/react-query'
|
import { QueryClientProvider } from '@tanstack/react-query'
|
||||||
import { useState } from 'react'
|
|
||||||
import { TanStackDevtoolsLoader } from '@/app/components/devtools/tanstack/loader'
|
import { TanStackDevtoolsLoader } from '@/app/components/devtools/tanstack/loader'
|
||||||
import { isServer } from '@/utils/client'
|
import { isServer } from '@/utils/client'
|
||||||
import { makeQueryClient } from './query-client-server'
|
import { makeQueryClient } from './query-client-server'
|
||||||
|
|
@ -19,8 +17,8 @@ function getQueryClient() {
|
||||||
return browserQueryClient
|
return browserQueryClient
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TanstackQueryInitializer: FC<PropsWithChildren> = ({ children }) => {
|
export const TanstackQueryInitializer = ({ children }: { children: React.ReactNode }) => {
|
||||||
const [queryClient] = useState(getQueryClient)
|
const queryClient = getQueryClient()
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,7 @@ export const useMutationClearAllTaskPlugin = () => {
|
||||||
export const usePluginManifestInfo = (pluginUID: string) => {
|
export const usePluginManifestInfo = (pluginUID: string) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: !!pluginUID,
|
enabled: !!pluginUID,
|
||||||
queryKey: [[NAME_SPACE, 'manifest', pluginUID]],
|
queryKey: [NAME_SPACE, 'manifest', pluginUID],
|
||||||
queryFn: () => getMarketplace<{ data: { plugin: PluginInfoFromMarketPlace, version: { version: string } } }>(`/plugins/${pluginUID}`),
|
queryFn: () => getMarketplace<{ data: { plugin: PluginInfoFromMarketPlace, version: { version: string } } }>(`/plugins/${pluginUID}`),
|
||||||
retry: 0,
|
retry: 0,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue