diff options
author | Yukai Huang | 2017-01-21 12:08:52 +0800 |
---|---|---|
committer | Yukai Huang | 2017-01-21 12:08:52 +0800 |
commit | 4bbe035beb41ad2c9f43434d0d90209850a62f70 (patch) | |
tree | 53095b529b1220b6e2d23f0dbc255af2ca54d7d7 /public/js/lib/common | |
parent | a9a38c3d75b1cf467bb3b4484abfc09dcbcea107 (diff) | |
parent | 1de4242473b74afdb2d3e358e3b213ef156ca0de (diff) |
Merge branch 'master' into frontend-next
Diffstat (limited to 'public/js/lib/common')
-rw-r--r-- | public/js/lib/common/login.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/public/js/lib/common/login.js b/public/js/lib/common/login.js index f1a03c72..58fa55c6 100644 --- a/public/js/lib/common/login.js +++ b/public/js/lib/common/login.js @@ -4,7 +4,7 @@ let checkAuth = false; let profile = null; let lastLoginState = getLoginState(); let lastUserId = getUserId(); -let loginStateChangeEvent = null; +var loginStateChangeEvent = null; export function setloginStateChangeEvent(func) { loginStateChangeEvent = func; @@ -32,9 +32,7 @@ export function setLoginState(bool, id) { export function checkLoginStateChanged() { if (getLoginState() != lastLoginState || getUserId() != lastUserId) { - if (loginStateChangeEvent) { - loginStateChangeEvent(); - } + if (loginStateChangeEvent) setTimeout(loginStateChangeEvent, 100); return true; } else { return false; @@ -56,8 +54,7 @@ export function clearLoginState() { export function checkIfAuth(yesCallback, noCallback) { const cookieLoginState = getLoginState(); - if (checkLoginStateChanged()) - checkAuth = false; + if (checkLoginStateChanged()) checkAuth = false; if (!checkAuth || typeof cookieLoginState == 'undefined') { $.get(`${serverurl}/me`) .done(data => { |