fix visual federation bugs
This commit is contained in:
parent
58f964ab66
commit
86ad944bbd
|
@ -10,6 +10,7 @@ import '../hooks/delayed_loading.dart';
|
||||||
import '../hooks/logged_in_action.dart';
|
import '../hooks/logged_in_action.dart';
|
||||||
import '../hooks/memo_future.dart';
|
import '../hooks/memo_future.dart';
|
||||||
import '../hooks/stores.dart';
|
import '../hooks/stores.dart';
|
||||||
|
import '../util/extensions/api.dart';
|
||||||
import '../util/goto.dart';
|
import '../util/goto.dart';
|
||||||
import '../util/intl.dart';
|
import '../util/intl.dart';
|
||||||
import '../util/more_icon.dart';
|
import '../util/more_icon.dart';
|
||||||
|
@ -315,10 +316,11 @@ class _CommunityOverview extends StatelessWidget {
|
||||||
text: '@',
|
text: '@',
|
||||||
style: TextStyle(fontWeight: FontWeight.w200)),
|
style: TextStyle(fontWeight: FontWeight.w200)),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: instanceHost,
|
text: community.originInstanceHost,
|
||||||
style: TextStyle(fontWeight: FontWeight.w600),
|
style: TextStyle(fontWeight: FontWeight.w600),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () => goToInstance(context, instanceHost)),
|
..onTap = () => goToInstance(
|
||||||
|
context, community.originInstanceHost)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||||
|
|
||||||
|
import '../cleanup_url.dart';
|
||||||
|
|
||||||
|
// Extensions to lemmy api objects which give a [.originInstanceHost] getter
|
||||||
|
// allowing for a convenient way of knowing what is the origin of the object
|
||||||
|
// For example if a post on lemmy.ml is federated from lemmygrad.ml then
|
||||||
|
// `post.instanceHost == 'lemmy.ml'
|
||||||
|
// && post.originInstanceHost == 'lemmygrad.ml``
|
||||||
|
|
||||||
|
extension GetInstanceCommunityView on CommunityView {
|
||||||
|
String get originInstanceHost => _extract(actorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension GetInstanceUserView on UserView {
|
||||||
|
String get originInstanceHost => _extract(actorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension GetInstanceCommunityModeratorView on CommunityModeratorView {
|
||||||
|
String get originInstanceHost => _extract(userActorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension GetInstancePostView on PostView {
|
||||||
|
String get originInstanceHost => _extract(apId);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension GetInstanceUser on User {
|
||||||
|
String get originInstanceHost => _extract(actorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension GetInstanceCommentView on CommentView {
|
||||||
|
String get originInstanceHost => _extract(apId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: change it to something more robust? regex?
|
||||||
|
String _extract(String s) => cleanUpUrl(s.split('/')[2]);
|
|
@ -13,6 +13,7 @@ import '../hooks/delayed_loading.dart';
|
||||||
import '../hooks/logged_in_action.dart';
|
import '../hooks/logged_in_action.dart';
|
||||||
import '../pages/full_post.dart';
|
import '../pages/full_post.dart';
|
||||||
import '../url_launcher.dart';
|
import '../url_launcher.dart';
|
||||||
|
import '../util/extensions/api.dart';
|
||||||
import '../util/goto.dart';
|
import '../util/goto.dart';
|
||||||
import '../util/more_icon.dart';
|
import '../util/more_icon.dart';
|
||||||
import 'bottom_modal.dart';
|
import 'bottom_modal.dart';
|
||||||
|
@ -172,11 +173,11 @@ class Post extends HookWidget {
|
||||||
text: '@',
|
text: '@',
|
||||||
style: TextStyle(fontWeight: FontWeight.w300)),
|
style: TextStyle(fontWeight: FontWeight.w300)),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: instanceHost,
|
text: post.originInstanceHost,
|
||||||
style: TextStyle(fontWeight: FontWeight.w600),
|
style: TextStyle(fontWeight: FontWeight.w600),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap =
|
..onTap = () => goToInstance(
|
||||||
() => goToInstance(context, instanceHost)),
|
context, post.originInstanceHost)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||||
import 'package:timeago/timeago.dart' as timeago;
|
import 'package:timeago/timeago.dart' as timeago;
|
||||||
|
|
||||||
import '../hooks/stores.dart';
|
import '../hooks/stores.dart';
|
||||||
|
import '../util/extensions/api.dart';
|
||||||
import '../util/goto.dart';
|
import '../util/goto.dart';
|
||||||
import '../util/intl.dart';
|
import '../util/intl.dart';
|
||||||
import '../util/text_color.dart';
|
import '../util/text_color.dart';
|
||||||
|
@ -221,9 +222,10 @@ class _UserOverview extends HookWidget {
|
||||||
style: theme.textTheme.caption,
|
style: theme.textTheme.caption,
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => goToInstance(context, userView.instanceHost),
|
onTap: () =>
|
||||||
|
goToInstance(context, userView.originInstanceHost),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${userView.instanceHost}',
|
'${userView.originInstanceHost}',
|
||||||
style: theme.textTheme.caption,
|
style: theme.textTheme.caption,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -260,7 +260,7 @@ packages:
|
||||||
name: lemmy_api_client
|
name: lemmy_api_client
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.2"
|
version: "0.8.5"
|
||||||
markdown:
|
markdown:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -43,7 +43,7 @@ dependencies:
|
||||||
# utils
|
# utils
|
||||||
timeago: ^2.0.27
|
timeago: ^2.0.27
|
||||||
fuzzy: <1.0.0
|
fuzzy: <1.0.0
|
||||||
lemmy_api_client: ^0.8.2
|
lemmy_api_client: ^0.8.5
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
Loading…
Reference in New Issue