@@ -65,9 +65,11 @@ class MessageListMessageItem extends MessageListMessageBaseItem {
65
65
66
66
/// The status of outstanding or recent fetch requests from a [MessageListView] .
67
67
enum FetchingStatus {
68
- /// The model hasn't successfully completed a `fetchInitial` request
69
- /// (since its last reset, if any).
70
- unfetched,
68
+ /// The model has not made any fetch requests (since its last reset, if any).
69
+ unstarted,
70
+
71
+ /// The model has made a `fetchInitial` request, which hasn't succeeded.
72
+ fetchInitial,
71
73
72
74
/// The model made a successful `fetchInitial` request,
73
75
/// and has no outstanding requests or backoff.
@@ -111,7 +113,10 @@ mixin _MessageSequence {
111
113
///
112
114
/// This allows the UI to distinguish "still working on fetching messages"
113
115
/// from "there are in fact no messages here".
114
- bool get fetched => _status != FetchingStatus .unfetched;
116
+ bool get fetched => switch (_status) {
117
+ FetchingStatus .unstarted || FetchingStatus .fetchInitial => false ,
118
+ _ => true ,
119
+ };
115
120
116
121
/// Whether we know we have the oldest messages for this narrow.
117
122
///
@@ -143,7 +148,7 @@ mixin _MessageSequence {
143
148
/// See also [fetchingOlder] .
144
149
bool get fetchOlderCoolingDown => _status == FetchingStatus .fetchOlderCoolingDown;
145
150
146
- FetchingStatus _status = FetchingStatus .unfetched ;
151
+ FetchingStatus _status = FetchingStatus .unstarted ;
147
152
148
153
BackoffMachine ? _fetchOlderCooldownBackoffMachine;
149
154
@@ -319,7 +324,7 @@ mixin _MessageSequence {
319
324
messages.clear ();
320
325
middleMessage = 0 ;
321
326
_haveOldest = false ;
322
- _status = FetchingStatus .unfetched ;
327
+ _status = FetchingStatus .unstarted ;
323
328
_fetchOlderCooldownBackoffMachine = null ;
324
329
contents.clear ();
325
330
items.clear ();
@@ -504,7 +509,8 @@ class MessageListView with ChangeNotifier, _MessageSequence {
504
509
// TODO(#82): fetch from a given message ID as anchor
505
510
assert (! fetched && ! haveOldest && ! fetchingOlder && ! fetchOlderCoolingDown);
506
511
assert (messages.isEmpty && contents.isEmpty);
507
- assert (_status == FetchingStatus .unfetched);
512
+ assert (_status == FetchingStatus .unstarted);
513
+ _status = FetchingStatus .fetchInitial;
508
514
// TODO schedule all this in another isolate
509
515
final generation = this .generation;
510
516
final result = await getMessages (store.connection,
@@ -528,7 +534,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
528
534
_addMessage (message);
529
535
// Now [middleMessage] is the last message (the one just added).
530
536
}
531
- assert (_status == FetchingStatus .unfetched );
537
+ assert (_status == FetchingStatus .fetchInitial );
532
538
_status = FetchingStatus .idle;
533
539
_haveOldest = result.foundOldest;
534
540
notifyListeners ();
0 commit comments