1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-29 15:28:25 +09:00

Better UX

This commit is contained in:
syuilo 2018-11-16 05:26:36 +09:00
parent a3c4e8a1bc
commit a86ae9fa50
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
2 changed files with 11 additions and 7 deletions

View File

@ -148,7 +148,7 @@ export default Vue.extend({
}, },
updateStats() { updateStats() {
this.$root.api('stats').then(stats => { this.$root.api('stats', {}, false, true).then(stats => {
this.stats = stats; this.stats = stats;
}); });
} }

View File

@ -385,15 +385,19 @@ export default class MiOS extends EventEmitter {
* @param data * @param data
*/ */
@autobind @autobind
public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false): Promise<{ [x: string]: any }> { public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false, silent = false): Promise<{ [x: string]: any }> {
if (!silent) {
if (++pending === 1) { if (++pending === 1) {
spinner = document.createElement('div'); spinner = document.createElement('div');
spinner.setAttribute('id', 'wait'); spinner.setAttribute('id', 'wait');
document.body.appendChild(spinner); document.body.appendChild(spinner);
} }
}
const onFinally = () => { const onFinally = () => {
if (!silent) {
if (--pending === 0) spinner.parentNode.removeChild(spinner); if (--pending === 0) spinner.parentNode.removeChild(spinner);
}
}; };
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {