Skip to content

Commit

Permalink
fix: πŸ› prevent server from breaking on locale.set
Browse files Browse the repository at this point in the history
Closes #55
  • Loading branch information
kaisermann committed Mar 29, 2020
1 parent 2a1bea5 commit 07ef1da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/runtime/stores/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 07ef1da

Please sign in to comment.