diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-20 13:54:59 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-20 13:55:04 +0900 |
| commit | 0610acbf6eef11a9a85cc35851150cb3cc072785 (patch) | |
| tree | 8d53c24c38ba7de3c64c4ff780c7f35d828ef554 /src/web/app/desktop | |
| parent | Merge pull request #301 from syuilo/greenkeeper/gulp-uglify-2.1.1 (diff) | |
| download | misskey-0610acbf6eef11a9a85cc35851150cb3cc072785.tar.gz misskey-0610acbf6eef11a9a85cc35851150cb3cc072785.tar.bz2 misskey-0610acbf6eef11a9a85cc35851150cb3cc072785.zip | |
#302
Diffstat (limited to 'src/web/app/desktop')
| -rw-r--r-- | src/web/app/desktop/tags/timeline-post.tag | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag index 8c3b7c9be1..07cc665674 100644 --- a/src/web/app/desktop/tags/timeline-post.tag +++ b/src/web/app/desktop/tags/timeline-post.tag @@ -40,7 +40,7 @@ <div class="media" if={ p.media }> <mk-images-viewer images={ p.media }></mk-images-viewer> </div> - <mk-poll if={ p.poll } post={ p }></mk-poll> + <mk-poll if={ p.poll } post={ p } ref="pollViewer"></mk-poll> <div class="repost" if={ p.repost }><i class="fa fa-quote-right fa-flip-horizontal"></i> <mk-post-preview class="repost" post={ p.repost }></mk-post-preview> </div> @@ -332,6 +332,7 @@ import dateStringify from '../../common/scripts/date-stringify'; this.mixin('api'); + this.mixin('stream'); this.mixin('user-preview'); this.isDetailOpened = false; @@ -347,19 +348,30 @@ this.set(this.opts.post); - this.refresh = () => { - this.api('posts/show', { - post_id: this.post.id - }).then(post => { - this.set(post); - this.update(); - if (this.refs.reactionsViewer) this.refs.reactionsViewer.update({ - post - }); + this.refresh = post => { + this.set(post); + this.update(); + if (this.refs.reactionsViewer) this.refs.reactionsViewer.update({ + post }); + if (this.refs.pollViewer) this.refs.pollViewer.init(post); + }; + + this.onStreamPostUpdated = data => { + const post = data.post; + if (post.id == this.p.id) { + this.refresh(post); + } }; this.on('mount', () => { + this.stream.send({ + type: 'capture', + id: this.p.id + }); + + this.stream.event.on('post-updated', this.onStreamPostUpdated); + if (this.p.text) { const tokens = this.p.ast; @@ -380,6 +392,15 @@ } }); + this.on('unmount', () => { + this.stream.send({ + type: 'decapture', + id: this.p.id + }); + + this.stream.event.off('post-updated', this.onStreamPostUpdated); + }); + this.reply = () => { riot.mount(document.body.appendChild(document.createElement('mk-post-form-window')), { reply: this.p @@ -395,8 +416,7 @@ this.react = () => { riot.mount(document.body.appendChild(document.createElement('mk-reaction-picker')), { source: this.refs.reactButton, - post: this.p, - cb: this.refresh + post: this.p }); }; |