stream-chat-react-native
stream-chat-react-native copied to clipboard
Fix: channel.lastRead() returns null after posting a message
๐ฏ Goal
Preventing deleting last_read of current user.
๐ Implementation details
In current implementation, getLatestMessageReadStatus function manipulates channel.state.read directly and deletes read state of current user.
const readList = channel.state.read;
if (currentUserId) {
delete readList[currentUserId];
}
This causes problems in case of using channel.lastRead() function after posting new message. Because this.state.read[userID] is set undefined after calling getLatestMessageReadStatus.
https://github.com/GetStream/stream-chat-js/blob/master/src/channel.ts#L901
To prevent this, how about copying object to avoid manipulating state directly?
๐จ UI Changes
Nothing changed.
๐งช Testing
channel.lastRead()does not return null after posting new message.
โ๏ธ Checklist
- [x] I have signed the Stream CLA (required)
- [x] PR targets the
developbranch - [x] Documentation is updated
- [x] New code is tested in main example apps, including all possible scenarios
- [x] SampleApp iOS and Android
- [x] Expo iOS and Android
Hey @ohayoyogi, can you please fix the lint issues and push your code? You can run yarn run lint-fix on the root of the project to fix it.
I apologize to forget to lint. Could you review this again?
Thanks for the PR @ohayoyogi
:tada: This PR is included in version 5.30.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: