Skip to content

Commit 70c31c3

Browse files
gnpricechrisbobbe
authored andcommitted
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 5aec54d commit 70c31c3

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
@@ -79,8 +79,8 @@ enum FetchingStatus {
7979
/// The model has an active `fetchOlder` request.
8080
fetchOlder,
8181

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

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

142142
FetchingStatus _status = FetchingStatus.unstarted;
143143

144-
BackoffMachine? _fetchOlderCooldownBackoffMachine;
144+
BackoffMachine? _fetchBackoffMachine;
145145

146146
/// The parsed message contents, as a list parallel to [messages].
147147
///
@@ -316,7 +316,7 @@ mixin _MessageSequence {
316316
middleMessage = 0;
317317
_haveOldest = false;
318318
_status = FetchingStatus.unstarted;
319-
_fetchOlderCooldownBackoffMachine = null;
319+
_fetchBackoffMachine = null;
320320
contents.clear();
321321
items.clear();
322322
middleItem = 0;
@@ -649,17 +649,17 @@ class MessageListView with ChangeNotifier, _MessageSequence {
649649
if (this.generation == generation) {
650650
assert(_status == FetchingStatus.fetchOlder);
651651
if (hasFetchError) {
652-
_status = FetchingStatus.fetchOlderCoolingDown;
653-
unawaited((_fetchOlderCooldownBackoffMachine ??= BackoffMachine())
652+
_status = FetchingStatus.backoff;
653+
unawaited((_fetchBackoffMachine ??= BackoffMachine())
654654
.wait().then((_) {
655655
if (this.generation != generation) return;
656-
assert(_status == FetchingStatus.fetchOlderCoolingDown);
656+
assert(_status == FetchingStatus.backoff);
657657
_status = FetchingStatus.idle;
658658
notifyListeners();
659659
}));
660660
} else {
661661
_status = FetchingStatus.idle;
662-
_fetchOlderCooldownBackoffMachine = null;
662+
_fetchBackoffMachine = null;
663663
}
664664
notifyListeners();
665665
}

0 commit comments

Comments
 (0)