mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-03 00:34:11 +01:00
chore: Follow up jump to event
This commit is contained in:
parent
b5364e1619
commit
63a9f9ca90
@ -308,7 +308,6 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||||||
if (event != null) {
|
if (event != null) {
|
||||||
scrollToEventId(event);
|
scrollToEventId(event);
|
||||||
}
|
}
|
||||||
_updateScrollController();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -783,23 +782,22 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||||||
inputFocus.requestFocus();
|
inputFocus.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToEventId(String eventId, {Duration? duration}) async {
|
void scrollToEventId(String eventId) async {
|
||||||
var eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
final eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
||||||
if (eventIndex == -1) {
|
if (eventIndex == -1) {
|
||||||
setState(() {
|
setState(() {
|
||||||
timeline = null;
|
timeline = null;
|
||||||
loadTimelineFuture = _getTimeline(eventId);
|
loadTimelineFuture = _getTimeline(eventId);
|
||||||
});
|
});
|
||||||
await loadTimelineFuture;
|
await loadTimelineFuture;
|
||||||
eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
}
|
scrollToEventId(eventId);
|
||||||
if (!mounted) {
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollController.scrollToIndex(
|
await scrollController.scrollToIndex(
|
||||||
eventIndex,
|
eventIndex,
|
||||||
preferPosition: AutoScrollPosition.middle,
|
preferPosition: AutoScrollPosition.middle,
|
||||||
duration: duration ?? scrollAnimationDuration,
|
|
||||||
);
|
);
|
||||||
_updateScrollController();
|
_updateScrollController();
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,6 @@ class ChatView extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.arrow_upward_outlined),
|
icon: const Icon(Icons.arrow_upward_outlined),
|
||||||
onPressed: () => controller.scrollToEventId(
|
onPressed: () => controller.scrollToEventId(
|
||||||
controller.room.fullyRead,
|
controller.room.fullyRead,
|
||||||
duration: Duration.zero,
|
|
||||||
),
|
),
|
||||||
label: Row(
|
label: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
Loading…
Reference in New Issue
Block a user