From 99b16d056b95b87efc4007b84619a4af950671b4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 21 Mar 2017 18:26:11 +0900 Subject: [PATCH] [Client] Fix bug --- package.json | 2 +- src/web/app/desktop/tags/timeline-post.tag | 18 ++++++++++++------ src/web/app/mobile/tags/timeline-post.tag | 18 ++++++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 89e0d0301..a7ea09c35 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.1410", + "version": "0.0.1413", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag index 3961d5a5c..4c07be6c8 100644 --- a/src/web/app/desktop/tags/timeline-post.tag +++ b/src/web/app/desktop/tags/timeline-post.tag @@ -364,24 +364,29 @@ } }; - this.capture = () => { + this.onStreamConnected = () => { + this.capture(); + }; + + this.capture = withHandler => { this.stream.send({ type: 'capture', id: this.post.id }); - this.stream.on('post-updated', this.onStreamPostUpdated); + if (withHandler) this.stream.on('post-updated', this.onStreamPostUpdated); }; - this.decapture = () => { + this.decapture = withHandler => { this.stream.send({ type: 'decapture', id: this.post.id }); - this.stream.off('post-updated', this.onStreamPostUpdated); + if (withHandler) this.stream.off('post-updated', this.onStreamPostUpdated); }; this.on('mount', () => { - this.capture(); + this.capture(true); + this.stream.on('_connected_', this.onStreamConnected); if (this.p.text) { const tokens = this.p.ast; @@ -404,7 +409,8 @@ }); this.on('unmount', () => { - this.decapture(); + this.decapture(true); + this.stream.off('_connected_', this.onStreamConnected); }); this.reply = () => { diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag index 855d7ff91..6af909ba9 100644 --- a/src/web/app/mobile/tags/timeline-post.tag +++ b/src/web/app/mobile/tags/timeline-post.tag @@ -340,24 +340,29 @@ } }; - this.capture = () => { + this.onStreamConnected = () => { + this.capture(); + }; + + this.capture = withHandler => { this.stream.send({ type: 'capture', id: this.post.id }); - this.stream.on('post-updated', this.onStreamPostUpdated); + if (withHandler) this.stream.on('post-updated', this.onStreamPostUpdated); }; - this.decapture = () => { + this.decapture = withHandler => { this.stream.send({ type: 'decapture', id: this.post.id }); - this.stream.off('post-updated', this.onStreamPostUpdated); + if (withHandler) this.stream.off('post-updated', this.onStreamPostUpdated); }; this.on('mount', () => { - this.capture(); + this.capture(true); + this.stream.on('_connected_', this.onStreamConnected); if (this.p.text) { const tokens = this.p.ast; @@ -380,7 +385,8 @@ }); this.on('unmount', () => { - this.decapture(); + this.decapture(true); + this.stream.off('_connected_', this.onStreamConnected); }); this.reply = () => {