fix: get correct lastMessage and latestMessagePreview from channel state #2535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Fix bug of not syncing
lastMessage
andlatestMessage
. Meanwhile thelatestMessage
was correctly taken from the channel state, thelastMessage
was set as any message coming withmessage.new
,message.updated
andmessage.deleted
. Moreover,message.undeleted
andchannel.truncate
were not taken into consideration when settinglastMessage
. Now both are set from thechannel.state
.Another fix is that
latestMessage
was derived fromchannel.state.messages
what is a getter that returns the currently viewed message set in the message list, but not the latest message set. This had to be changed tochannel.state.latestMessages
.I have deprecated
latestMessage
in favor oflatestMessagePreview
because for integrators (and for me) it was unclear how does it differ fromlastMessage
.Finally I have added possibility to customize the possibility of generating latest message preview through new prop
getLatestMessagePreview
toChannelList
andChannelPreview
.