fix: custom locale not being set until the settings tab is open

This commit is contained in:
Roberto Tonino 2020-09-23 18:15:59 +02:00
parent 53735647f9
commit 0eb0ebcbc9
3 changed files with 22 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -21,10 +21,19 @@ import EventBus from '@/utils/EventBus.js'
/* ===== App initialization ===== */
function startApp() {
setLocale()
mountApp()
initTabs()
}
function setLocale() {
let storedLocale = localStorage.getItem('locale')
if (storedLocale) {
i18n.locale = storedLocale
}
}
function mountApp() {
new Vue({
store,
@ -120,11 +129,13 @@ socket.on('logged_in', function(data) {
break
case -1:
toast(i18n.t('toasts.deezerNotAvailable'), 'close', true, 'login-toast')
$('#open_login_prompt').show()
document.getElementById('logged_in_info').classList.add('hide')
$('#settings_username').text('Not Logged')
$('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`)
document.getElementById('home_not_logged_in').classList.remove('hide')
return
// TODO
// $('#open_login_prompt').show()
// document.getElementById('logged_in_info').classList.add('hide')
// $('#settings_username').text('Not Logged')
// $('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`)
// document.getElementById('home_not_logged_in').classList.remove('hide')
}
})

View File

@ -722,7 +722,6 @@ export default {
let storedLocale = localStorage.getItem('locale')
if (storedLocale) {
this.$i18n.locale = storedLocale
this.currentLocale = storedLocale
}