The UX for many messaging applications is built so that if one person (User A) starts a 1:1 message with another user (User B), only User A will see the channel until they send a message, at which point, both users can see the channel. Technically, the channel is created as soon as the message window is opened, but only the initiator can see the channel until a message is sent, and then both users can see the channel.
To achieve this sort of functionality, apply this filter in the queryChannels call. As always, some tweaking may be needed to fit your exact use case.
const filters = { $and: [ { type: channel_type }, { members: { $in: [current_user_id] } }, { $or: [ { last_message_at: { $exists: true } }, { created_by_id: current_user_id }, ], }, ], };
Comments
1 comment
This was very helpful! Thanks!
Please sign in to leave a comment.