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

View file

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

View file

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

View file

@ -41,12 +41,6 @@
</section>
<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 class="apps" show={ page == 'apps' }>
@ -214,14 +208,5 @@
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>
</mk-settings>

View file

@ -1,5 +1,5 @@
<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>
<div class="main">
<div class="backdrop"></div>