@@ -93,7 +93,7 @@ mixin _MessageSequence {
93
93
///
94
94
/// This may or may not represent all the message history that
95
95
/// conceptually belongs in this message list.
96
- /// That information is expressed in [fetched] and [haveOldest] .
96
+ /// That information is expressed in [fetched] , [haveOldest] , [haveNewest ] .
97
97
///
98
98
/// See also [middleMessage] , an index which divides this list
99
99
/// into a top slice and a bottom slice.
@@ -120,11 +120,19 @@ mixin _MessageSequence {
120
120
121
121
/// Whether we know we have the oldest messages for this narrow.
122
122
///
123
- /// (Currently we always have the newest messages for the narrow,
124
- /// once [fetched] is true, because we start from the newest.)
123
+ /// See also [haveNewest] .
125
124
bool get haveOldest => _haveOldest;
126
125
bool _haveOldest = false ;
127
126
127
+ /// Whether we know we have the newest messages for this narrow.
128
+ ///
129
+ /// (Currently this is always true once [fetched] is true,
130
+ /// because we start from the newest.)
131
+ ///
132
+ /// See also [haveOldest] .
133
+ bool get haveNewest => _haveNewest;
134
+ bool _haveNewest = false ;
135
+
128
136
/// Whether this message list is currently busy when it comes to
129
137
/// fetching more messages.
130
138
///
@@ -157,7 +165,7 @@ mixin _MessageSequence {
157
165
/// before, between, or after the messages.
158
166
///
159
167
/// This information is completely derived from [messages] and
160
- /// the flags [haveOldest] and [busyFetchingMore] .
168
+ /// the flags [haveOldest] , [haveNewest] , and [busyFetchingMore] .
161
169
/// It exists as an optimization, to memoize that computation.
162
170
///
163
171
/// See also [middleItem] , an index which divides this list
@@ -314,6 +322,7 @@ mixin _MessageSequence {
314
322
messages.clear ();
315
323
middleMessage = 0 ;
316
324
_haveOldest = false ;
325
+ _haveNewest = false ;
317
326
_status = FetchingStatus .unstarted;
318
327
_fetchBackoffMachine = null ;
319
328
contents.clear ();
@@ -504,7 +513,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
504
513
Future <void > fetchInitial () async {
505
514
// TODO(#80): fetch from anchor firstUnread, instead of newest
506
515
// TODO(#82): fetch from a given message ID as anchor
507
- assert (! fetched && ! haveOldest && ! busyFetchingMore);
516
+ assert (! fetched && ! haveOldest && ! haveNewest && ! busyFetchingMore);
508
517
assert (messages.isEmpty && contents.isEmpty);
509
518
_setStatus (FetchingStatus .fetchInitial, was: FetchingStatus .unstarted);
510
519
// TODO schedule all this in another isolate
@@ -531,6 +540,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
531
540
// Now [middleMessage] is the last message (the one just added).
532
541
}
533
542
_haveOldest = result.foundOldest;
543
+ _haveNewest = true ; // TODO(#82)
534
544
_setStatus (FetchingStatus .idle, was: FetchingStatus .fetchInitial);
535
545
}
536
546
0 commit comments