ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
124 stars 111 forks source link

Remove dialog for all users #316

Closed LagoonProject closed 1 week ago

LagoonProject commented 1 week ago

Hi,

1) To delete a group chat dialog I use this piece of code :

ConnectyCube.chat.dialog.delete(dialogId)

But even if the user is the owner, the dialog is removed for the user but remains for the other occupants. Is it possible to delete the dialog for all users with the React Native API ?

2) Side question : is it possible to remove a 1v1 chat dialog from the history ?

Thanks

ccvlad commented 1 week ago

Hi

  1. https://developers.connectycube.com/reactnative/messaging/#remove-dialog

    • If other occupants were offline while a dialog was deleted then they will have to sync dialogs with a server to remove the dialog from UI/DB if needed.
    • If other occupants are online while a dialog is deleting, the owner should send a system message to each occupant to inform them about the delete action. You can pass the deleted dialog ID to inform which dialog has to be removed from UI/DB

      const message = {
      extension: {
        delete_dialog_by_id: dialogId,
      },
      };
      
      ConnectyCube.chat.sendSystemMessage(userId, message);
  2. Yes. In the same way. But a 1v1 chat dialog will be recreated if a user sends a message to his opponent
LagoonProject commented 1 week ago

thanks @ccvlad .

I think that's what I am doing but I don't get the expected result.

User A creates a group chat (type 2), with user B as an occupant => ConnectyCube.chat.dialog.create(params)

User A and User B see the dialog in their dialog list => ConnectyCube.chat.dialog.list({})

Then User A deletes the dialog => ConnectyCube.chat.dialog.delete(dialogId);

User A doesn't see the dialog anymore, but user B still see the dialog in its list when calling => ConnectyCube.chat.dialog.list({})

I'm not sure if I am missing something? The users are connect via firebase and user A appears as the owner of the group chat in the back end panel.

ccvlad commented 1 week ago

@LagoonProject Try to do ConnectyCube.chat.dialog.delete(dialogId, {force: 1}). Unfortunately, we didn't specify the second argument in our docs, but it is in REST API docs, and react-native-connectycube SDK has to support it. Please check with the force = 1 param and let us know about the result. I will update the docs if it works

LagoonProject commented 1 week ago

@ccvlad Thanks so much, it works perfectly, I was missing {force: 1}, also works for type 3.

ccvlad commented 1 week ago

I'm glad to help you! Thank you for your feedback. We will add note about this force = 1 param to our docs for React Native, JS, etc.