Add trailing @originInstanceHost to comments/community list
This commit is contained in:
parent
81ea5c051b
commit
e82c1fa576
|
@ -9,6 +9,7 @@ import 'package:lemmy_api_client/lemmy_api_client.dart';
|
|||
import '../hooks/delayed_loading.dart';
|
||||
import '../hooks/memo_future.dart';
|
||||
import '../hooks/stores.dart';
|
||||
import '../util/extensions/api.dart';
|
||||
import '../util/extensions/iterators.dart';
|
||||
import '../util/goto.dart';
|
||||
import '../util/text_color.dart';
|
||||
|
@ -205,7 +206,9 @@ class CommunitiesTab extends HookWidget {
|
|||
else
|
||||
SizedBox(width: 30),
|
||||
SizedBox(width: 10),
|
||||
Text('!${comm.communityName}'),
|
||||
Text(
|
||||
'''!${comm.communityName}${comm.isLocal ? '' : '@${comm.originInstanceHost}'}''',
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: _CommunitySubscribeToggle(
|
||||
|
|
|
@ -8,28 +8,31 @@ import '../cleanup_url.dart';
|
|||
// `post.instanceHost == 'lemmy.ml'
|
||||
// && post.originInstanceHost == 'lemmygrad.ml``
|
||||
|
||||
// [.isLocal] is true iff `.originInstanceHost == .instanceHost`
|
||||
|
||||
extension GetInstanceCommunityView on CommunityView {
|
||||
String get originInstanceHost => _extract(actorId);
|
||||
bool get isLocal => originInstanceHost == instanceHost;
|
||||
}
|
||||
|
||||
extension GetInstanceUserView on UserView {
|
||||
String get originInstanceHost => _extract(actorId);
|
||||
bool get isLocal => originInstanceHost == instanceHost;
|
||||
}
|
||||
|
||||
extension GetInstanceCommunityModeratorView on CommunityModeratorView {
|
||||
String get originInstanceHost => _extract(userActorId);
|
||||
extension GetInstanceCommunityFollowerView on CommunityFollowerView {
|
||||
String get originInstanceHost => _extract(communityActorId);
|
||||
bool get isLocal => originInstanceHost == instanceHost;
|
||||
}
|
||||
|
||||
extension GetInstancePostView on PostView {
|
||||
String get originInstanceHost => _extract(apId);
|
||||
}
|
||||
|
||||
extension GetInstanceUser on User {
|
||||
String get originInstanceHost => _extract(actorId);
|
||||
bool get isLocal => originInstanceHost == instanceHost;
|
||||
}
|
||||
|
||||
extension GetInstanceCommentView on CommentView {
|
||||
String get originInstanceHost => _extract(apId);
|
||||
bool get isLocal => originInstanceHost == instanceHost;
|
||||
}
|
||||
|
||||
// TODO: change it to something more robust? regex?
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:url_launcher/url_launcher.dart' as ul;
|
|||
import '../comment_tree.dart';
|
||||
import '../hooks/delayed_loading.dart';
|
||||
import '../hooks/logged_in_action.dart';
|
||||
import '../util/extensions/api.dart';
|
||||
import '../util/goto.dart';
|
||||
import '../util/intl.dart';
|
||||
import '../util/text_color.dart';
|
||||
|
@ -191,12 +192,18 @@ class Comment extends HookWidget {
|
|||
|
||||
// decide which username to use
|
||||
final username = () {
|
||||
if (comment.creatorPreferredUsername != null &&
|
||||
comment.creatorPreferredUsername != '') {
|
||||
return comment.creatorPreferredUsername;
|
||||
} else {
|
||||
return '@${comment.creatorName}';
|
||||
}
|
||||
final name = () {
|
||||
if (comment.creatorPreferredUsername != null &&
|
||||
comment.creatorPreferredUsername != '') {
|
||||
return comment.creatorPreferredUsername;
|
||||
} else {
|
||||
return '@${comment.creatorName}';
|
||||
}
|
||||
}();
|
||||
|
||||
if (!comment.isLocal) return '$name@${comment.originInstanceHost}';
|
||||
|
||||
return name;
|
||||
}();
|
||||
|
||||
final body = () {
|
||||
|
|
Loading…
Reference in New Issue