summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-19 15:22:55 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-19 15:22:55 +0900
commit898daf24d12cb02b72ce128f8b143ad39d95620a (patch)
tree73ccc3b7dc509779e9a751794dca8839f3bd845f /src
parent[API] Better appdata get/set endpoints (BREAKING) (diff)
downloadsharkey-898daf24d12cb02b72ce128f8b143ad39d95620a.tar.gz
sharkey-898daf24d12cb02b72ce128f8b143ad39d95620a.tar.bz2
sharkey-898daf24d12cb02b72ce128f8b143ad39d95620a.zip
[Client] Follow api changes and some cleanups
Diffstat (limited to 'src')
-rw-r--r--src/web/app/boot.js21
-rw-r--r--src/web/app/common/scripts/generate-default-userdata.js3
-rw-r--r--src/web/app/desktop/tags/donation.tag7
-rw-r--r--src/web/app/desktop/tags/settings.tag15
-rw-r--r--src/web/app/desktop/tags/ui-header.tag2
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 @@
</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>
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 @@
<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>