mirror of
https://github.com/flarum/framework.git
synced 2025-05-22 22:59:57 +08:00
API for syncing added/removed posts after a discussion is updated
This commit is contained in:
@ -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) {
|
makeItem(start, end, post) {
|
||||||
var item = {start, end}
|
var item = {start, end}
|
||||||
if (post) {
|
if (post) {
|
||||||
|
@ -78,8 +78,8 @@ class Discussion extends Model {
|
|||||||
var title = prompt('Enter a new title for this discussion:', currentTitle);
|
var title = prompt('Enter a new title for this discussion:', currentTitle);
|
||||||
if (title && title !== currentTitle) {
|
if (title && title !== currentTitle) {
|
||||||
this.save({title}).then(discussion => {
|
this.save({title}).then(discussion => {
|
||||||
if (app.current.discussion && app.current.discussion().id() === discussion.id()) {
|
if (app.current instanceof DiscussionPage) {
|
||||||
discussion.addedPosts().forEach(post => app.current.stream().addPostToEnd(post));
|
app.current.stream().sync();
|
||||||
}
|
}
|
||||||
m.redraw();
|
m.redraw();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user