summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-14 03:40:12 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-14 03:40:12 +0900
commit10abe03ed7a5b9c5732d8db2e5c486b6bbad767c (patch)
tree77bd7cd9713e5ab97eb6d23fa65dd0f41ab37b1c /src/client
parentFix bug (diff)
downloadsharkey-10abe03ed7a5b9c5732d8db2e5c486b6bbad767c.tar.gz
sharkey-10abe03ed7a5b9c5732d8db2e5c486b6bbad767c.tar.bz2
sharkey-10abe03ed7a5b9c5732d8db2e5c486b6bbad767c.zip
Fix bug
Diffstat (limited to 'src/client')
-rw-r--r--src/client/app/common/mios.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/client/app/common/mios.ts b/src/client/app/common/mios.ts
index ccc73eebc3..f4bb60fcdb 100644
--- a/src/client/app/common/mios.ts
+++ b/src/client/app/common/mios.ts
@@ -441,10 +441,14 @@ export default class MiOS extends EventEmitter {
document.body.appendChild(spinner);
}
+ const onFinally = () => {
+ if (--pending === 0) spinner.parentNode.removeChild(spinner);
+ };
+
// Append a credential
if (this.isSignedIn) (data as any).i = this.i.token;
- return new Promise((resolve, reject) => {
+ const promise = new Promise((resolve, reject) => {
const viaStream = this.stream.hasConnection &&
(localStorage.getItem('apiViaStream') ? localStorage.getItem('apiViaStream') == 'true' : true);
@@ -453,8 +457,6 @@ export default class MiOS extends EventEmitter {
const id = Math.random().toString();
stream.once(`api-res:${id}`, res => {
- if (--pending === 0) spinner.parentNode.removeChild(spinner);
-
if (res.res) {
resolve(res.res);
} else {
@@ -489,8 +491,6 @@ export default class MiOS extends EventEmitter {
credentials: endpoint === 'signin' ? 'include' : 'omit',
cache: 'no-cache'
}).then(async (res) => {
- if (--pending === 0) spinner.parentNode.removeChild(spinner);
-
const body = res.status === 204 ? null : await res.json();
if (this.debug) {
@@ -508,6 +508,10 @@ export default class MiOS extends EventEmitter {
}).catch(reject);
}
});
+
+ promise.then(onFinally, onFinally);
+
+ return promise;
}
/**