Skip to content

[Optimization]: Optimize unnecessary call to discord's API when scrolling to the end of channel history #40

@roobscoob

Description

@roobscoob

When scrolling to the end of channel history, you can see logs similar to the ones below:

Discord: get_messages: GetMessages { search_filter: None, limit: Some(50) }
Discord: get_messages: GetMessages { search_filter: Some(Before(MessageId(InnerId(1307281599834099833)))), limit: Some(50) }
Discord gave us 50 messages (out of 50)
Discord: get_messages: GetMessages { search_filter: Some(Before(MessageId(InnerId(1307256815993491477)))), limit: Some(50) }
Discord gave us 43 messages (out of 50)
Discord: get_messages: GetMessages { search_filter: Some(Before(MessageId(InnerId(1307138812673265764)))), limit: Some(50) }
Discord gave us 0 messages (out of 50)

Here, the last call to discord (GetMessages { search_filter: Some(Before(MessageId(InnerId(1307138812673265764)))), limit: Some(50) }), is entirely unnecessary as the previous call returned 43 items (less then the requested 50), meaning the channel reached it's end. Ideally the app would not need to make this call.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions