From 07ef1da6d5177854b4707d5f038f5a14562e6bf5 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Sun, 29 Mar 2020 16:54:08 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20prevent=20server=20from?= =?UTF-8?q?=20breaking=20on=20locale.set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #55 --- src/runtime/stores/locale.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/stores/locale.ts b/src/runtime/stores/locale.ts index 7094f3e..7bcbc2e 100644 --- a/src/runtime/stores/locale.ts +++ b/src/runtime/stores/locale.ts @@ -66,7 +66,11 @@ $locale.set = (newLocale: string): void | Promise => { // if there's no current locale, we don't wait to set isLoading to true // because it would break pages when loading the initial locale - if (getCurrentLocale() != null && loadingDelay) { + if ( + typeof window !== 'undefined' && + getCurrentLocale() != null && + loadingDelay + ) { loadingTimer = window.setTimeout(() => $isLoading.set(true), loadingDelay) } else { $isLoading.set(true)