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';
      params.addUserIds(members);
      const groupChannel = await sendbird.GroupChannel.createChannel(params);

      updateNotificationBadgeCount(groupChannel.unreadMessageCount);
      registerUnreadCountHandler(groupChannel);
      setChannel(groupChannel);

      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