@@ -63,21 +63,6 @@ class MessageListMessageItem extends MessageListMessageBaseItem {
6363 });
6464}
6565
66- /// Indicates the app is loading more messages at the top.
67- // TODO(#80): or loading at the bottom, by adding a [MessageListDirection.newer]
68- class MessageListLoadingItem extends MessageListItem {
69- final MessageListDirection direction;
70-
71- const MessageListLoadingItem (this .direction);
72- }
73-
74- enum MessageListDirection { older }
75-
76- /// Indicates we've reached the oldest message in the narrow.
77- class MessageListHistoryStartItem extends MessageListItem {
78- const MessageListHistoryStartItem ();
79- }
80-
8166/// The sequence of messages in a message list, and how to display them.
8267///
8368/// This comprises much of the guts of [MessageListView] .
@@ -161,11 +146,6 @@ mixin _MessageSequence {
161146
162147 static int _compareItemToMessageId (MessageListItem item, int messageId) {
163148 switch (item) {
164- case MessageListHistoryStartItem (): return - 1 ;
165- case MessageListLoadingItem ():
166- switch (item.direction) {
167- case MessageListDirection .older: return - 1 ;
168- }
169149 case MessageListRecipientHeaderItem (: var message):
170150 case MessageListDateSeparatorItem (: var message):
171151 if (message.id == null ) return 1 ; // TODO(#1441): test
@@ -328,37 +308,12 @@ mixin _MessageSequence {
328308 showSender: ! canShareSender, isLastInBlock: true ));
329309 }
330310
331- /// Update [items] to include markers at start and end as appropriate.
332- void _updateEndMarkers () {
333- assert (fetched);
334- assert (! (fetchingOlder && fetchOlderCoolingDown));
335- final effectiveFetchingOlder = fetchingOlder || fetchOlderCoolingDown;
336- assert (! (effectiveFetchingOlder && haveOldest));
337- final startMarker = switch ((effectiveFetchingOlder, haveOldest)) {
338- (true , _) => const MessageListLoadingItem (MessageListDirection .older),
339- (_, true ) => const MessageListHistoryStartItem (),
340- (_, _) => null ,
341- };
342- final hasStartMarker = switch (items.firstOrNull) {
343- MessageListLoadingItem () => true ,
344- MessageListHistoryStartItem () => true ,
345- _ => false ,
346- };
347- switch ((startMarker != null , hasStartMarker)) {
348- case (true , true ): items[0 ] = startMarker! ;
349- case (true , _ ): items.addFirst (startMarker! );
350- case (_, true ): items.removeFirst ();
351- case (_, _ ): break ;
352- }
353- }
354-
355311 /// Recompute [items] from scratch, based on [messages] , [contents] , and flags.
356312 void _reprocessAll () {
357313 items.clear ();
358314 for (var i = 0 ; i < messages.length; i++ ) {
359315 _processMessage (i);
360316 }
361- _updateEndMarkers ();
362317 }
363318}
364319
@@ -508,7 +463,6 @@ class MessageListView with ChangeNotifier, _MessageSequence {
508463 }
509464 _fetched = true ;
510465 _haveOldest = result.foundOldest;
511- _updateEndMarkers ();
512466 notifyListeners ();
513467 }
514468
@@ -555,7 +509,6 @@ class MessageListView with ChangeNotifier, _MessageSequence {
555509 || (narrow as TopicNarrow ).with_ == null );
556510 assert (messages.isNotEmpty);
557511 _fetchingOlder = true ;
558- _updateEndMarkers ();
559512 notifyListeners ();
560513 final generation = this .generation;
561514 bool hasFetchError = false ;
@@ -601,13 +554,11 @@ class MessageListView with ChangeNotifier, _MessageSequence {
601554 .wait ().then ((_) {
602555 if (this .generation != generation) return ;
603556 _fetchOlderCoolingDown = false ;
604- _updateEndMarkers ();
605557 notifyListeners ();
606558 }));
607559 } else {
608560 _fetchOlderCooldownBackoffMachine = null ;
609561 }
610- _updateEndMarkers ();
611562 notifyListeners ();
612563 }
613564 }
0 commit comments