From 2b94545190fa8db22309789f8ae6839440532d74 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 5 Jul 2023 11:11:38 +0800 Subject: [PATCH] fix check version api (#520) --- web/context/app-context.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/web/context/app-context.tsx b/web/context/app-context.tsx index 5b39d69a1..13f591d37 100644 --- a/web/context/app-context.tsx +++ b/web/context/app-context.tsx @@ -20,6 +20,16 @@ export type AppContextValue = { useSelector: typeof useSelector } +const initialLangeniusVersionInfo = { + current_env: '', + current_version: '', + latest_version: '', + release_date: '', + release_notes: '', + version: '', + can_auto_update: false, +} + const AppContext = createContext({ apps: [], mutateApps: () => { }, @@ -30,15 +40,7 @@ const AppContext = createContext({ }, mutateUserProfile: () => { }, pageContainerRef: createRef(), - langeniusVersionInfo: { - current_env: '', - current_version: '', - latest_version: '', - release_date: '', - release_notes: '', - version: '', - can_auto_update: false, - }, + langeniusVersionInfo: initialLangeniusVersionInfo, useSelector, }) @@ -57,7 +59,7 @@ export const AppContextProvider: FC = ({ children }) => const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile) const [userProfile, setUserProfile] = useState() - const [langeniusVersionInfo, setLangeniusVersionInfo] = useState() + const [langeniusVersionInfo, setLangeniusVersionInfo] = useState(initialLangeniusVersionInfo) const updateUserProfileAndVersion = async () => { if (userProfileResponse && !userProfileResponse.bodyUsed) { const result = await userProfileResponse.json() @@ -72,7 +74,7 @@ export const AppContextProvider: FC = ({ children }) => updateUserProfileAndVersion() }, [userProfileResponse]) - if (!appList || !userProfile || !langeniusVersionInfo) + if (!appList || !userProfile) return return (