diff --git a/js/forum/src/utils/post-stream.js b/js/forum/src/utils/post-stream.js index 9299d1209..309adc0d8 100644 --- a/js/forum/src/utils/post-stream.js +++ b/js/forum/src/utils/post-stream.js @@ -131,6 +131,18 @@ export default class PostStream { }); } + sync() { + var discussion = this.discussion; + + var addedPosts = discussion.addedPosts(); + addedPosts && addedPosts.forEach(this.addPostToEnd.bind(this)); + discussion.pushData({links: {addedPosts: null}}); + + var removedPosts = discussion.removedPosts(); + removedPosts && removedPosts.forEach(this.removePost.bind(this)); + discussion.pushData({removedPosts: null}); + } + makeItem(start, end, post) { var item = {start, end} if (post) { diff --git a/js/lib/models/discussion.js b/js/lib/models/discussion.js index 6a5d61bb5..217c8c8c8 100644 --- a/js/lib/models/discussion.js +++ b/js/lib/models/discussion.js @@ -78,8 +78,8 @@ class Discussion extends Model { var title = prompt('Enter a new title for this discussion:', currentTitle); if (title && title !== currentTitle) { this.save({title}).then(discussion => { - if (app.current.discussion && app.current.discussion().id() === discussion.id()) { - discussion.addedPosts().forEach(post => app.current.stream().addPostToEnd(post)); + if (app.current instanceof DiscussionPage) { + app.current.stream().sync(); } m.redraw(); });