1
0
mirror of https://github.com/flarum/core.git synced 2025-10-17 17:56:14 +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

@@ -85,6 +85,17 @@ class UpdateAction extends SerializeResourceAction
$discussion = $state->discussion;
}
if ($posts = $discussion->getModifiedPosts()) {
$discussion->posts_ids = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
$discussion->posts = array_filter($posts, function ($post) {
return $post->exists;
});
$request->include = array_merge($request->include, ['posts']);
$request->link = array_merge($request->include, ['posts', 'posts.discussion', 'posts.user']);
}
return $discussion;
}
}

View File

@@ -22,13 +22,14 @@ class CreateAction extends BaseCreateAction
* @inheritdoc
*/
public static $include = [
'user' => true
'user' => true,
'discussion' => true
];
/**
* @inheritdoc
*/
public static $link = [];
public static $link = ['discussion.posts'];
/**
* @inheritdoc
@@ -84,6 +85,9 @@ class CreateAction extends BaseCreateAction
);
}
$discussion = $post->discussion;
$discussion->posts_ids = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
return $post;
}
}