summaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-04 16:51:30 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-04 16:51:47 +0200
commit9763d3f756954f75feb7c0fa1911b99ce917a33a (patch)
tree1dc7e77cb9f158bf6fb1c055a40f0308100ddf56 /src/components
parentc484ce45299879f9000947625d2488d4f23c4cd9 (diff)
Use async/await moment loading
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Properties/PropertyDateTime.vue40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/components/Properties/PropertyDateTime.vue b/src/components/Properties/PropertyDateTime.vue
index f93d1092..6c909adf 100644
--- a/src/components/Properties/PropertyDateTime.vue
+++ b/src/components/Properties/PropertyDateTime.vue
@@ -130,33 +130,31 @@ export default {
}
},
- mounted() {
+ async mounted() {
// Load the locale
// convert format like en_GB to en-gb for `moment.js`
let locale = getLocale().replace('_', '-').toLowerCase()
- // default load e.g. fr-fr
- console.debug('Importing locale', locale)
- import('moment/locale/' + locale)
- .then(e => {
- // force locale change to update
- // the component once done loading
- this.locale = locale
- })
- .catch(e => {
+ try {
+ // default load e.g. fr-fr
+ await import('moment/locale/' + locale)
+ this.locale = locale
+ } catch (e) {
+ try {
// failure: fallback to fr
locale = locale.split('-')[0]
- console.debug('Fallback to locale', locale)
- import('moment/locale/' + locale)
- .then(e => {
- this.locale = locale
- })
- .catch(e => {
- console.debug('Fallback to locale', 'en')
- // failure, fallback to english
- this.locale = 'en'
- })
- })
+ await import('moment/locale/' + locale)
+ } catch (e) {
+ // failure, fallback to english
+ console.debug('Fallback to locale', 'en')
+ locale = 'en'
+ }
+ } finally {
+ // force locale change to update
+ // the component once done loading
+ this.locale = locale
+ console.debug('Locale used', locale)
+ }
},
methods: {