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

fix: improve __jump_to_message reliability #4554

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Jan 24, 2025

Follow-up to 6a656f9
(#4510).
Partially addresses #4508.
Why partially? Because the bug appears to still happen sometimes.
But this commit should make it more reliable, or at least be a refactor.

This should also improve performance in some cases,
thanks to the removal of setTimeout().

@WofWca WofWca force-pushed the wofwca/fix-jump_to_message-reliability branch from 4832061 to 4701d5d Compare January 24, 2025 14:46
@WofWca WofWca force-pushed the wofwca/fix-jump_to_message-reliability branch 2 times, most recently from e8f3b2e to 6dddd28 Compare January 25, 2025 15:11
@WofWca WofWca force-pushed the wofwca/fix-jump_to_message-reliability branch from 6dddd28 to 4d7b919 Compare January 25, 2025 17:16
@WofWca WofWca force-pushed the wofwca/fix-jump_to_message-reliability branch from 4d7b919 to 321ef27 Compare January 25, 2025 17:17
WofWca added a commit that referenced this pull request Jan 25, 2025
That is, when you jump to a message in a different chat
(e.g. by clicking on a notification, or from message search,
or from a "private reply" quote),
we would momentarily show the new chat scrolled to bottom
prior to jumping to the desired message.

Why this is bad:

- We mark the visible messages as read.
  In this case that would be the last messages in the chat.
  But they weren't actually read, the user did not intend
  to scroll to them.
- Extra layout shifting: not great visually.
- Bad for performance. Let's just load the part of the chat
  that we need right away.

Related:
- #4508
- #4510
- #4554
Copy link
Member

@nicodh nicodh left a comment

Choose a reason for hiding this comment

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

When reviewing this and the whole "jumpToMessage" logic, it seems we should clarify and/or document what is going on (perhaps improve the comment in jumpToMessage in MessageListStore)

We have now:
a function _window._internal_jump_to_message
another function _window._internal_check_jump_to_message
an object maybeJumpToMessageHack which is assigned to window.__internal_jump_to_message_asap which has a property jumpToMessageArgs which holds a addMessageIdToStack

Maybe a list of use cases would help. Ideally some (for now manual) tests, to make sure changes do not break anything?

@WofWca
Copy link
Collaborator Author

WofWca commented Jan 28, 2025

OK, I force-pushed the initial commit to clarify those __internal docs, and pushed another commit on top that adds docs to other jumpToMessage functions.

Copy link
Member

@nicodh nicodh left a comment

Choose a reason for hiding this comment

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

Wow! Very accurate documentation! Thanks for that! Will help a lot in future development!

Tested randomly and so far everything worked as expected.

Follow-up to 6a656f9
(#4510).
Partially addresses #4508.
Why partially? Because the bug appears to still happen sometimes.
But this commit should make it more reliable, or at least be a refactor.

This should also improve performance in some cases,
thanks to the removal of `setTimeout()`.
@WofWca WofWca force-pushed the wofwca/fix-jump_to_message-reliability branch from 2b33c44 to 8754014 Compare January 29, 2025 09:53
@WofWca WofWca merged commit dcaaf7a into main Jan 29, 2025
8 of 9 checks passed
@WofWca WofWca deleted the wofwca/fix-jump_to_message-reliability branch January 29, 2025 09:54
WofWca added a commit that referenced this pull request Jan 31, 2025
That is, when you jump to a message in a different chat
(e.g. by clicking on a notification, or from message search,
or from a "private reply" quote),
we would momentarily show the new chat scrolled to bottom
prior to jumping to the desired message.

Why this is bad:

- We mark the visible messages as read.
  In this case that would be the last messages in the chat.
  But they weren't actually read, the user did not intend
  to scroll to them.
- Extra layout shifting: not great visually.
- Bad for performance. Let's just load the part of the chat
  that we need right away.

Related:
- #4508
- #4510
- #4554
WofWca added a commit that referenced this pull request Jan 31, 2025
That is, when you jump to a message in a different chat
(e.g. by clicking on a notification, or from message search,
or from a "private reply" quote),
we would momentarily show the new chat scrolled to bottom
prior to jumping to the desired message.

Why this is bad:

- We mark the visible messages as read.
  In this case that would be the last messages in the chat.
  But they weren't actually read, the user did not intend
  to scroll to them.
- Extra layout shifting: not great visually.
- Bad for performance. Let's just load the part of the chat
  that we need right away.

Related:
- #4508
- #4510
- #4554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants