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

perf: improve jumpToMessage speed #4584

Merged
merged 4 commits into from
Jan 31, 2025
Merged

perf: improve jumpToMessage speed #4584

merged 4 commits into from
Jan 31, 2025

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Jan 29, 2025

  • refactor: remove outdated comment
  • refactor: simplify jumpToMessage
  • refactor: simplify jumpToMessage again
  • perf: improve jumpToMessage speed

@WofWca WofWca force-pushed the wofwca/perf-jumpToMessage-2 branch from 8bf2614 to eb92265 Compare January 29, 2025 12:43
@WofWca WofWca marked this pull request as ready for review January 29, 2025 12:43
@WofWca WofWca force-pushed the wofwca/perf-jumpToMessage-2 branch from eb92265 to 24f4f32 Compare January 31, 2025 10:44
// so we know the chatId in advance.
// However, let's keep the code that supports arbitrary chatId,
// which can be "enabled" by setting `chatIdPreset = undefined`.
const chatIdPreset: number | undefined = this.chatId
Copy link
Member

Choose a reason for hiding this comment

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

You mean that there is (should?) be no use case at the moment, where this.chatId is not set and/or is different from the jumpToMessage.chatId ?
Since later we log an error if isMessageInCurrentChat is false.
If so, you leave the code since it might be useful if we extend the usage later or just as a fallback if this function is called "wrongly" for a message that belongs not to current chat?

Copy link
Collaborator Author

@WofWca WofWca Jan 31, 2025

Choose a reason for hiding this comment

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

You mean that there is (should?) be no use case at the moment, where this.chatId is not set and/or is different from the jumpToMessage.chatId ?

Unless there is a bug that I missed, currently we never call this jumpToMessage with a msgId that belongs to a chat whose ID is not this.chatId.

Since later we log an error if isMessageInCurrentChat is false.

Yes, that would be unexpected.

If so, you leave the code since it might be useful if we extend the usage later or just as a fallback if this function is called "wrongly" for a message that belongs not to current chat?

I guess it's for the former case mostly.
But maybe also for the latter, because I am not sure if we'd want to just throw an error instead. In this regard I kept things as they were before me.

@WofWca WofWca merged commit 28aa40a into main Jan 31, 2025
12 checks passed
@WofWca WofWca deleted the wofwca/perf-jumpToMessage-2 branch January 31, 2025 12:35
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