From 36c3b726b64a19584b3f046870e89abb791d6457 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 16 Nov 2018 05:26:36 +0900 Subject: [PATCH] Better UX --- src/client/app/admin/views/dashboard.vue | 2 +- src/client/app/mios.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/client/app/admin/views/dashboard.vue b/src/client/app/admin/views/dashboard.vue index 2a6d9a310..3fd024a13 100644 --- a/src/client/app/admin/views/dashboard.vue +++ b/src/client/app/admin/views/dashboard.vue @@ -148,7 +148,7 @@ export default Vue.extend({ }, updateStats() { - this.$root.api('stats').then(stats => { + this.$root.api('stats', {}, false, true).then(stats => { this.stats = stats; }); } diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts index 2f5dcde15..5ed4dfd4d 100644 --- a/src/client/app/mios.ts +++ b/src/client/app/mios.ts @@ -385,15 +385,19 @@ export default class MiOS extends EventEmitter { * @param data パラメータ */ @autobind - public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false): Promise<{ [x: string]: any }> { - if (++pending === 1) { - spinner = document.createElement('div'); - spinner.setAttribute('id', 'wait'); - document.body.appendChild(spinner); + public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false, silent = false): Promise<{ [x: string]: any }> { + if (!silent) { + if (++pending === 1) { + spinner = document.createElement('div'); + spinner.setAttribute('id', 'wait'); + document.body.appendChild(spinner); + } } const onFinally = () => { - if (--pending === 0) spinner.parentNode.removeChild(spinner); + if (!silent) { + if (--pending === 0) spinner.parentNode.removeChild(spinner); + } }; const promise = new Promise((resolve, reject) => {