1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 15:34:26 +02:00

Improve post stream

- Return all discussion post IDs from API requests which add/remove
posts, so the post stream updates appropriately. Related to #146
- Always unload posts that are two pages away, no matter how fast
you’re scrolling
- Retrieve posts from cache instead of reloading them
- Fix various bugs. Maybe #152, needs confirmation
This commit is contained in:
Toby Zerner
2015-07-06 16:26:27 +09:30
parent 746df7e3ad
commit 5fe88e448e
11 changed files with 93 additions and 128 deletions

View File

@@ -55,20 +55,21 @@ export default function(app) {
app.history.back();
}
}
}
};
Discussion.prototype.renameAction = function() {
var currentTitle = this.title();
var title = prompt('Enter a new title for this discussion:', currentTitle);
const currentTitle = this.title();
const title = prompt('Enter a new title for this discussion:', currentTitle);
if (title && title !== currentTitle) {
this.save({title}).then(discussion => {
if (app.current instanceof DiscussionPage) {
app.current.stream.sync();
this.save({title}).then(() => {
if (app.viewingDiscussion(this)) {
app.current.stream.update();
}
m.redraw();
});
}
}
};
Discussion.prototype.userControls = function(context) {
var items = new ItemList();

View File

@@ -23,10 +23,7 @@ export default function(app) {
function deleteAction() {
this.delete();
// this.discussion().pushAttributes({removedPosts: [this.id()]});
if (app.current instanceof DiscussionPage) {
app.current.stream.removePost(this.id());
}
this.discussion().removePost(this.id());
}
Post.prototype.userControls = function(context) {