fix: 🐛 prevent server from breaking on locale.set

Closes #55
This commit is contained in:
Christian Kaisermann 2020-03-29 16:54:08 -03:00
parent 2a1bea5559
commit 07ef1da6d5

View File

@ -66,7 +66,11 @@ $locale.set = (newLocale: string): void | Promise<void> => {
// 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)