From 390279a4a820e0b9678c2514a0d4cebae6992aa6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 9 Feb 2020 03:49:18 +0900 Subject: [PATCH] Fix #5885 --- src/client/components/note.vue | 10 ++-------- src/server/api/stream/index.ts | 9 +++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/client/components/note.vue b/src/client/components/note.vue index 80d6180b7..0e9272ec3 100644 --- a/src/client/components/note.vue +++ b/src/client/components/note.vue @@ -265,14 +265,8 @@ export default Vue.extend({ methods: { capture(withHandler = false) { if (this.$store.getters.isSignedIn) { - if (document.body.contains(this.$el)) { - this.connection.send('sn', { id: this.appearNote.id }); - if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated); - } else { - this.$once('hook:activated', () => { - this.capture(withHandler); - }); - } + this.connection.send(document.body.contains(this.$el) ? 'sn' : 's', { id: this.appearNote.id }); + if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated); } }, diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index 6ec644a02..463ae0a60 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -60,8 +60,9 @@ export default class Connection { switch (type) { case 'api': this.onApiRequest(body); break; case 'readNotification': this.onReadNotification(body); break; - case 'subNote': this.onSubscribeNote(body); break; - case 'sn': this.onSubscribeNote(body); break; // alias + case 'subNote': this.onSubscribeNote(body, true); break; + case 'sn': this.onSubscribeNote(body, true); break; // alias + case 's': this.onSubscribeNote(body, false); break; case 'unsubNote': this.onUnsubscribeNote(body); break; case 'un': this.onUnsubscribeNote(body); break; // alias case 'connect': this.onChannelConnectRequested(body); break; @@ -107,7 +108,7 @@ export default class Connection { * 投稿購読要求時 */ @autobind - private onSubscribeNote(payload: any) { + private onSubscribeNote(payload: any, read: boolean) { if (!payload.id) return; if (this.subscribingNotes[payload.id] == null) { @@ -120,7 +121,7 @@ export default class Connection { this.subscriber.on(`noteStream:${payload.id}`, this.onNoteStreamMessage); } - if (this.user) { + if (this.user && read) { readNote(this.user.id, payload.id); } }