Skip to content

Commit 5e1f267

Browse files
committed
msglist [nfc]: Rename backoff state to share between older/newer
If a fetch in one direction has recently failed, we'll want the backoff to apply to any attempt to fetch in the other direction too; after all, it's the same server. We can also drop the term "cooldown" here, which is effectively redundant with "backoff".
1 parent 2f869c4 commit 5e1f267

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/model/message_list.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ enum FetchingStatus {
7878
/// The model has an active `fetchOlder` request.
7979
fetchOlder,
8080

81-
/// The model is in a backoff period from a failed `fetchOlder` request.
82-
fetchOlderCoolingDown,
81+
/// The model is in a backoff period from a failed request.
82+
backoff,
8383
}
8484

8585
/// The sequence of messages in a message list, and how to display them.
@@ -134,13 +134,13 @@ mixin _MessageSequence {
134134
/// This is true both when the recent request is still outstanding,
135135
/// and when it failed and the backoff from that is still in progress.
136136
bool get busyFetchingMore => switch (_status) {
137-
FetchingStatus.fetchOlder || FetchingStatus.fetchOlderCoolingDown => true,
137+
FetchingStatus.fetchOlder || FetchingStatus.backoff => true,
138138
_ => false,
139139
};
140140

141141
FetchingStatus _status = FetchingStatus.unstarted;
142142

143-
BackoffMachine? _fetchOlderCooldownBackoffMachine;
143+
BackoffMachine? _fetchBackoffMachine;
144144

145145
/// The parsed message contents, as a list parallel to [messages].
146146
///
@@ -315,7 +315,7 @@ mixin _MessageSequence {
315315
middleMessage = 0;
316316
_haveOldest = false;
317317
_status = FetchingStatus.unstarted;
318-
_fetchOlderCooldownBackoffMachine = null;
318+
_fetchBackoffMachine = null;
319319
contents.clear();
320320
items.clear();
321321
middleItem = 0;
@@ -619,17 +619,17 @@ class MessageListView with ChangeNotifier, _MessageSequence {
619619
if (this.generation == generation) {
620620
assert(_status == FetchingStatus.fetchOlder);
621621
if (hasFetchError) {
622-
_status = FetchingStatus.fetchOlderCoolingDown;
623-
unawaited((_fetchOlderCooldownBackoffMachine ??= BackoffMachine())
622+
_status = FetchingStatus.backoff;
623+
unawaited((_fetchBackoffMachine ??= BackoffMachine())
624624
.wait().then((_) {
625625
if (this.generation != generation) return;
626-
assert(_status == FetchingStatus.fetchOlderCoolingDown);
626+
assert(_status == FetchingStatus.backoff);
627627
_status = FetchingStatus.idle;
628628
notifyListeners();
629629
}));
630630
} else {
631631
_status = FetchingStatus.idle;
632-
_fetchOlderCooldownBackoffMachine = null;
632+
_fetchBackoffMachine = null;
633633
}
634634
notifyListeners();
635635
}

0 commit comments

Comments
 (0)