Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {
int numBuilds = 0;

int recentItemsCount = 0;
int historyItemsCount = 0;
int get historyItemsCount => timeline.events.length - recentItemsCount;

bool firstFrame = true;
bool animatingToBottom = false;

Expand Down Expand Up @@ -104,7 +105,6 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {

this.timeline = timeline;
recentItemsCount = timeline.events.length;
historyItemsCount = timeline.events.length - recentItemsCount;

subscriptions = [
timeline.onEventAdded.stream.listen(onEventAdded),
Expand Down Expand Up @@ -136,8 +136,6 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {

if (index == 0 || index < recentItemsCount) {
recentItemsCount += 1;
} else {
historyItemsCount = timeline.events.length - recentItemsCount;
}

if (index == 0) {
Expand Down Expand Up @@ -182,9 +180,8 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {
void onEventRemoved(int index) {
if (index < recentItemsCount) {
recentItemsCount -= 1;
} else {
historyItemsCount = timeline.events.length - recentItemsCount;
}

var removed = eventKeys.removeAt(index);

assert(timeline.events[index].eventId == removed.$2);
Expand Down Expand Up @@ -262,18 +259,19 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {

animatingToBottom = true;

int lastEvent = recentItemsCount;

controller
.animateTo(controller.position.minScrollExtent,
duration: const Duration(milliseconds: 500),
curve: Curves.easeOutExpo)
.then((value) {
if (recentItemsCount == lastEvent) {
controller.jumpTo(controller.position.minScrollExtent);

.then((_) {
setState(() {
controller.jumpTo(0);
animatingToBottom = false;
}
});
});

setState(() {
recentItemsCount = 0;
});
}

Expand Down Expand Up @@ -554,7 +552,6 @@ class RoomTimelineWidgetViewState extends State<RoomTimelineWidgetView> {

setState(() {
recentItemsCount = index;
historyItemsCount = timeline.events.length - recentItemsCount;
highlightedEventId = timeline.events[index].eventId;
highlightedEventOffstageIndex = index;
highlightedEventOffstageKey = GlobalKey();
Expand Down