2
0
mirror of https://github.com/frappe/books.git synced 2024-11-12 16:36:27 +00:00

fix: load langs on boot properly

- don't reload in setup wizard cause it crashes at times.
- will undo the above once fixed
This commit is contained in:
18alantom 2022-02-17 16:05:01 +05:30
parent 7afac9cfbd
commit ab93349e11
4 changed files with 11 additions and 8 deletions

View File

@ -2,8 +2,8 @@
<FormControl
:df="languageDf"
:value="value"
@change="setLanguageMap"
:input-class="'focus:outline-none rounded '+inputClass"
@change="(v) => setLanguageMap(v, dontReload)"
:input-class="'focus:outline-none rounded ' + inputClass"
/>
</template>
<script>
@ -23,6 +23,10 @@ export default {
default:
'bg-gray-100 active:bg-gray-200 focus:bg-gray-200 px-3 py-2 text-base',
},
dontReload: {
type: Boolean,
default: false,
},
},
components: { FormControl },
computed: {

View File

@ -10,11 +10,10 @@ import { IPC_CHANNELS, IPC_MESSAGES } from './messages';
import router from './router';
import { outsideClickDirective } from './ui';
import { setLanguageMap, showToast, stringifyCircular } from './utils';
(async () => {
const language = config.get('language');
if (language) {
setLanguageMap(language);
await setLanguageMap(language);
}
frappe.isServer = true;

View File

@ -10,7 +10,7 @@
</template>
<template #content>
<div class="flex flex-col justify-center items-center h-96">
<LanguageSelector class="w-40 mt-8" />
<LanguageSelector class="w-40 mt-8" :dont-reload="true" />
<p
class="text-sm mt-2 hover:underline cursor-pointer text-gray-700"
@click="openContributingTranslations"

View File

@ -479,7 +479,7 @@ async function fetchAndSetLanguageMap(code) {
return success;
}
export async function setLanguageMap(initLanguage) {
export async function setLanguageMap(initLanguage, dontReload = false) {
const oldLanguage = config.get('language');
initLanguage ??= oldLanguage;
const [code, language, usingDefault] = getLanguageCode(
@ -498,8 +498,8 @@ export async function setLanguageMap(initLanguage) {
config.set('language', language);
}
if (success && initLanguage !== oldLanguage) {
ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW);
if (!dontReload && success && initLanguage !== oldLanguage) {
await ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW);
}
return success;
}