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