-
Notifications
You must be signed in to change notification settings - Fork 79
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: premature channels state consumption in ChannelManager #1466
Conversation
Size Change: +884 B (+0.17%) Total Size: 524 kB
|
This also makes it evident that
Thoughts ? |
}, obj); | ||
|
||
// works exactly the same as lodash.uniqBy | ||
export const uniqBy = <T>(array: T[] | unknown, iteratee: ((item: T) => unknown) | keyof T): T[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the same implementation as in lodash
obviously and it does not use their fast SetCache
, but close enough for such small lists. Still ~ O(n)
.
CLA
Description of the changes, What, Why and How?
There was an unfortunate bug with the pagination logic in the new
ChannelManager
that somehow evaded me in the last PR. The offset was not being calculated properly, particularly in cases where:state.channels
receive updates from something other than pagination (WS events for instance) and it will then contain either broken pagination or duplicate values when actually paginating (for example if a WS event arrives as the query is being executed)setChannels
ispublic
)loadNext()
invocationsFor this purpose, when running the queries we always calculate the offset through
state.channels.length
and we make sure to runstate.getLatestValue()
as late as possible, particularly when there are HTTP calls involved (we can ignore the other instances of this happening).In addition to fixing
loadNext()
, the relevant WS event handlers have also been fixed (ones that run asynchronously) to make sure the most up to date state is always there.Changelog