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

@ -27,6 +27,20 @@ class Discussion extends Model {
// }
}
removePost(id) {
const relationships = this.data().relationships;
const posts = relationships && relationships.posts;
if (posts) {
posts.data.some((data, i) => {
if (id === data.id) {
posts.data.splice(i, 1);
return true;
}
});
}
}
unreadCount() {
var user = app.session.user();
if (user && user.readTime() < this.lastTime()) {