Duplicated group channels with isDistinct as true

const getOrCreateChannel = async () => {
    const userLoggedId = String(userData?.id); // 123
    const partnerUserLoggedId = String(partnerData?.partnerId); // 456
    const members = [userLoggedId, partnerUserLoggedId];
   // lets imagine that we have [123, 456]

      const params = new sendbird.GroupChannelParams();
      params.isDistinct = true;
      params.name = `PartnerChat_Y:${userData?.id}_P:${partnerData?.partnerId}`;
      params.customType = 'Normal chat';
      const groupChannel = await sendbird.GroupChannel.createChannel(params);


      return groupChannel;

This function is called at the moment the user opens the chat.
A new channel will be created with the users [123, 456], note that the userLoggedId is 123.

At this point is all right, but when the second user, 456, log in and opens the chat. A new channel is created because the members’ array has the values [456, 123].

Shouldn’t the flag isDistinct be used to validate this situation?

Expected behavior:

Only one channel be created if the users’ IDs are the same: [123, 456] or [456, 123].

1 Like

Hi @Lucas_Gomes. For both users [123, 456], you need to use isDistinct=true. It will help you to prevent channel duplication.