Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: correct useEducationStatus query cache configuration (#30416)

yyhf28a08a69642
diff --git a/web/context/provider-context.tsx b/web/context/provider-context.tsx
index 7eca72e3221..d350d08b4ac 100644
--- a/web/context/provider-context.tsx
+++ b/web/context/provider-context.tsx
@@ -134,7 +134,7 @@ export const ProviderContextProvider = ({
const [enableEducationPlan, setEnableEducationPlan] = useState(false)
const [isEducationWorkspace, setIsEducationWorkspace] = useState(false)
- const { data: educationAccountInfo, isLoading: isLoadingEducationAccountInfo, isFetching: isFetchingEducationAccountInfo } = useEducationStatus(!enableEducationPlan)
+ const { data: educationAccountInfo, isLoading: isLoadingEducationAccountInfo, isFetching: isFetchingEducationAccountInfo, isFetchedAfterMount: isEducationDataFetchedAfterMount } = useEducationStatus(!enableEducationPlan)
const [isAllowTransferWorkspace, setIsAllowTransferWorkspace] = useState(false)
const [isAllowPublishAsCustomKnowledgePipelineTemplate, setIsAllowPublishAsCustomKnowledgePipelineTemplate] = useState(false)
@@ -240,9 +240,9 @@ export const ProviderContextProvider = ({
datasetOperatorEnabled,
enableEducationPlan,
isEducationWorkspace,
- isEducationAccount: educationAccountInfo?.is_student || false,
- allowRefreshEducationVerify: educationAccountInfo?.allow_refresh || false,
- educationAccountExpireAt: educationAccountInfo?.expire_at || null,
+ isEducationAccount: isEducationDataFetchedAfterMount ? (educationAccountInfo?.is_student ?? false) : false,
+ allowRefreshEducationVerify: isEducationDataFetchedAfterMount ? (educationAccountInfo?.allow_refresh ?? false) : false,
+ educationAccountExpireAt: isEducationDataFetchedAfterMount ? (educationAccountInfo?.expire_at ?? null) : null,
isLoadingEducationAccountInfo,
isFetchingEducationAccountInfo,
webappCopyrightEnabled,
diff --git a/web/service/use-education.ts b/web/service/use-education.ts
index 34b08e59c6d..a75ec6f3c7e 100644
--- a/web/service/use-education.ts
+++ b/web/service/use-education.ts
@@ -59,7 +59,7 @@ export const useEducationStatus = (disable?: boolean) => {
return get<{ is_student: boolean, allow_refresh: boolean, expire_at: number | null }>('/account/education')
},
retry: false,
- gcTime: 0, // No cache. Prevent switch account caused stale data
+ staleTime: 0, // Data expires immediately, ensuring fresh data on refetch
})
}