From d9f0e158a35eec183da77e84a3b038fab645bf62 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 19 Sep 2018 14:18:34 +0900 Subject: [PATCH] Implement #2736 --- .../app/common/scripts/streaming/home.ts | 24 +++++++ .../desktop/views/components/notes.note.vue | 8 ++- .../app/desktop/views/components/timeline.vue | 11 +++- .../desktop/views/pages/deck/deck.note.vue | 8 ++- .../app/mobile/views/components/note.vue | 8 ++- .../app/mobile/views/components/ui.header.vue | 3 - src/client/app/mobile/views/pages/drive.vue | 6 +- .../app/mobile/views/pages/favorites.vue | 2 +- .../app/mobile/views/pages/games/reversi.vue | 2 +- src/client/app/mobile/views/pages/home.vue | 27 +++++++- .../app/mobile/views/pages/messaging-room.vue | 2 +- .../app/mobile/views/pages/messaging.vue | 2 +- src/client/app/mobile/views/pages/note.vue | 2 +- .../app/mobile/views/pages/notifications.vue | 2 +- .../app/mobile/views/pages/settings.vue | 2 +- src/client/app/mobile/views/pages/tag.vue | 2 +- src/client/app/mobile/views/pages/widgets.vue | 2 +- src/models/note-unread.ts | 17 +++++ src/models/note.ts | 4 +- src/models/user.ts | 8 ++- src/server/api/endpoints/i.ts | 1 + src/server/api/stream/home.ts | 4 ++ src/services/note/create.ts | 22 ++++--- src/services/note/read.ts | 62 +++++++++++++++++++ src/services/note/unread.ts | 47 ++++++++++++++ 25 files changed, 239 insertions(+), 39 deletions(-) create mode 100644 src/models/note-unread.ts create mode 100644 src/services/note/read.ts create mode 100644 src/services/note/unread.ts diff --git a/src/client/app/common/scripts/streaming/home.ts b/src/client/app/common/scripts/streaming/home.ts index dd18c70d70..26729507fb 100644 --- a/src/client/app/common/scripts/streaming/home.ts +++ b/src/client/app/common/scripts/streaming/home.ts @@ -50,6 +50,30 @@ export class HomeStream extends Stream { }); }); + this.on('unreadMention', () => { + os.store.dispatch('mergeMe', { + hasUnreadMentions: true + }); + }); + + this.on('readAllUnreadMentions', () => { + os.store.dispatch('mergeMe', { + hasUnreadMentions: false + }); + }); + + this.on('unreadSpecifiedNote', () => { + os.store.dispatch('mergeMe', { + hasUnreadSpecifiedNotes: true + }); + }); + + this.on('readAllUnreadSpecifiedNotes', () => { + os.store.dispatch('mergeMe', { + hasUnreadSpecifiedNotes: false + }); + }); + this.on('clientSettingUpdated', x => { os.store.commit('settings/set', { key: x.key, diff --git a/src/client/app/desktop/views/components/notes.note.vue b/src/client/app/desktop/views/components/notes.note.vue index fdf41a52c9..ac2c1ce97f 100644 --- a/src/client/app/desktop/views/components/notes.note.vue +++ b/src/client/app/desktop/views/components/notes.note.vue @@ -213,10 +213,14 @@ export default Vue.extend({ methods: { capture(withHandler = false) { if (this.$store.getters.isSignedIn) { - this.connection.send({ + const data = { type: 'capture', id: this.p.id - }); + } as any; + if ((this.p.visibleUserIds || []).includes(this.$store.state.i.id) || (this.p.mentions || []).includes(this.$store.state.i.id)) { + data.read = true; + } + this.connection.send(data); if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); } }, diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index 9f421a68ed..7d683236bb 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -8,8 +8,8 @@ %fa:hashtag% {{ tagTl.title }} %fa:list% {{ list.title }}
- - + +
@@ -202,6 +202,13 @@ root(isDark) line-height 42px color isDark ? #9baec8 : #ccc + > .badge + position absolute + top -4px + right 4px + font-size 10px + color $theme-color + &:hover color isDark ? #b2c1d5 : #aaa diff --git a/src/client/app/desktop/views/pages/deck/deck.note.vue b/src/client/app/desktop/views/pages/deck/deck.note.vue index 980fb03136..99274b0f41 100644 --- a/src/client/app/desktop/views/pages/deck/deck.note.vue +++ b/src/client/app/desktop/views/pages/deck/deck.note.vue @@ -147,10 +147,14 @@ export default Vue.extend({ methods: { capture(withHandler = false) { if (this.$store.getters.isSignedIn) { - this.connection.send({ + const data = { type: 'capture', id: this.p.id - }); + } as any; + if ((this.p.visibleUserIds || []).includes(this.$store.state.i.id) || (this.p.mentions || []).includes(this.$store.state.i.id)) { + data.read = true; + } + this.connection.send(data); if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); } }, diff --git a/src/client/app/mobile/views/components/note.vue b/src/client/app/mobile/views/components/note.vue index 8787b39a93..0ce72cab11 100644 --- a/src/client/app/mobile/views/components/note.vue +++ b/src/client/app/mobile/views/components/note.vue @@ -160,10 +160,14 @@ export default Vue.extend({ methods: { capture(withHandler = false) { if (this.$store.getters.isSignedIn) { - this.connection.send({ + const data = { type: 'capture', id: this.p.id - }); + } as any; + if ((this.p.visibleUserIds || []).includes(this.$store.state.i.id) || (this.p.mentions || []).includes(this.$store.state.i.id)) { + data.read = true; + } + this.connection.send(data); if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); } }, diff --git a/src/client/app/mobile/views/components/ui.header.vue b/src/client/app/mobile/views/components/ui.header.vue index c9b3ab51ae..15c8299c2e 100644 --- a/src/client/app/mobile/views/components/ui.header.vue +++ b/src/client/app/mobile/views/components/ui.header.vue @@ -188,9 +188,6 @@ root(isDark) overflow hidden text-overflow ellipsis - [data-fa], [data-icon] - margin-right 4px - > img display inline-block vertical-align bottom diff --git a/src/client/app/mobile/views/pages/drive.vue b/src/client/app/mobile/views/pages/drive.vue index 27ac956043..c0fc7b48dc 100644 --- a/src/client/app/mobile/views/pages/drive.vue +++ b/src/client/app/mobile/views/pages/drive.vue @@ -1,9 +1,9 @@