From e515276e15fdf46a1756aa321701faf0b8d09854 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 6 Mar 2018 08:35:25 +0900 Subject: nanka iroiro Closes #1188 --- src/web/app/common/mios.ts | 10 +++++++- .../app/common/scripts/streaming/home-stream.ts | 7 +++++- .../app/desktop/views/components/post-detail.vue | 26 +++++++++++-------- .../app/desktop/views/components/posts.post.vue | 26 +++++++++++-------- src/web/app/desktop/views/components/settings.vue | 29 ++++++++-------------- .../app/mobile/views/components/post-detail.vue | 26 +++++++++++-------- src/web/app/mobile/views/components/post.vue | 26 +++++++++++-------- 7 files changed, 90 insertions(+), 60 deletions(-) (limited to 'src/web/app') diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index da1d9746a1..bbe28960fd 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -1,5 +1,6 @@ import Vue from 'vue'; import { EventEmitter } from 'eventemitter3'; +import * as merge from 'object-assign-deep'; import { host, apiUrl, swPublickey, version, lang, googleMapsApiKey } from '../config'; import Progress from './scripts/loading'; @@ -284,6 +285,13 @@ export default class MiOS extends EventEmitter { // フェッチが完了したとき const fetched = me => { if (me) { + // デフォルトの設定をマージ + me.client_settings = Object.assign({ + fetchOnScroll: true, + showMaps: true, + showPostFormOnTopOfTl: false + }, me.client_settings); + // ローカルストレージにキャッシュ localStorage.setItem('me', JSON.stringify(me)); } @@ -313,7 +321,7 @@ export default class MiOS extends EventEmitter { // 後から新鮮なデータをフェッチ fetchme(cachedMe.token, freshData => { - Object.assign(cachedMe, freshData); + merge(cachedMe, freshData); }); } else { // Get token from cookie diff --git a/src/web/app/common/scripts/streaming/home-stream.ts b/src/web/app/common/scripts/streaming/home-stream.ts index 57bf0ec2a6..3516705e22 100644 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -1,3 +1,5 @@ +import * as merge from 'object-assign-deep'; + import Stream from './stream'; import MiOS from '../../mios'; @@ -18,7 +20,10 @@ export default class Connection extends Stream { // 自分の情報が更新されたとき this.on('i_updated', i => { - Object.assign(me, i); + if (os.debug) { + console.log('I updated:', i); + } + merge(me, i); }); // トークンが再生成されたとき diff --git a/src/web/app/desktop/views/components/post-detail.vue b/src/web/app/desktop/views/components/post-detail.vue index e33120c7c0..e454c28702 100644 --- a/src/web/app/desktop/views/components/post-detail.vue +++ b/src/web/app/desktop/views/components/post-detail.vue @@ -148,17 +148,20 @@ export default Vue.extend({ // Draw map if (this.p.geo) { - (this as any).os.getGoogleMaps().then(maps => { - const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); - const map = new maps.Map(this.$refs.map, { - center: uluru, - zoom: 15 + const shouldShowMap = (this as any).os.isSignedIn ? (this as any).os.i.client_settings.showMaps : true; + if (shouldShowMap) { + (this as any).os.getGoogleMaps().then(maps => { + const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); + const map = new maps.Map(this.$refs.map, { + center: uluru, + zoom: 15 + }); + new maps.Marker({ + position: uluru, + map: map + }); }); - new maps.Marker({ - position: uluru, - map: map - }); - }); + } } }, methods: { @@ -348,6 +351,9 @@ export default Vue.extend({ width 100% height 300px + &:empty + display none + > .mk-url-preview margin-top 8px diff --git a/src/web/app/desktop/views/components/posts.post.vue b/src/web/app/desktop/views/components/posts.post.vue index b88f016ad1..1a5f7c3b09 100644 --- a/src/web/app/desktop/views/components/posts.post.vue +++ b/src/web/app/desktop/views/components/posts.post.vue @@ -162,17 +162,20 @@ export default Vue.extend({ // Draw map if (this.p.geo) { - (this as any).os.getGoogleMaps().then(maps => { - const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); - const map = new maps.Map(this.$refs.map, { - center: uluru, - zoom: 15 + const shouldShowMap = (this as any).os.isSignedIn ? (this as any).os.i.client_settings.showMaps : true; + if (shouldShowMap) { + (this as any).os.getGoogleMaps().then(maps => { + const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); + const map = new maps.Map(this.$refs.map, { + center: uluru, + zoom: 15 + }); + new maps.Marker({ + position: uluru, + map: map + }); }); - new maps.Marker({ - position: uluru, - map: map - }); - }); + } } }, beforeDestroy() { @@ -467,6 +470,9 @@ export default Vue.extend({ width 100% height 300px + &:empty + display none + > .tags margin 4px 0 0 0 diff --git a/src/web/app/desktop/views/components/settings.vue b/src/web/app/desktop/views/components/settings.vue index 3278efb9ca..524e055c3a 100644 --- a/src/web/app/desktop/views/components/settings.vue +++ b/src/web/app/desktop/views/components/settings.vue @@ -20,7 +20,7 @@

