some small UI fixes, disale moderation toggle

pull/1011/head
Gabby Gurdin 2 years ago
parent 19fb4cfbf7
commit dc7029be97

@ -350,12 +350,13 @@ class ChatController extends State<ChatPageWithRoom>
try { try {
await loadTimelineFuture; await loadTimelineFuture;
// #Pangea // #Pangea
if (timeline != null) { final String? targetId =
timeline?.events.firstWhereOrNull((e) => e.isVisibleInGui)?.eventId;
if (targetId != null) {
choreographer.pangeaController.instructions.show( choreographer.pangeaController.instructions.show(
context, context,
InstructionsEnum.clickMessage, InstructionsEnum.clickMessage,
timeline!.events.firstWhereOrNull((e) => e.isVisibleInGui)?.eventId ?? targetId,
'',
true, true,
); );
} }
@ -399,6 +400,16 @@ class ChatController extends State<ChatPageWithRoom>
animateInEventIndex = i; animateInEventIndex = i;
} }
// #Pangea
List<Event> get visibleEvents =>
timeline?.events
.where(
(x) => x.isVisibleInGui,
)
.toList() ??
<Event>[];
// Pangea#
Future<void> _getTimeline({ Future<void> _getTimeline({
String? eventContextId, String? eventContextId,
}) async { }) async {
@ -415,22 +426,15 @@ class ChatController extends State<ChatPageWithRoom>
onInsert: onInsert, onInsert: onInsert,
); );
// #Pangea // #Pangea
List<Event>? messageEvents = if (visibleEvents.length < 10) {
timeline?.events.where((x) => x.type == 'm.room.message').toList();
if (messageEvents != null && messageEvents.length < 10) {
int prevNumEvents = timeline!.events.length; int prevNumEvents = timeline!.events.length;
await requestHistory(); await requestHistory();
messageEvents =
timeline?.events.where((x) => x.type == 'm.room.message').toList();
int numRequests = 0; int numRequests = 0;
while (timeline!.events.length > prevNumEvents && while (timeline!.events.length > prevNumEvents &&
messageEvents!.length < 10 && visibleEvents.length < 10 &&
numRequests <= 5) { numRequests <= 5) {
prevNumEvents = timeline!.events.length; prevNumEvents = timeline!.events.length;
await requestHistory(); await requestHistory();
messageEvents = timeline?.events
.where((x) => x.type == 'm.room.message')
.toList();
numRequests++; numRequests++;
} }
} }

@ -33,6 +33,7 @@ class MessageUnsubscribedCard extends StatelessWidget {
MatrixState.pangeaController.subscriptionController MatrixState.pangeaController.subscriptionController
.showPaywall(context); .showPaywall(context);
} }
MatrixState.pAnyState.closeOverlay();
} }
return Padding( return Padding(

@ -190,31 +190,31 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
), ),
), ),
), ),
Padding( // Padding(
padding: const EdgeInsets.only(left: 16), // padding: const EdgeInsets.only(left: 16),
child: SwitchListTile.adaptive( // child: SwitchListTile.adaptive(
title: Text( // title: Text(
L10n.of(context)!.enableModeration, // L10n.of(context)!.enableModeration,
style: TextStyle( // style: TextStyle(
color: Theme.of(context).colorScheme.secondary, // color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
), // ),
subtitle: Text(L10n.of(context)!.enableModerationDesc), // subtitle: Text(L10n.of(context)!.enableModerationDesc),
secondary: CircleAvatar( // secondary: CircleAvatar(
backgroundColor: // backgroundColor:
Theme.of(context).scaffoldBackgroundColor, // Theme.of(context).scaffoldBackgroundColor,
foregroundColor: // foregroundColor:
Theme.of(context).textTheme.bodyLarge!.color, // Theme.of(context).textTheme.bodyLarge!.color,
child: const Icon(Icons.shield_outlined), // child: const Icon(Icons.shield_outlined),
), // ),
activeColor: AppConfig.activeToggleColor, // activeColor: AppConfig.activeToggleColor,
value: botOptions.safetyModeration, // value: botOptions.safetyModeration,
onChanged: (bool newValue) => updateBotOption(() { // onChanged: (bool newValue) => updateBotOption(() {
botOptions.safetyModeration = newValue; // botOptions.safetyModeration = newValue;
}), // }),
), // ),
), // ),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(32, 16, 0, 0), padding: const EdgeInsets.fromLTRB(32, 16, 0, 0),
child: Text( child: Text(

Loading…
Cancel
Save