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