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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user