Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Seems to be backwards #451

Closed
topmiamisoftware started this conversation in General
Discussion options

Hi all. While working on a stream-chat integration I noticed the following lines in the channel service js file.
const prevChannels = recoverState ? [] : this.channelsSubject.getValue() || []; this.channelsSubject.next([...prevChannels, ...channels]);

In the queryChannels function parameters the recoverState defaults to false. When we are updating the channels subject, there's a part where we check if the recoverState parameter is true.

What I'm pointing out here might sound silly but it's confusing if you're reading the code.

"recovering" the state suggests that the dev. wants to go back to a previous state...

but on this line const prevChannels = recoverState ? [] : this.channelsSubject.getValue() || []; the recoverState being set to true indicates that prevChannels would be loading an empty array and if false it would be going back to the previous state.

This line would make sense if written as such:
const prevChannels = recoverState ? this.channelsSubject.getValue() || [] : [];

Or maybe the developer's true intention here was to reset the State in which case, renaming the recoverState parameter to resetState would be the correct answer.

I hope this makes sense. Please feel free to disagree.

You must be logged in to vote

Replies: 1 comment

Comment options

Hi,

The recoverState flag is an internal flag, not part of the public API. It is used when we recover the state after a reconnection, in those cases, we're rebuilding the whole state.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /