Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! TW-1974: Update scroll to message
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Sep 4, 2024
1 parent 7ed8c5b commit 6619426
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -963,15 +963,21 @@ class ChatController extends State<Chat>
return eventIndex + addedHeadItemsInChat;
}

Future<void> scrollToEventId(String eventId, {bool highlight = true}) async {
int _getEventIndex(String eventId) {
final foundEvent =
timeline!.events.firstWhereOrNull((event) => event.eventId == eventId);

final eventIndex = foundEvent == null
? -1
: timeline!.events
.indexWhere((event) => event.eventId == foundEvent.eventId);
: timeline!.events.indexWhere(
(event) => event.eventId == foundEvent.eventId,
);

return eventIndex;
}

Future<void> scrollToEventId(String eventId, {bool highlight = true}) async {
final eventIndex = _getEventIndex(eventId);
if (eventIndex == -1) {
setState(() {
timeline = null;
Expand Down

0 comments on commit 6619426

Please sign in to comment.