mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
chore: Follow up jump to event
This commit is contained in:
parent
51115b8919
commit
cce5900d71
2 changed files with 5 additions and 8 deletions
|
@ -308,7 +308,6 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
if (event != null) {
|
||||
scrollToEventId(event);
|
||||
}
|
||||
_updateScrollController();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -783,23 +782,22 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
inputFocus.requestFocus();
|
||||
}
|
||||
|
||||
void scrollToEventId(String eventId, {Duration? duration}) async {
|
||||
var eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
||||
void scrollToEventId(String eventId) async {
|
||||
final eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
||||
if (eventIndex == -1) {
|
||||
setState(() {
|
||||
timeline = null;
|
||||
loadTimelineFuture = _getTimeline(eventId);
|
||||
});
|
||||
await loadTimelineFuture;
|
||||
eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
||||
}
|
||||
if (!mounted) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
scrollToEventId(eventId);
|
||||
});
|
||||
return;
|
||||
}
|
||||
await scrollController.scrollToIndex(
|
||||
eventIndex,
|
||||
preferPosition: AutoScrollPosition.middle,
|
||||
duration: duration ?? scrollAnimationDuration,
|
||||
);
|
||||
_updateScrollController();
|
||||
}
|
||||
|
|
|
@ -347,7 +347,6 @@ class ChatView extends StatelessWidget {
|
|||
icon: const Icon(Icons.arrow_upward_outlined),
|
||||
onPressed: () => controller.scrollToEventId(
|
||||
controller.room.fullyRead,
|
||||
duration: Duration.zero,
|
||||
),
|
||||
label: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
Loading…
Reference in a new issue