mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
Rename discussion.startUser
This commit is contained in:
parent
14885fc0e1
commit
6670605b7c
|
@ -10,7 +10,7 @@ Object.assign(Discussion.prototype, {
|
|||
slug: Model.attribute('slug'),
|
||||
|
||||
startTime: Model.attribute('startTime', Model.transformDate),
|
||||
startUser: Model.hasOne('startUser'),
|
||||
user: Model.hasOne('user'),
|
||||
firstPost: Model.hasOne('firstPost'),
|
||||
|
||||
lastTime: Model.attribute('lastTime', Model.transformDate),
|
||||
|
|
|
@ -87,7 +87,7 @@ export default class DiscussionList extends Component {
|
|||
* @api
|
||||
*/
|
||||
requestParams() {
|
||||
const params = {include: ['startUser', 'lastUser'], filter: {}};
|
||||
const params = {include: ['user', 'lastUser'], filter: {}};
|
||||
|
||||
params.sort = this.sortMap()[this.props.params.sort];
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class DiscussionListItem extends Component {
|
|||
if (retain) return retain;
|
||||
|
||||
const discussion = this.props.discussion;
|
||||
const startUser = discussion.startUser();
|
||||
const user = discussion.user();
|
||||
const isUnread = discussion.isUnread();
|
||||
const isRead = discussion.isRead();
|
||||
const showUnread = !this.showRepliesCount() && isUnread;
|
||||
|
@ -93,14 +93,14 @@ export default class DiscussionListItem extends Component {
|
|||
</a>
|
||||
|
||||
<div className={'DiscussionListItem-content Slidable-content' + (isUnread ? ' unread' : '') + (isRead ? ' read' : '')}>
|
||||
<a href={startUser ? app.route.user(startUser) : '#'}
|
||||
<a href={user ? app.route.user(user) : '#'}
|
||||
className="DiscussionListItem-author"
|
||||
title={extractText(app.translator.trans('core.forum.discussion_list.started_text', {user: startUser, ago: humanTime(discussion.startTime())}))}
|
||||
title={extractText(app.translator.trans('core.forum.discussion_list.started_text', {user: user, ago: humanTime(discussion.startTime())}))}
|
||||
config={function(element) {
|
||||
$(element).tooltip({placement: 'right'});
|
||||
m.route.apply(this, arguments);
|
||||
}}>
|
||||
{avatar(startUser, {title: ''})}
|
||||
{avatar(user, {title: ''})}
|
||||
</a>
|
||||
|
||||
<ul className="DiscussionListItem-badges badges">
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class TerminalPost extends Component {
|
|||
const discussion = this.props.discussion;
|
||||
const lastPost = this.props.lastPost && discussion.repliesCount();
|
||||
|
||||
const user = discussion[lastPost ? 'lastUser' : 'startUser']();
|
||||
const user = discussion[lastPost ? 'lastUser' : 'user']();
|
||||
const time = discussion[lastPost ? 'lastTime' : 'startTime']();
|
||||
|
||||
return (
|
||||
|
|
|
@ -31,7 +31,7 @@ class CreateDiscussionController extends AbstractCreateController
|
|||
*/
|
||||
public $include = [
|
||||
'posts',
|
||||
'startUser',
|
||||
'user',
|
||||
'lastUser',
|
||||
'firstPost',
|
||||
'lastPost'
|
||||
|
|
|
@ -30,7 +30,7 @@ class ListDiscussionsController extends AbstractListController
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public $include = [
|
||||
'startUser',
|
||||
'user',
|
||||
'lastUser',
|
||||
'mostRelevantPost',
|
||||
'mostRelevantPost.user'
|
||||
|
|
|
@ -52,7 +52,7 @@ class ShowDiscussionController extends AbstractShowController
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public $optionalInclude = [
|
||||
'startUser',
|
||||
'user',
|
||||
'lastUser',
|
||||
'firstPost',
|
||||
'lastPost'
|
||||
|
|
|
@ -44,7 +44,7 @@ class BasicDiscussionSerializer extends AbstractSerializer
|
|||
/**
|
||||
* @return \Tobscure\JsonApi\Relationship
|
||||
*/
|
||||
protected function startUser($discussion)
|
||||
protected function user($discussion)
|
||||
{
|
||||
return $this->hasOne($discussion, BasicUserSerializer::class);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ use Flarum\Util\Str;
|
|||
* @property \Illuminate\Database\Eloquent\Collection $comments
|
||||
* @property \Illuminate\Database\Eloquent\Collection $participants
|
||||
* @property Post|null $firstPost
|
||||
* @property User|null $startUser
|
||||
* @property User|null $user
|
||||
* @property Post|null $lastPost
|
||||
* @property User|null $lastUser
|
||||
* @property \Illuminate\Database\Eloquent\Collection $readers
|
||||
|
@ -123,7 +123,7 @@ class Discussion extends AbstractModel
|
|||
$discussion->created_at = Carbon::now();
|
||||
$discussion->user_id = $user->id;
|
||||
|
||||
$discussion->setRelation('startUser', $user);
|
||||
$discussion->setRelation('user', $user);
|
||||
|
||||
$discussion->raise(new Started($discussion));
|
||||
|
||||
|
@ -339,7 +339,7 @@ class Discussion extends AbstractModel
|
|||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function startUser()
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class DiscussionRenamedLogger
|
|||
$blueprint = new DiscussionRenamedBlueprint($post);
|
||||
|
||||
if ($post->exists) {
|
||||
$this->notifications->sync($blueprint, [$event->discussion->startUser]);
|
||||
$this->notifications->sync($blueprint, [$event->discussion->user]);
|
||||
} else {
|
||||
$this->notifications->delete($blueprint);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class UserMetadataUpdater
|
|||
|
||||
private function updateDiscussionsCount(Discussion $discussion)
|
||||
{
|
||||
$user = $discussion->startUser;
|
||||
$user = $discussion->user;
|
||||
|
||||
if ($user && $user->exists) {
|
||||
$user->refreshDiscussionsCount()->save();
|
||||
|
|
Loading…
Reference in New Issue
Block a user