How to redirect a user to a specific conversation?


#1

hello !!! I work on an application including the functionality of the chat. I would like to redirect the user to a specific conversation if createConversation(distinctByParticipants=true) return error as conversation with the same chat room exists.


#2

You should use getConversations() as mentioned in another thread. Normally you should maintain a hash map or array map locally for all conversations of a user.

Otherwise you can simply do this, to match participants for 50 conversations of the current user.

## assume all participants are in an array called chatUsers
skygearChat.getConversations().then(function (conversation) {
  if(chatUsers.every(user => conversation.participants.includes(user))) {
    # do the logic to show your conversation
  }
});

#3

without lying to you, I do not find myself. I’m waiting if there will be a follow up to this request https://github.com/SkygearIO/features/issues/118


#4

thank you for the assistance, I solve the problem. thank you.