[Client] Follow api changes and some cleanups

This commit is contained in:
syuilo 2017-03-19 15:22:55 +09:00
parent 31550ce1d9
commit 898daf24d1
5 changed files with 12 additions and 36 deletions

View file

@ -65,7 +65,7 @@ export default callback => {
// Get cached account data // Get cached account data
let cachedMe = JSON.parse(localStorage.getItem('me')); let cachedMe = JSON.parse(localStorage.getItem('me'));
if (cachedMe && cachedMe.data && cachedMe.data.cache) { if (cachedMe) {
fetched(cachedMe); fetched(cachedMe);
// 後から新鮮なデータをフェッチ // 後から新鮮なデータをフェッチ
@ -74,11 +74,6 @@ export default callback => {
cachedMe.trigger('updated'); cachedMe.trigger('updated');
}); });
} else { } else {
// キャッシュ無効なのにキャッシュが残ってたら掃除
if (cachedMe) {
localStorage.removeItem('me');
}
// Get token from cookie // Get token from cookie
const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1]; const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1];
@ -94,7 +89,6 @@ export default callback => {
me.trigger('updated'); me.trigger('updated');
}; };
if (me.data.cache) {
localStorage.setItem('me', JSON.stringify(me)); localStorage.setItem('me', JSON.stringify(me));
me.on('updated', () => { me.on('updated', () => {
@ -102,7 +96,6 @@ export default callback => {
localStorage.setItem('me', JSON.stringify(me)); localStorage.setItem('me', JSON.stringify(me));
}); });
} }
}
mixin(me); mixin(me);
@ -164,7 +157,7 @@ function fetchme(token, cb) {
function init() { function init() {
const data = generateDefaultUserdata(); const data = generateDefaultUserdata();
api(token, 'i/appdata/set', { api(token, 'i/appdata/set', {
data: JSON.stringify(data) set: data
}).then(() => { }).then(() => {
me.data = data; me.data = data;
done(); done();

View file

@ -38,8 +38,7 @@ export default () => {
}); });
const data = { const data = {
cache: true, home: JSON.stringify(homeData)
home: homeData
}; };
return data; return data;

View file

@ -54,12 +54,11 @@
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.I.data.no_donation = true; this.I.data.no_donation = 'true';
this.I.update(); this.I.update();
this.api('i/appdata/set', { this.api('i/appdata/set', {
data: JSON.stringify({ key: 'no_donation',
no_donation: this.I.data.no_donation value: 'true'
})
}); });
this.unmount(); this.unmount();

View file

@ -41,12 +41,6 @@
</section> </section>
<section class="web" show={ page == 'web' }> <section class="web" show={ page == 'web' }>
<h1>その他</h1>
<label class="checkbox">
<input type="checkbox" checked={ I.data.cache } onclick={ updateCache }/>
<p>読み込みを高速化する</p>
<p>API通信時に新鮮なユーザー情報をキャッシュすることでフェッチのオーバーヘッドを無くします。(実験的)</p>
</label>
</section> </section>
<section class="apps" show={ page == 'apps' }> <section class="apps" show={ page == 'apps' }>
@ -214,14 +208,5 @@
notify('プロフィールを更新しました'); notify('プロフィールを更新しました');
}); });
}; };
this.updateCache = () => {
this.I.data.cache = !this.I.data.cache;
this.api('i/appdata/set', {
data: JSON.stringify({
cache: this.I.data.cache
})
});
};
</script> </script>
</mk-settings> </mk-settings>

View file

@ -1,5 +1,5 @@
<mk-ui-header> <mk-ui-header>
<mk-donation if={ SIGNIN && !I.data.no_donation }></mk-donation> <mk-donation if={ SIGNIN && I.data.no_donation != 'true' }></mk-donation>
<mk-special-message></mk-special-message> <mk-special-message></mk-special-message>
<div class="main"> <div class="main">
<div class="backdrop"></div> <div class="backdrop"></div>