feat: Animate in new events in timeline

This commit is contained in:
krille-chan 2023-12-26 20:08:07 +01:00
commit f07aba448d
No known key found for this signature in database
3 changed files with 119 additions and 77 deletions

View file

@ -304,6 +304,13 @@ class ChatController extends State<ChatPageWithRoom> {
Future<void>? loadTimelineFuture;
int? animateInEventIndex;
void onInsert(int i) {
// setState will be called by updateView() anyway
animateInEventIndex = i;
}
Future<void> _getTimeline({
String? eventContextId,
}) async {
@ -317,11 +324,15 @@ class ChatController extends State<ChatPageWithRoom> {
timeline = await room.getTimeline(
onUpdate: updateView,
eventContextId: eventContextId,
onInsert: onInsert,
);
} catch (e, s) {
Logs().w('Unable to load timeline on event ID $eventContextId', e, s);
if (!mounted) return;
timeline = await room.getTimeline(onUpdate: updateView);
timeline = await room.getTimeline(
onUpdate: updateView,
onInsert: onInsert,
);
if (!mounted) return;
if (e is TimeoutException || e is IOException) {
_showScrollUpMaterialBanner(eventContextId!);