From 3a03010ee20fecee508aa2d6520b8cfe7aaac68a Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 1 Feb 2019 00:09:28 +0900 Subject: [PATCH] Refactoring --- src/client/app/boot.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 4e9d3192c7..612311ef51 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -69,16 +69,18 @@ window.lang = lang; //#endregion - let locale = localStorage.getItem('locale'); + //#region Fetch locale data + const cachedLocale = localStorage.getItem('locale'); const localeKey = localStorage.getItem('localeKey'); - if (locale == null || localeKey != `${ver}.${lang}`) { + if (cachedLocale == null || localeKey != `${ver}.${lang}`) { const locale = await fetch(`/assets/locales/${lang}.json?ver=${ver}`) .then(response => response.json()); - localStorage.setItem('locale', JSON.stringify(locale)); - localStorage.setItem('localeKey', `${ver}.${lang}`); + localStorage.setItem('locale', JSON.stringify(locale)); + localStorage.setItem('localeKey', `${ver}.${lang}`); } + //#endregion // Detect the user agent const ua = navigator.userAgent.toLowerCase();