From 398f05d8a54cf85964024e05e01c56d2fb99714d Mon Sep 17 00:00:00 2001 From: kunish Date: Mon, 16 Oct 2023 20:33:41 +0800 Subject: [PATCH] fix(config): backend version is likely to be undefined when invoking isUpdateAvailableAPI --- src/pages/Config.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pages/Config.tsx b/src/pages/Config.tsx index 9b68213..b4efd9a 100644 --- a/src/pages/Config.tsx +++ b/src/pages/Config.tsx @@ -467,8 +467,12 @@ const Versions: Component<{ backendVersion: Accessor }> = ({ }) => { const [isUpdateAvailable, setIsUpdateAvailable] = createSignal(false) - onMount(async () => { - setIsUpdateAvailable(await isUpdateAvailableAPI(backendVersion())) + createEffect(async () => { + const version = backendVersion() + + if (!version) return + + setIsUpdateAvailable(await isUpdateAvailableAPI(version)) }) return ( @@ -494,15 +498,14 @@ const Versions: Component<{ backendVersion: Accessor }> = ({ } export default () => { + const [t] = useI18n() + const [backendVersion, setBackendVersion] = createSignal('') onMount(async () => { - const version = await fetchBackendVersionAPI() - setBackendVersion(version) + setBackendVersion(await fetchBackendVersionAPI()) }) - const [t] = useI18n() - return (