Merge pull request #554 from pangeachat/fix-reply-scrolling

Fix reply scrolling
pull/1384/head
ggurdin 1 year ago committed by GitHub
commit 876a5230d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1108,8 +1108,14 @@ class ChatController extends State<ChatPageWithRoom>
inputFocus.requestFocus(); inputFocus.requestFocus();
} }
void scrollToEventId(String eventId) async { void scrollToEventId(
final eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId); String eventId, {
bool highlightEvent = true,
}) async {
final eventIndex = timeline!.events
.where((event) => event.isVisibleInGui)
.toList()
.indexWhere((e) => e.eventId == eventId);
if (eventIndex == -1) { if (eventIndex == -1) {
setState(() { setState(() {
timeline = null; timeline = null;
@ -1125,11 +1131,14 @@ class ChatController extends State<ChatPageWithRoom>
}); });
return; return;
} }
setState(() { if (highlightEvent) {
scrollToEventIdMarker = eventId; setState(() {
}); scrollToEventIdMarker = eventId;
});
}
await scrollController.scrollToIndex( await scrollController.scrollToIndex(
eventIndex, eventIndex + 1,
duration: FluffyThemes.animationDuration,
preferPosition: AutoScrollPosition.middle, preferPosition: AutoScrollPosition.middle,
); );
_updateScrollController(); _updateScrollController();

Loading…
Cancel
Save