From a86ae9fa50ecb0767657ece666819126fb1cf933 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 2a6d9a3101..3fd024a133 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 2f5dcde159..5ed4dfd4db 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) => {