From 898daf24d12cb02b72ce128f8b143ad39d95620a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 19 Mar 2017 15:22:55 +0900 Subject: [PATCH] [Client] Follow api changes and some cleanups --- src/web/app/boot.js | 21 +++++++------------ .../scripts/generate-default-userdata.js | 3 +-- src/web/app/desktop/tags/donation.tag | 7 +++---- src/web/app/desktop/tags/settings.tag | 15 ------------- src/web/app/desktop/tags/ui-header.tag | 2 +- 5 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 24981c5889..cdedcd5003 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -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,14 +89,12 @@ export default callback => { me.trigger('updated'); }; - if (me.data.cache) { - localStorage.setItem('me', JSON.stringify(me)); + localStorage.setItem('me', JSON.stringify(me)); - me.on('updated', () => { - // キャッシュ更新 - localStorage.setItem('me', JSON.stringify(me)); - }); - } + me.on('updated', () => { + // キャッシュ更新 + 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(); diff --git a/src/web/app/common/scripts/generate-default-userdata.js b/src/web/app/common/scripts/generate-default-userdata.js index 1f3a04e649..1200563e1a 100644 --- a/src/web/app/common/scripts/generate-default-userdata.js +++ b/src/web/app/common/scripts/generate-default-userdata.js @@ -38,8 +38,7 @@ export default () => { }); const data = { - cache: true, - home: homeData + home: JSON.stringify(homeData) }; return data; diff --git a/src/web/app/desktop/tags/donation.tag b/src/web/app/desktop/tags/donation.tag index 6c6b3a94ad..33f377a192 100644 --- a/src/web/app/desktop/tags/donation.tag +++ b/src/web/app/desktop/tags/donation.tag @@ -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(); diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 6d692ed9aa..07ed6043b8 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -41,12 +41,6 @@
-

その他

-
@@ -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 - }) - }); - }; diff --git a/src/web/app/desktop/tags/ui-header.tag b/src/web/app/desktop/tags/ui-header.tag index 3bdd5a2ff8..5547574f94 100644 --- a/src/web/app/desktop/tags/ui-header.tag +++ b/src/web/app/desktop/tags/ui-header.tag @@ -1,5 +1,5 @@ - +