Skip to content

Conversation

@PVince81
Copy link
Member

Whenever the old messages are already loading initially when opening a
conversation, a scroll event might call getOldMessages again which would
cancel the previous one.

The initial old messages load is using includeLastKnown=1 while the others use
0. So if it gets cancelled, we will miss the "last known" message as it
won't be included in subsequent calls.

This fix prevents repeated calls to getOldMessages to avoid the above
issue.

See #3825 (comment) for semi-reliable reproduction steps and #3825 (comment) for some information.

The handleScroll method was sometimes calling getOldMessages(false) while we still had getOldMessages(true), which led to having a missing message in the list. Usually the one with the read marker, hence why I discovered it only in the PR above.

With a bit of luck this might also fix #5188 as it will also prevent repeated calls to getOldMessages(false) if scrolling up/down multiple times when at the top of the container.

Whenever the old messages are already loading initially when opening a
conversation, a scroll event might call getOldMessages again which would
cancel the previous one.

The initial old messages load is using includeLastKnown=1 while the others use
0. So if it gets cancelled, we will miss the "last known" message as it
won't be included in subsequent calls.

This fix prevents repeated calls to getOldMessages to avoid the above
issue.

Signed-off-by: Vincent Petry <[email protected]>
@nickvergessen
Copy link
Member

Ay that's what I'm always experiencing

@PVince81 PVince81 requested a review from danxuliu February 18, 2021 16:48
// Make the request
try {
const messages = await request({ token, lastKnownMessageId, includeLastKnown: includeLastKnown ? '1' : '0' })
this.oldMessagesPromise = request({ token, lastKnownMessageId, includeLastKnown: includeLastKnown ? '1' : '0' })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the component is reused, so you need to store this based on token?
Otherwise if you quickly change to 2 unloaded conversations the second one wouldn't load?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or more simply reset the value to null when the token changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you switch to another conversation the call will get cancelled anyway, so you'll then get a new request

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, seems to work

@nickvergessen nickvergessen merged commit 43e85f5 into master Feb 19, 2021
@nickvergessen nickvergessen deleted the bugfix/noid/prevent-double-request-cancel-on-scroll branch February 19, 2021 10:58
@nickvergessen nickvergessen added this to the 💖 Next Major (22) milestone Feb 19, 2021
@nickvergessen
Copy link
Member

Queuing backport for after 11.0.0 is out

@nickvergessen
Copy link
Member

/backport to stable21.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Older messages sometimes missing until full page reload

4 participants