Example Code Repository with New createGroupChannelCollection or createMessageCollection?

The only code samples I’ve found in Sendbird’s repository with these new functions (and subsequent setup) just have comments in the body like:

// Do something here

i.e. sendbird-javascript-samples/migration.ts at 0ef7e5fa32bd2ca213708ebe566b67f775bf8596 · sendbird/sendbird-javascript-samples · GitHub

and

Is there anywhere where I can see an example implementation, specifically for onApiResult for the MessageCollection, the rest I can try and implement through trial and error I suppose.

Do these newer collections (and their event handlers) essentially replace ChannelHandler? In some old sample code (and our current codebase) I see that ChannelHandler is used in both the Channels and Chat screens - can we safely replace these with a ChannelCollection and MessageCollection?

Another question in general for all the event handlers like onMessagesAdded, onChannelsAdded, I assume in the callback the respective messages and channels are only the incoming added channels, and not the entire channels right? So it’s best to work with a sort of channel map and add, update, and remove as necessary.

It’s also unclear to me at which moments we should completely invalidate our cached copies of the channels and or messages (if ever) can I ‘trust’ that Sendbird is storing everything in AsyncStorage correctly?

Thanks

Chris

Furthermore, is it advisable to immediately create a MessageCollection per channel? Or use it only while we are in the chat window for a given channel? I would assume the additional async storage entries wouldn’t cause any performance issues…

Thanks,

Chris

Hi @fullStackChris - thanks for reaching out!

Here are some of the sample codes. Please let me know if these are helpful.

https://github.com/sendbird/react-native-samples/blob/main/samples/chat-typescript/src/domain/channel/hooks/useGroupChannelMessageCollection.ts

https://github.com/sendbird/react-native-samples/blob/main/scripts/__template__sample/typescript/src/domain/channel/hooks/useMessageCollection.ts

1 Like

Thanks for this. I’ve slowly converted everything in our app to the new local storage method, the only thing remaining I mentioned is having trouble with simultaneously storing all messages in the redux store, but it appears to be stored at the local storage (sendbird’s implementation), that chats are retrieved per channel just fine.

Thanks for the update @fullStackChris. Please let you know if you have any further questions/issues.