Skip to content

Commit

Permalink
some small UI fixes, disale moderation toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin committed Feb 28, 2024
1 parent 19fb4cf commit dc7029b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 37 deletions.
28 changes: 16 additions & 12 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,13 @@ class ChatController extends State<ChatPageWithRoom>
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,
);
}
Expand Down Expand Up @@ -399,6 +400,16 @@ class ChatController extends State<ChatPageWithRoom>
animateInEventIndex = i;
}

// #Pangea
List<Event> get visibleEvents =>
timeline?.events
.where(
(x) => x.isVisibleInGui,
)
.toList() ??
<Event>[];
// Pangea#

Future<void> _getTimeline({
String? eventContextId,
}) async {
Expand All @@ -415,22 +426,15 @@ class ChatController extends State<ChatPageWithRoom>
onInsert: onInsert,
);
// #Pangea
List<Event>? 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++;
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/pangea/widgets/chat/message_unsubscribed_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MessageUnsubscribedCard extends StatelessWidget {
MatrixState.pangeaController.subscriptionController
.showPaywall(context);
}
MatrixState.pAnyState.closeOverlay();
}

return Padding(
Expand Down
50 changes: 25 additions & 25 deletions lib/pangea/widgets/conversation_bot/conversation_bot_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,31 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
),
),
),
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(
Expand Down

0 comments on commit dc7029b

Please sign in to comment.