Skip to content

Commit d831280

Browse files
gnpricechrisbobbe
authored andcommitted
msglist [nfc]: Say we'll show "loading" even when fetch is at other end
This is NFC ultimately because we currently only ever fetch, or show loading indicators, at one end of the message list, namely the start. When we do start supporting a message list in the middle of history, though (#82), and consequently loading newer as well as older messages, my conclusion after thinking it through is that we'll want a "busy fetching" state at one end to mean we show a loading indicator at the other end too, if it still has more to be fetched. This would look weird if the user actually saw both at the same time -- but that shouldn't happen, because if both ends (or even either end) is still open then the original fetch should have found plenty of messages to separate them, many screenfuls' worth. And conversely, if the user does kick off a fetch at one end and then scroll swiftly to the other end and witness how that appears, we want to show them a "loading" sign. The situation is exactly like if they'd had a fetch attempt on that same end and we were backing off from failure: there's no fetch right now, but even though a fetch is needed (because the user is looking at the incomplete end of the known history), the app will hold off from starting one right now. Declining to start a fetch when one is needed means effectively that the loading is busy.
1 parent debe99e commit d831280

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/widgets/message_list.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,21 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
725725
}
726726

727727
Widget _buildStartCap() {
728-
// These assertions are invariants of [MessageListView].
728+
// If we're done fetching older messages, show that.
729+
// Else if we're busy with fetching, then show a loading indicator.
730+
//
731+
// This applies even if the fetch is over, but failed, and we're still
732+
// in backoff from it; and even if the fetch is/was for the other direction.
733+
// The loading indicator really means "busy, working on it"; and that's the
734+
// right summary even if the fetch is internally queued behind other work.
735+
736+
// (This assertion is an invariant of [MessageListView].)
729737
assert(!(model.fetchingOlder && model.fetchOlderCoolingDown));
730-
final effectiveFetchingOlder =
738+
final busyFetchingMore =
731739
model.fetchingOlder || model.fetchOlderCoolingDown;
732-
assert(!(model.haveOldest && effectiveFetchingOlder));
733-
return switch ((effectiveFetchingOlder, model.haveOldest)) {
734-
(true, _) => const _MessageListLoadingMore(),
735-
(_, true) => const _MessageListHistoryStart(),
736-
(_, _) => const SizedBox.shrink(),
737-
};
740+
return model.haveOldest ? const _MessageListHistoryStart()
741+
: busyFetchingMore ? const _MessageListLoadingMore()
742+
: const SizedBox.shrink();
738743
}
739744

740745
Widget _buildEndCap() {

0 commit comments

Comments
 (0)