動作

- + ページを下までスクロールしたときに自動で追加のコンテンツを読み込みます。
@@ -31,6 +31,9 @@ + + 位置情報が添付された投稿のマップを自動的に展開します。 +
@@ -71,7 +74,7 @@

通知

- + リアクションしたり返信したりした投稿に関する通知を自動的に受け取るようにします。
@@ -193,8 +196,6 @@ export default Vue.extend({ version, latestVersion: undefined, checkingForUpdate: false, - fetchOnScroll: true, - autoWatch: true, enableSounds: localStorage.getItem('enableSounds') == 'true', lang: localStorage.getItem('lang') || '', preventUpdate: localStorage.getItem('preventUpdate') == 'true', @@ -228,20 +229,6 @@ export default Vue.extend({ (this as any).os.getMeta().then(meta => { this.meta = meta; }); - - if ((this as any).os.i.settings.auto_watch != null) { - this.autoWatch = (this as any).os.i.settings.auto_watch; - this.$watch('os.i.settings.auto_watch', v => { - this.autoWatch = v; - }); - } - - if ((this as any).os.i.client_settings.fetchOnScroll != null) { - this.fetchOnScroll = (this as any).os.i.client_settings.fetchOnScroll; - this.$watch('os.i.client_settings.fetchOnScroll', v => { - this.fetchOnScroll = v; - }); - } }, methods: { customizeHome() { @@ -265,6 +252,12 @@ export default Vue.extend({ value: v }); }, + onChangeShowMaps(v) { + (this as any).api('i/update_client_setting', { + name: 'showMaps', + value: v + }); + }, onChangeDisableViaMobile(v) { (this as any).api('i/update_client_setting', { name: 'disableViaMobile', diff --git a/src/web/app/mobile/views/components/post-detail.vue b/src/web/app/mobile/views/components/post-detail.vue index bf8ce4f6fa..d51bfbc0e6 100644 --- a/src/web/app/mobile/views/components/post-detail.vue +++ b/src/web/app/mobile/views/components/post-detail.vue @@ -144,17 +144,20 @@ export default Vue.extend({ // Draw map if (this.p.geo) { - (this as any).os.getGoogleMaps().then(maps => { - const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); - const map = new maps.Map(this.$refs.map, { - center: uluru, - zoom: 15 + const shouldShowMap = (this as any).os.isSignedIn ? (this as any).os.i.client_settings.showMaps : true; + if (shouldShowMap) { + (this as any).os.getGoogleMaps().then(maps => { + const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); + const map = new maps.Map(this.$refs.map, { + center: uluru, + zoom: 15 + }); + new maps.Marker({ + position: uluru, + map: map + }); }); - new maps.Marker({ - position: uluru, - map: map - }); - }); + } } }, methods: { @@ -349,6 +352,9 @@ export default Vue.extend({ width 100% height 200px + &:empty + display none + > .mk-url-preview margin-top 8px diff --git a/src/web/app/mobile/views/components/post.vue b/src/web/app/mobile/views/components/post.vue index 390c6396f2..3b31b827f6 100644 --- a/src/web/app/mobile/views/components/post.vue +++ b/src/web/app/mobile/views/components/post.vue @@ -137,17 +137,20 @@ export default Vue.extend({ // Draw map if (this.p.geo) { - (this as any).os.getGoogleMaps().then(maps => { - const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); - const map = new maps.Map(this.$refs.map, { - center: uluru, - zoom: 15 + const shouldShowMap = (this as any).os.isSignedIn ? (this as any).os.i.client_settings.showMaps : true; + if (shouldShowMap) { + (this as any).os.getGoogleMaps().then(maps => { + const uluru = new maps.LatLng(this.p.geo.latitude, this.p.geo.longitude); + const map = new maps.Map(this.$refs.map, { + center: uluru, + zoom: 15 + }); + new maps.Marker({ + position: uluru, + map: map + }); }); - new maps.Marker({ - position: uluru, - map: map - }); - }); + } } }, beforeDestroy() { @@ -448,6 +451,9 @@ export default Vue.extend({ width 100% height 200px + &:empty + display none + > .app font-size 12px color #ccc -- cgit v1.2.3-freya