From aa09cb5b9d340df65a852260abd1fae2ffcb121d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?syuilo=E2=AD=90=EF=B8=8F?= Date: Fri, 3 Feb 2017 05:14:07 +0900 Subject: [PATCH] Refactor --- src/web/app/common/scripts/api.ls | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/web/app/common/scripts/api.ls b/src/web/app/common/scripts/api.ls index 2292902a9..7ebd645db 100644 --- a/src/web/app/common/scripts/api.ls +++ b/src/web/app/common/scripts/api.ls @@ -10,7 +10,11 @@ riot.mixin \net do module.exports = (i, endpoint, data) -> pending++ - + if pending == 1 + spinner := document.create-element \div + ..set-attribute \id \wait + document.body.append-child spinner + if i? and typeof i == \object then i = i.token body = [] @@ -36,11 +40,6 @@ module.exports = (i, endpoint, data) -> then endpoint else "#{CONFIG.api.url}/#{endpoint}" - if pending == 1 - spinner := document.create-element \div - ..set-attribute \id \wait - document.body.append-child spinner - new Promise (resolve, reject) -> timer = set-timeout -> net.trigger \detected-slow-network