diff --git a/src/constants/features.ts b/src/constants/features.ts index d0ea9114..236fc6c3 100644 --- a/src/constants/features.ts +++ b/src/constants/features.ts @@ -22,5 +22,5 @@ const __isFeatureEnabled = (name: Feature, version: SemVer): boolean => { } export const isFeatureEnabled = (name: Feature, serviceInfo: ServiceInfo): boolean => { - return !!serviceInfo.server?.version && __isFeatureEnabled(name, serviceInfo.server.version) + return !!serviceInfo.server && __isFeatureEnabled(name, serviceInfo.server.version) } diff --git a/src/context/ServiceInfoContext.tsx b/src/context/ServiceInfoContext.tsx index 3fe4cfb8..d84c0de0 100644 --- a/src/context/ServiceInfoContext.tsx +++ b/src/context/ServiceInfoContext.tsx @@ -80,7 +80,7 @@ type SessionInfo = { } type ServerInfo = { server?: { - version?: SemVer + version: SemVer } } @@ -118,20 +118,12 @@ const ServiceInfoProvider = ({ children }: PropsWithChildren<{}>) => { Api.getGetinfo({ signal: abortCtrl.signal }) .then((res) => (res.ok ? res.json() : Api.Helper.throwError(res))) - .then((data: JmGetInfoData) => { - dispatchServiceInfo({ - server: { - version: toSemVer(data.version), - }, - }) - }) - .catch((err) => { - const notFound = err.response.status === 404 - if (notFound) { + .then((data: JmGetInfoData) => toSemVer(data.version)) + .catch((_) => UNKNOWN_VERSION) + .then((version) => { + if (!abortCtrl.signal.aborted) { dispatchServiceInfo({ - server: { - version: UNKNOWN_VERSION, - }, + server: { version }, }) } })