zulip-flutter
zulip-flutter copied to clipboard
msglist: Fetch-older is defeated by a run of 100+ muted messages
I ran into an odd bug yesterday in the iOS app:
- Muted a topic ("zulip.yaml") in the
#api documentationchannel on CZO - In the Flutter app, opened the channel narrow for
#api documentation
Expected: to see the channel feed as usual, just without messages in the topic I muted Actual: I only saw one message! 🙂 The most recent in the channel. And nothing above it saying I'd reached the start of the channel, or that it was still loading more messages:
Diagnosis
I think two things are breaking this:
- When the visible messages occupy much less than a screenful, the
ScrollPhysicsdoesn't allow changing the scroll position, so the user can't trigger a neededfetchOlder. This is happening here because apparently 99 of the 100 messages fromfetchInitialare muted. A simple fix is to useAlwaysScrollableScrollPhysicsfor the message list. - Normally, a
fetchOlderresponse will cause us to do the nextfetchOlderrequest with a different, older message as the "anchor". Here, though, we're sending the samefetchOlderrequest with the same anchor. Why? Because the anchor we request is the oldest visible (non-muted;_messageVisible) message. If thefetchOlderresponse is entirely messages that we don't count as visible, then "the oldest visible message", and therefore the anchor, won't change.