From 7ab92f76bfe09a1bcbbd8019e56dbccf25d6f81c Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 24 Sep 2026 22:46:48 -0400 Subject: [PATCH] fix for janky scrolling when tapping reply with SuperSliverView I don't like this but it does work. --- lib/helpers/hooks/chat_scroll.dart | 43 ++++++++++++++++------------ lib/widgets/room_chat/room_chat.dart | 3 +- 2 files changed, 27 insertions(+), 19 deletions(-) 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) =>