fix(displaypreferences): use if instead of try-catch

This commit is contained in:
Thibault Nocchi 2020-12-17 17:05:14 +01:00
parent 9e5ffbf930
commit 9be44bf72b

View File

@ -28,25 +28,14 @@ const defaultState = (): DisplayPreferencesState => ({
* Methods to apply for each CustomPrefs property.
* Those callbacks are usually done on global variables such as $vuetify or $i18n,
* and those may not be present early in the application lifecycle.
* The try-catch are there to silence those errors.
*/
const updateMethods: { [key: string]: (value: string) => void } = {
darkMode: (value: string) => {
try {
window.$nuxt.$vuetify.theme.dark = stringToBoolean(value);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
if (window.$nuxt) window.$nuxt.$vuetify.theme.dark = stringToBoolean(value);
},
locale: (value: string) => {
try {
window.$nuxt.$i18n.setLocale(value);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
if (window.$nuxt) window.$nuxt.$i18n.setLocale(value);
}
};