Fix #5885
This commit is contained in:
parent
851dececab
commit
390279a4a8
2 changed files with 7 additions and 12 deletions
|
@ -265,14 +265,8 @@ export default Vue.extend({
|
||||||
methods: {
|
methods: {
|
||||||
capture(withHandler = false) {
|
capture(withHandler = false) {
|
||||||
if (this.$store.getters.isSignedIn) {
|
if (this.$store.getters.isSignedIn) {
|
||||||
if (document.body.contains(this.$el)) {
|
this.connection.send(document.body.contains(this.$el) ? 'sn' : 's', { id: this.appearNote.id });
|
||||||
this.connection.send('sn', { id: this.appearNote.id });
|
|
||||||
if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated);
|
if (withHandler) this.connection.on('noteUpdated', this.onStreamNoteUpdated);
|
||||||
} else {
|
|
||||||
this.$once('hook:activated', () => {
|
|
||||||
this.capture(withHandler);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,9 @@ export default class Connection {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'api': this.onApiRequest(body); break;
|
case 'api': this.onApiRequest(body); break;
|
||||||
case 'readNotification': this.onReadNotification(body); break;
|
case 'readNotification': this.onReadNotification(body); break;
|
||||||
case 'subNote': this.onSubscribeNote(body); break;
|
case 'subNote': this.onSubscribeNote(body, true); break;
|
||||||
case 'sn': this.onSubscribeNote(body); break; // alias
|
case 'sn': this.onSubscribeNote(body, true); break; // alias
|
||||||
|
case 's': this.onSubscribeNote(body, false); break;
|
||||||
case 'unsubNote': this.onUnsubscribeNote(body); break;
|
case 'unsubNote': this.onUnsubscribeNote(body); break;
|
||||||
case 'un': this.onUnsubscribeNote(body); break; // alias
|
case 'un': this.onUnsubscribeNote(body); break; // alias
|
||||||
case 'connect': this.onChannelConnectRequested(body); break;
|
case 'connect': this.onChannelConnectRequested(body); break;
|
||||||
|
@ -107,7 +108,7 @@ export default class Connection {
|
||||||
* 投稿購読要求時
|
* 投稿購読要求時
|
||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
private onSubscribeNote(payload: any) {
|
private onSubscribeNote(payload: any, read: boolean) {
|
||||||
if (!payload.id) return;
|
if (!payload.id) return;
|
||||||
|
|
||||||
if (this.subscribingNotes[payload.id] == null) {
|
if (this.subscribingNotes[payload.id] == null) {
|
||||||
|
@ -120,7 +121,7 @@ export default class Connection {
|
||||||
this.subscriber.on(`noteStream:${payload.id}`, this.onNoteStreamMessage);
|
this.subscriber.on(`noteStream:${payload.id}`, this.onNoteStreamMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.user) {
|
if (this.user && read) {
|
||||||
readNote(this.user.id, payload.id);
|
readNote(this.user.id, payload.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue