mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Rename discussion.commentsCount
This commit is contained in:
parent
c3906eabcd
commit
5a6b0fc474
|
@ -18,8 +18,8 @@ Object.assign(Discussion.prototype, {
|
|||
lastPost: Model.hasOne('lastPost'),
|
||||
lastPostNumber: Model.attribute('lastPostNumber'),
|
||||
|
||||
commentsCount: Model.attribute('commentsCount'),
|
||||
repliesCount: computed('commentsCount', commentsCount => Math.max(0, commentsCount - 1)),
|
||||
commentCount: Model.attribute('commentCount'),
|
||||
repliesCount: computed('commentCount', commentCount => Math.max(0, commentCount - 1)),
|
||||
posts: Model.hasMany('posts'),
|
||||
mostRelevantPost: Model.hasOne('mostRelevantPost'),
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class DiscussionSerializer extends BasicDiscussionSerializer
|
|||
$gate = $this->gate->forUser($this->actor);
|
||||
|
||||
$attributes = parent::getDefaultAttributes($discussion) + [
|
||||
'commentsCount' => (int) $discussion->comment_count,
|
||||
'commentCount' => (int) $discussion->comment_count,
|
||||
'participantsCount' => (int) $discussion->participant_count,
|
||||
'startTime' => $this->formatDate($discussion->created_at),
|
||||
'lastTime' => $this->formatDate($discussion->last_posted_at),
|
||||
|
|
|
@ -230,11 +230,11 @@ class Discussion extends AbstractModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Refresh the discussion's comments count.
|
||||
* Refresh the discussion's comment count.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function refreshCommentsCount()
|
||||
public function refreshCommentCount()
|
||||
{
|
||||
$this->comment_count = $this->comments()->count();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class DiscussionMetadataUpdater
|
|||
$discussion = $event->post->discussion;
|
||||
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshCommentCount();
|
||||
$discussion->refreshLastPost();
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->save();
|
||||
|
@ -76,7 +76,7 @@ class DiscussionMetadataUpdater
|
|||
$discussion = $event->post->discussion;
|
||||
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshCommentCount();
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->refreshLastPost();
|
||||
$discussion->save();
|
||||
|
@ -91,7 +91,7 @@ class DiscussionMetadataUpdater
|
|||
$discussion = $post->discussion;
|
||||
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshCommentCount();
|
||||
$discussion->refreshParticipantsCount();
|
||||
|
||||
if ($discussion->last_post_id == $post->id) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user