diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js index cbdde8d2f..5296abfde 100644 --- a/src/web/app/common/scripts/stream.js +++ b/src/web/app/common/scripts/stream.js @@ -45,6 +45,8 @@ class Connection { } send(message) { + // TODO: バッファリングしてつぎ接続した時に送信する + if (this.state != 'connected') return; this.socket.send(JSON.stringify(message)); } diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag index 07cc66567..220b8441b 100644 --- a/src/web/app/desktop/tags/timeline-post.tag +++ b/src/web/app/desktop/tags/timeline-post.tag @@ -364,13 +364,24 @@ } }; - this.on('mount', () => { + this.capture = () => { this.stream.send({ type: 'capture', id: this.p.id }); - this.stream.event.on('post-updated', this.onStreamPostUpdated); + }; + + this.decapture = () => { + this.stream.send({ + type: 'decapture', + id: this.p.id + }); + this.stream.event.off('post-updated', this.onStreamPostUpdated); + }; + + this.on('mount', () => { + this.capture(); if (this.p.text) { const tokens = this.p.ast; @@ -393,12 +404,7 @@ }); this.on('unmount', () => { - this.stream.send({ - type: 'decapture', - id: this.p.id - }); - - this.stream.event.off('post-updated', this.onStreamPostUpdated); + this.decapture(); }); this.reply = () => { diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag index e0cffb62d..7f02dd487 100644 --- a/src/web/app/mobile/tags/timeline-post.tag +++ b/src/web/app/mobile/tags/timeline-post.tag @@ -340,13 +340,24 @@ } }; - this.on('mount', () => { + this.capture = () => { this.stream.send({ type: 'capture', id: this.p.id }); - this.stream.event.on('post-updated', this.onStreamPostUpdated); + }; + + this.decapture = () => { + this.stream.send({ + type: 'decapture', + id: this.p.id + }); + this.stream.event.off('post-updated', this.onStreamPostUpdated); + }; + + this.on('mount', () => { + this.capture(); if (this.p.text) { const tokens = this.p.ast; @@ -369,12 +380,7 @@ }); this.on('unmount', () => { - this.stream.send({ - type: 'decapture', - id: this.p.id - }); - - this.stream.event.off('post-updated', this.onStreamPostUpdated); + this.decapture(); }); this.reply = () => {