Refactor: Improve readability
This commit is contained in:
		
							parent
							
								
									3edd41b97e
								
							
						
					
					
						commit
						7c91da6183
					
				
					 1 changed files with 14 additions and 11 deletions
				
			
		| 
						 | 
					@ -1,13 +1,6 @@
 | 
				
			||||||
/*
 | 
					/**
 | 
				
			||||||
MISSKEY BOOT LOADER
 | 
					 * boot
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
Misskeyを起動します。
 | 
					 | 
				
			||||||
1. 初期化
 | 
					 | 
				
			||||||
2. ユーザー取得(ログインしていれば)
 | 
					 | 
				
			||||||
3. アプリケーションをマウント
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// LOAD DEPENDENCIES
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const riot = require('riot');
 | 
					const riot = require('riot');
 | 
				
			||||||
require('velocity');
 | 
					require('velocity');
 | 
				
			||||||
| 
						 | 
					@ -18,7 +11,9 @@ const mixins = require('./common/mixins.ls');
 | 
				
			||||||
const checkForUpdate = require('./common/scripts/check-for-update.ls');
 | 
					const checkForUpdate = require('./common/scripts/check-for-update.ls');
 | 
				
			||||||
require('./common/tags.ls');
 | 
					require('./common/tags.ls');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MISSKEY ENTORY POINT
 | 
					/**
 | 
				
			||||||
 | 
					 * MISSKEY ENTORY POINT!
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
document.domain = CONFIG.host;
 | 
					document.domain = CONFIG.host;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,26 +59,33 @@ module.exports = callback => {
 | 
				
			||||||
		if (cachedMe != null) {
 | 
							if (cachedMe != null) {
 | 
				
			||||||
			localStorage.removeItem('me');
 | 
								localStorage.removeItem('me');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fetchme(i, false, fetched);
 | 
							fetchme(i, false, fetched);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function fetched(me) {
 | 
						function fetched(me) {
 | 
				
			||||||
		if (me != null) {
 | 
							if (me != null) {
 | 
				
			||||||
			riot.observable(me);
 | 
								riot.observable(me);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (me.data.cache) {
 | 
								if (me.data.cache) {
 | 
				
			||||||
				localStorage.setItem('me', JSON.stringify(me));
 | 
									localStorage.setItem('me', JSON.stringify(me));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				me.on('updated', () => {
 | 
									me.on('updated', () => {
 | 
				
			||||||
					// キャッシュ更新
 | 
										// キャッシュ更新
 | 
				
			||||||
					localStorage.setItem('me', JSON.stringify(me));
 | 
										localStorage.setItem('me', JSON.stringify(me));
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mixins(me);
 | 
							mixins(me);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const init = document.getElementById('init');
 | 
							const init = document.getElementById('init');
 | 
				
			||||||
		init.parentNode.removeChild(init);
 | 
							init.parentNode.removeChild(init);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const app = document.createElement('div');
 | 
							const app = document.createElement('div');
 | 
				
			||||||
		app.setAttribute('id', 'app');
 | 
							app.setAttribute('id', 'app');
 | 
				
			||||||
		document.body.appendChild(app);
 | 
							document.body.appendChild(app);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			callback(me);
 | 
								callback(me);
 | 
				
			||||||
		} catch (e) {
 | 
							} catch (e) {
 | 
				
			||||||
| 
						 | 
					@ -113,6 +115,7 @@ function fetchme(token, silent, cb) {
 | 
				
			||||||
		if (res.status !== 200) {
 | 
							if (res.status !== 200) {
 | 
				
			||||||
			return signout();
 | 
								return signout();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		res.json().then(i => {
 | 
							res.json().then(i => {
 | 
				
			||||||
			me = i;
 | 
								me = i;
 | 
				
			||||||
			me.token = token;
 | 
								me.token = token;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue