Fix display names

This commit is contained in:
shilangyu 2021-01-27 20:11:36 +00:00
parent fa1243f9d9
commit dd15ebb2c0
4 changed files with 13 additions and 16 deletions

View File

@ -26,18 +26,18 @@ extension GetOriginInstanceCommentView on Comment {
String _extract(String url) => urlHost(url);
extension DisplayName on UserSafe {
extension DisplayNames on UserSafe {
String get displayName {
final name = () {
if (preferredUsername != null && preferredUsername != '') {
return preferredUsername;
} else {
return '@${this.name}';
}
}();
if (preferredUsername != null && preferredUsername != '') {
return preferredUsername;
}
if (!local) return '$name@$originInstanceHost';
return '@$name';
}
return name;
String get originDisplayName {
if (!local) return '$displayName@$originInstanceHost';
return displayName;
}
}

View File

@ -215,9 +215,6 @@ class CommentWidget extends HookWidget {
delayedVoting.cancel();
}
// decide which username to use
final username = comment.creator.displayName;
final body = () {
if (isDeleted.value) {
return const Flexible(
@ -363,7 +360,7 @@ class CommentWidget extends HookWidget {
InkWell(
onTap: () => goToUser.byId(
context, comment.instanceHost, comment.creator.id),
child: Text(username,
child: Text(comment.creator.originDisplayName,
style: TextStyle(
color: Theme.of(context).accentColor,
)),

View File

@ -206,7 +206,7 @@ class PostWidget extends HookWidget {
style:
TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text: ' ${post.creator.displayName}',
text: ' ${post.creator.originDisplayName}',
style: const TextStyle(
fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()

View File

@ -205,7 +205,7 @@ class _UserOverview extends HookWidget {
padding: EdgeInsets.only(
top: userView.user.avatar == null ? 10 : 0),
child: Text(
userView.user.preferredUsername ?? userView.user.name,
userView.user.displayName,
style: theme.textTheme.headline6,
),
),