From dc7029be9767efff8af8bf303efe7ae89566145b Mon Sep 17 00:00:00 2001 From: Gabby Gurdin Date: Wed, 28 Feb 2024 10:45:32 -0500 Subject: [PATCH] some small UI fixes, disale moderation toggle --- lib/pages/chat/chat.dart | 28 ++++++----- .../chat/message_unsubscribed_card.dart | 1 + .../conversation_bot_settings.dart | 50 +++++++++---------- 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index a7aa744ba..00d9f7304 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -350,12 +350,13 @@ class ChatController extends State try { await loadTimelineFuture; // #Pangea - if (timeline != null) { + final String? targetId = + timeline?.events.firstWhereOrNull((e) => e.isVisibleInGui)?.eventId; + if (targetId != null) { choreographer.pangeaController.instructions.show( context, InstructionsEnum.clickMessage, - timeline!.events.firstWhereOrNull((e) => e.isVisibleInGui)?.eventId ?? - '', + targetId, true, ); } @@ -399,6 +400,16 @@ class ChatController extends State animateInEventIndex = i; } + // #Pangea + List get visibleEvents => + timeline?.events + .where( + (x) => x.isVisibleInGui, + ) + .toList() ?? + []; + // Pangea# + Future _getTimeline({ String? eventContextId, }) async { @@ -415,22 +426,15 @@ class ChatController extends State onInsert: onInsert, ); // #Pangea - List? messageEvents = - timeline?.events.where((x) => x.type == 'm.room.message').toList(); - if (messageEvents != null && messageEvents.length < 10) { + if (visibleEvents.length < 10) { int prevNumEvents = timeline!.events.length; await requestHistory(); - messageEvents = - timeline?.events.where((x) => x.type == 'm.room.message').toList(); int numRequests = 0; while (timeline!.events.length > prevNumEvents && - messageEvents!.length < 10 && + visibleEvents.length < 10 && numRequests <= 5) { prevNumEvents = timeline!.events.length; await requestHistory(); - messageEvents = timeline?.events - .where((x) => x.type == 'm.room.message') - .toList(); numRequests++; } } diff --git a/lib/pangea/widgets/chat/message_unsubscribed_card.dart b/lib/pangea/widgets/chat/message_unsubscribed_card.dart index 8219e2355..2d37328ec 100644 --- a/lib/pangea/widgets/chat/message_unsubscribed_card.dart +++ b/lib/pangea/widgets/chat/message_unsubscribed_card.dart @@ -33,6 +33,7 @@ class MessageUnsubscribedCard extends StatelessWidget { MatrixState.pangeaController.subscriptionController .showPaywall(context); } + MatrixState.pAnyState.closeOverlay(); } return Padding( diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart index a9171a11d..94214c8d2 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart @@ -190,31 +190,31 @@ class ConversationBotSettingsState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only(left: 16), - child: SwitchListTile.adaptive( - title: Text( - L10n.of(context)!.enableModeration, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - subtitle: Text(L10n.of(context)!.enableModerationDesc), - secondary: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: - Theme.of(context).textTheme.bodyLarge!.color, - child: const Icon(Icons.shield_outlined), - ), - activeColor: AppConfig.activeToggleColor, - value: botOptions.safetyModeration, - onChanged: (bool newValue) => updateBotOption(() { - botOptions.safetyModeration = newValue; - }), - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 16), + // child: SwitchListTile.adaptive( + // title: Text( + // L10n.of(context)!.enableModeration, + // style: TextStyle( + // color: Theme.of(context).colorScheme.secondary, + // fontWeight: FontWeight.bold, + // ), + // ), + // subtitle: Text(L10n.of(context)!.enableModerationDesc), + // secondary: CircleAvatar( + // backgroundColor: + // Theme.of(context).scaffoldBackgroundColor, + // foregroundColor: + // Theme.of(context).textTheme.bodyLarge!.color, + // child: const Icon(Icons.shield_outlined), + // ), + // activeColor: AppConfig.activeToggleColor, + // value: botOptions.safetyModeration, + // onChanged: (bool newValue) => updateBotOption(() { + // botOptions.safetyModeration = newValue; + // }), + // ), + // ), Padding( padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), child: Text(