From b896ca7ef6e950bdd6e50fcae784a016aed3aa25 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 6 Jul 2022 09:53:46 +0200 Subject: [PATCH] web: fix locale erroring with no pre-hydrated locale setting Signed-off-by: Jens Langhammer --- web/src/api/Global.ts | 4 ++-- web/src/interfaces/locale.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/api/Global.ts b/web/src/api/Global.ts index 0a5135267..bbec287a5 100644 --- a/web/src/api/Global.ts +++ b/web/src/api/Global.ts @@ -6,9 +6,9 @@ export interface GlobalAuthentik { } export interface AuthentikWindow { - authentik: GlobalAuthentik; + authentik?: GlobalAuthentik; } -export function globalAK(): GlobalAuthentik { +export function globalAK(): GlobalAuthentik | undefined { return (window as unknown as AuthentikWindow).authentik; } diff --git a/web/src/interfaces/locale.ts b/web/src/interfaces/locale.ts index 500abd056..f9cb83ea3 100644 --- a/web/src/interfaces/locale.ts +++ b/web/src/interfaces/locale.ts @@ -125,7 +125,7 @@ export function autoDetectLanguage() { const detected = detect( () => { - return globalAK().locale; + return globalAK()?.locale; }, fromUrl("locale"), fromNavigator(),