Skip to content

Commit

Permalink
Fix updated settings/config init routine on settings UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Mar 2, 2022
1 parent b4c7163 commit 3b0c8b3
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ router.afterEach((to) => {
});
});

function initConfig(app) {
// Load server side config and language before mounting the app.
api.getServerConfig().then((data) => {
api.getLang(data.lang).then((lang) => {
i18n.locale = data.lang;
i18n.setLocaleMessage(i18n.locale, lang);

Vue.prototype.$utils = new Utils(i18n);
Vue.prototype.$api = api;

// Set the page title after i18n has loaded.
const to = router.history.current;
const t = to.meta.title ? `${i18n.tc(to.meta.title, 0)} /` : '';
document.title = `${t} listmonk`;

if (app) {
app.$mount('#app');
}
});
});

api.getSettings();
}

const v = new Vue({
router,
Expand All @@ -43,28 +66,15 @@ const v = new Vue({
isLoaded: false,
},

methods: {
loadConfig() {
initConfig();
},
},

mounted() {
v.isLoaded = true;
},
});


// Load server side config and language before mounting the app.
api.getServerConfig().then((data) => {
api.getLang(data.lang).then((lang) => {
i18n.locale = data.lang;
i18n.setLocaleMessage(i18n.locale, lang);

Vue.prototype.$utils = new Utils(i18n);
Vue.prototype.$api = api;

// Set the page title after i18n has loaded.
const to = router.history.current;
const t = to.meta.title ? `${i18n.tc(to.meta.title, 0)} /` : '';
document.title = `${t} listmonk`;

v.$mount('#app');
});
});

api.getSettings();
initConfig(v);

0 comments on commit 3b0c8b3

Please sign in to comment.