diff --git a/lib/helpers/hooks/chat_scroll.dart b/lib/helpers/hooks/chat_scroll.dart index 4253aee..efc023e 100644 --- a/lib/helpers/hooks/chat_scroll.dart +++ b/lib/helpers/hooks/chat_scroll.dart @@ -92,27 +92,34 @@ final class ChatScroll({ ); if (historyIndex != -1) { - historyListController.value.animateToItem( - index: historyIndex, - scrollController: scrollController, - alignment: 0.5, - duration: (_) => .new(milliseconds: 700), - curve: (_) => Curves.easeInOut, + // TODO: Replace SuperSliverView because of the bug that requires this: #94 + // ignore: invalid_use_of_visible_for_testing_member + final offset = historyListController.value.getOffsetToReveal( + historyIndex, + 0.5, ); - return; - } - - final liveIndex = split.live.indexWhere((item) => id(item) == itemId); - - if (liveIndex != -1) { - liveListController.value.animateToItem( - index: liveIndex, - scrollController: scrollController, - alignment: 0.5, - duration: (_) => .new(milliseconds: 700), - curve: (_) => Curves.easeInOut, + await scrollController.animateTo( + offset, + duration: const Duration(milliseconds: 700), + curve: Curves.easeInOut, ); + } else { + final liveIndex = split.live.indexWhere((item) => id(item) == itemId); + + if (liveIndex != -1) { + // ignore: invalid_use_of_visible_for_testing_member + final offset = liveListController.value.getOffsetToReveal( + liveIndex, + 0.5, + ); + + await scrollController.animateTo( + offset, + duration: const Duration(milliseconds: 700), + curve: Curves.easeInOut, + ); + } } } diff --git a/lib/widgets/room_chat/room_chat.dart b/lib/widgets/room_chat/room_chat.dart index 05413d6..951d9e3 100644 --- a/lib/widgets/room_chat/room_chat.dart +++ b/lib/widgets/room_chat/room_chat.dart @@ -95,10 +95,11 @@ final class const RoomChat({ Future jumpToId(String eventId) async { highlightedEvent.value = eventId; - await scroll.jumpToId(eventId); + final jump = scroll.jumpToId(eventId); await Future.delayed(.new(seconds: 1), () { if (highlightedEvent.value == eventId) highlightedEvent.value = null; }); + await jump; } IList getEventOptions(Event event) =>