Seems to be backwards #451
Closed
0456franco
started this conversation in
General
Replies: 1 comment
-
Hi, The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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 tofalse
. When we are updating the channels subject, there's a part where we check if therecoverState
parameter istrue
.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() || [];
therecoverState
being set totrue
indicates thatprevChannels
would be loading an empty array and iffalse
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 toresetState
would be the correct answer.I hope this makes sense. Please feel free to disagree.
Beta Was this translation helpful? Give feedback.
All reactions