Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfixes: Improve first/last message handling #903

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neiljp
Copy link
Collaborator

@neiljp neiljp commented Jan 31, 2021

This is the result of exploring seeing intermittent cases where the _have_last_message dict had a KeyError in event handling via the new Notice popup.

This PR:

  • improves the handling of this dict so that the logic is more consistent and expected
  • uses the first/last message tracking to avoid hitting the API on trying to scroll beyond the start/end of the message view

This is a partial fix of #428, in particular #428 (comment).

This dict tracks whether the app has the last message in a narrow; this
commits fixes the following issues:
* There are too many narrows to pre-populate the dict, so ensure we use
  `.get` when checking it upon receiving a message event.
* The value for a narrow was set on each get_message call, but the value
  from a call is whether the returned messages contain the last message,
  so use both the previous state (if any) as well as the new state.
Prior to this commit, pressing GO_DOWN at the bottom of a message view
in which there were no more messages would hit the API each time,
looking for newer messages.

With the consistent new-message tracking now present in the model, a new
model accessor then supports determining this state, avoiding scrolling
and fetching newer messages if not required.
Prior to this commit, pressing GO_UP at the top of a message view in
which there were no more messages would hit the API each time, looking
for older messages.

If the oldest message in a narrow is reached, this is now tracked in the
model much like tracking the last message (the API uses
found_[oldest|newest]). A new model accessor then supports determining
this state, avoiding scrolling and fetching older messages if not
required.
@zulipbot zulipbot added the size: M [Automatic label added by zulipbot] label Jan 31, 2021
@neiljp neiljp added bug Something isn't working feedback wanted labels Feb 1, 2021
@neiljp
Copy link
Collaborator Author

neiljp commented Feb 1, 2021

These tests may be fixed by rebasing onto something like #904.

I've run with this branch a little and am slightly concerned that this has or exposes an outstanding issue with movement between eg. stream and topic narrows, but makes it worse since it may limit the scrolling.

Further thoughts welcome!

@zulipbot
Copy link
Member

Heads up @neiljp, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feedback wanted has conflicts size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants