From 9008138ba561d345faa5fa46b36915f16cdcb70f Mon Sep 17 00:00:00 2001 From: Yan-Fa Li Date: Tue, 12 Mar 2019 10:22:03 -0700 Subject: [PATCH] Issue #274 Fix loading readme on importing keymap (#275) Regression. Pre-vue upgrade the README would reload when importing a keymap.json. This did not work anymore. Reported by @noroadsleft - change status/viewReadme to always clear status window - wait for viewReadme action to finish before setting keymapname and dirty flag - clean up loadingKeymapPromise slightly and cache it, remove it then execute the promise. --- src/components/ControllerBottom.vue | 6 ++++-- src/components/VisualKeymap.vue | 3 ++- src/store/modules/status.js | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/ControllerBottom.vue b/src/components/ControllerBottom.vue index b3e053e51b..b45fbb8590 100644 --- a/src/components/ControllerBottom.vue +++ b/src/components/ControllerBottom.vue @@ -250,8 +250,10 @@ export default { stats.count } keycodes. Defined ${stats.any} Any key keycodes\n`; store.commit('status/deferredMessage', msg); - store.commit('app/setKeymapName', data.keymap); - store.commit('keymap/setDirty'); + store.dispatch('status/viewReadme', this.keyboard).then(() => { + store.commit('app/setKeymapName', data.keymap); + store.commit('keymap/setDirty'); + }); }); disableOtherButtons(); }); diff --git a/src/components/VisualKeymap.vue b/src/components/VisualKeymap.vue index 959e9179b5..a6a42d5c1a 100644 --- a/src/components/VisualKeymap.vue +++ b/src/components/VisualKeymap.vue @@ -65,8 +65,9 @@ export default { return []; } if (this.loadingKeymapPromise) { - this.loadingKeymapPromise(); + const _promise = this.loadingKeymapPromise; this.setLoadingKeymapPromise(undefined); + _promise(); } // Calculate Max with given layout // eslint-disable-next-line no-console diff --git a/src/store/modules/status.js b/src/store/modules/status.js index d26725a639..50b320a73e 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -22,6 +22,7 @@ const actions = { .get(backend_readme_url_template({ keyboard: _keyboard })) .then(result => { if (result.status === 200) { + commit('clear'); commit('append', escape(result.data)); commit('append', escape(state.deferredMessage)); commit('deferredMessage', '');