-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: improve channel preview display hooks and long title issue #3002
base: develop
Are you sure you want to change the base?
Conversation
SDK Size
|
}, [channel, channelMemberOnline, client]); | ||
const displayPresence = useMemo(() => { | ||
return getChannelPreviewDisplayPresence(channel, client); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
We shouldn't need this, why is eslint
complaining ? If we do, let's try to fix the hook instead of disabling the rule
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.
It is for the additional channelMemberOnline
dep
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.
That should not be the case, that one was there before too and it was also the dependency of a hook.
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.
Yeah, its weird that it didn't complain before
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.
Regardless, the issue with the dependencies should be fixed; we should not introduce any more of the eslint-disable
comments unless we have a very very good reason to do so
const [latestMessagePreview, setLatestMessagePreview] = useState< | ||
LatestMessagePreview<StreamChatGenerics> | ||
>({ | ||
created_at: '', |
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.
This change should be for the better (since the default state seems very broken anyway), but please check and make sure that we don't have code in the downstream components that depends on this (since it's being removed).
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.
Yeah, I don't see any noticeable bug post this change
); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [channelName, currentUserId, characterLimit, numOfMembers]); | ||
[channelName, characterLimit, currentUserId, members], |
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.
We probably aren't sure that members
will change its reference each time a member is added (for example, it may very well be the fact that it gets mutated rather than copied on write, as we can see in the other hooks).
I would keep both members
and numMembers
here
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.
(for the time being at least, until we convert channel
to be fully reactive)
The goal of the PR is to improve the channel preview display hooks to use
useMemo
instead of a combination ofuseState
anduseEffect
for the calculation that would take an additional render.Also, the title logic for the channel preview is improved for channels that have long names. This was a UI issue that was easily noticeable and looked bad.
I am open to discussion if anything doesn't seem correct here.