0👍
Unfortunately, this is the only way right now. In Pusher ChatKit, every action depends on the current user & the user’s subscription to rooms. A user is not necessarily subscribed to a room s/he is a member of.
It has both pros and cons.
But for now I can say, you can just set the messageLimit: 0
. This will not fetch all messages while you load the page for the first time.
Rather fetch messages when a user clicks on a room to see the messages by using the following method:
currentUser.subscribeToRoom({
roomId: room.id,
hooks: {
onNewMessage: (message) => {
// do something with the message
},
onUserStartedTyping : (user) => {
// do something with the user
},
onUserStoppedTyping : (user) => {
// do something with the user
},
},
messageLimit: 10
});
Source:stackexchange.com