diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-01-01 11:23:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-01-01 11:23:09 +0900 |
| commit | 7c91da61835081f9fad4582103b6db3d8f4fe27c (patch) | |
| tree | df037527b327dd9479cdb76e2c83bbde63b7e5ea /src | |
| parent | Fox bug (diff) | |
| download | sharkey-7c91da61835081f9fad4582103b6db3d8f4fe27c.tar.gz sharkey-7c91da61835081f9fad4582103b6db3d8f4fe27c.tar.bz2 sharkey-7c91da61835081f9fad4582103b6db3d8f4fe27c.zip | |
Refactor: Improve readability
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/app/boot.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 612e73e885..5067600c6c 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -1,13 +1,6 @@ -/* -MISSKEY BOOT LOADER - -Misskeyを起動します。 -1. 初期化 -2. ユーザー取得(ログインしていれば) -3. アプリケーションをマウント -*/ - -// LOAD DEPENDENCIES +/** + * boot + */ const riot = require('riot'); require('velocity'); @@ -18,7 +11,9 @@ const mixins = require('./common/mixins.ls'); const checkForUpdate = require('./common/scripts/check-for-update.ls'); require('./common/tags.ls'); -// MISSKEY ENTORY POINT +/** + * MISSKEY ENTORY POINT! + */ document.domain = CONFIG.host; @@ -64,26 +59,33 @@ module.exports = callback => { if (cachedMe != null) { localStorage.removeItem('me'); } + fetchme(i, false, fetched); } function fetched(me) { if (me != null) { riot.observable(me); + if (me.data.cache) { localStorage.setItem('me', JSON.stringify(me)); + me.on('updated', () => { // キャッシュ更新 localStorage.setItem('me', JSON.stringify(me)); }); } } + mixins(me); + const init = document.getElementById('init'); init.parentNode.removeChild(init); + const app = document.createElement('div'); app.setAttribute('id', 'app'); document.body.appendChild(app); + try { callback(me); } catch (e) { @@ -113,6 +115,7 @@ function fetchme(token, silent, cb) { if (res.status !== 200) { return signout(); } + res.json().then(i => { me = i; me.token = token; |