From aba6836bdda87498ee6d0e7e8e14e53e9ef50b45 Mon Sep 17 00:00:00 2001 From: Clark Winkelmann Date: Sun, 22 Aug 2021 00:34:34 +0200 Subject: [PATCH] Replace username with display name in more places (#3040) * Replace username with display name in more places * More readable spread operator and translator user magic --- js/src/forum/utils/UserControls.js | 9 +++++++-- src/Notification/NotificationMailer.php | 2 +- views/frontend/content/discussion.blade.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/src/forum/utils/UserControls.js b/js/src/forum/utils/UserControls.js index 620a88345..675a1291b 100644 --- a/js/src/forum/utils/UserControls.js +++ b/js/src/forum/utils/UserControls.js @@ -124,13 +124,18 @@ export default { * @param {string} type */ showDeletionAlert(user, type) { - const { username, email } = user.data.attributes; const message = { success: 'core.forum.user_controls.delete_success_message', error: 'core.forum.user_controls.delete_error_message', }[type]; - app.alerts.show({ type }, app.translator.trans(message, { username, email })); + app.alerts.show( + { type }, + app.translator.trans(message, { + user, + email: user.email(), + }) + ); }, /** diff --git a/src/Notification/NotificationMailer.php b/src/Notification/NotificationMailer.php index e5308243c..d5bd5dff1 100644 --- a/src/Notification/NotificationMailer.php +++ b/src/Notification/NotificationMailer.php @@ -46,7 +46,7 @@ class NotificationMailer $blueprint->getEmailView(), compact('blueprint', 'user'), function (Message $message) use ($blueprint, $user) { - $message->to($user->email, $user->username) + $message->to($user->email, $user->display_name) ->subject($blueprint->getEmailSubject($this->translator)); } ); diff --git a/views/frontend/content/discussion.blade.php b/views/frontend/content/discussion.blade.php index e96f5bc9d..e9e4ebe13 100644 --- a/views/frontend/content/discussion.blade.php +++ b/views/frontend/content/discussion.blade.php @@ -5,7 +5,7 @@ @foreach ($posts as $post)
relationships->user->data) ? $getResource($post->relationships->user->data) : null; ?> -

{{ $user ? $user->attributes->username : $translator->trans('core.lib.username.deleted_text') }}

+

{{ $user ? $user->attributes->displayName : $translator->trans('core.lib.username.deleted_text') }}

{!! $post->attributes->contentHtml !!}