ConnectyCube / connectycube-reactnative-samples

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

Message get duplicates #132

Closed ciamalaeaskan closed 3 years ago

ciamalaeaskan commented 3 years ago

Hi,

I have an issue on message sending process. When i send a message it get duplicates multiple times. Can you please help me to find out why this is happend ?

Please refer the below screenshot.

Thanks. image_2020_10_20T04_54_08_271Z

ccvlad commented 3 years ago

Hi, @ciamalaeaskan

Is the issue reproduce on our Sample Chat (w/o your modifications)? Or is it in your code?

A logs will be helpful.

ciamalaeaskan commented 3 years ago

Yes this issue is our Sample Chat code only.

ccvlad commented 3 years ago

OK. We will check to find the issue and fix. Are there any special steps to reproduce or the problem always present?

ciamalaeaskan commented 3 years ago

No its not on all time. I think its happen when both sender or receiver open chat at a time or open chat with multiple devices. But not sure about this scenario. Can you please give me a solution ASAP ?

ciamalaeaskan commented 3 years ago

And also I want to confirm that this will persist when user is logged in via browser version and Mobile at a time ?

ccvlad commented 3 years ago

No its not on all time. I think its happen when both sender or receiver open chat at a time or open chat with multiple devices. But not sure about this scenario. Can you please give me a solution ASAP ?

Please show your logs. We have to check the duplicate issue there. Or provide steps to reproduce for the issue.

And also I want to confirm that this will persist when user is logged in via browser version and Mobile at a time ?

You will get messages from the same user. Compare users' IDs to know that you've received the message from the same user.

ciamalaeaskan commented 3 years ago

Please show your logs. We have to check the duplicate issue there. Or provide steps to reproduce for the issue.

This is happend when both sender and receiver open and chat each other at a time. And also if the user logged in multiple devices also its happend

And also please confirm duplicate issue will persist also if the sender and receiver chat from browser and app respectively.

ciamalaeaskan commented 3 years ago

Message duplication scenario :

  1. Person1 and Person2 logged in a real devices seperately. And also Person1 has logged in more than one devices
  2. both open their personal chat module and start chatting.
  3. Person1 sending "Hai" to Person2, then Person2 open personal chat page. And reply to Person1
  4. then Person1 get duplicate message ( same message with multiple times)
ccvlad commented 3 years ago

Thanks We will check it and let you know

ciamalaeaskan commented 3 years ago

Hi, @ccvlad

This issue is only pending from our end, Any update on this please?

ccvlad commented 3 years ago

Hi @ciamalaeaskan I have tested our Sample RNChat (user-A and user-B) with Sample Web Chat (User-A) by your steps and have not reproduced the issue with duplicate. Could you provide log from device where the problem exists?

ciamalaeaskan commented 3 years ago

No, for now we are not using web chat. We are having this issue only on Sample RNChat on the real device when chatting each other at the same time.

ccvlad commented 3 years ago

I am not asking you for logs from webapp. You are able to copy logs from the RNChat and paste here (via Metro Bundler / Android Studio / Chrome Debuger)

ciamalaeaskan commented 3 years ago

Now i have attached log file with the demo to reproduce this issue. Please refer the below zip file.

Archive.zip

ccvlad commented 3 years ago

Now i have attached log file with the demo to reproduce this issue. Please refer the below zip file.

Uploading Archive.zip…

It is empty:

Screen Shot 2020-10-28 at 13 37 54
ciamalaeaskan commented 3 years ago

Please check it now

ccvlad commented 3 years ago

A user receives a forwarded message from the same user and it is normal. You can check incoming message by ID and display it if doesn't exist.

...

// init onMessageListener 
ConnectyCube.chat.onMessageListener = this.onMessage;

...

const isMessageExistById = msgId => {
  return messages.some(msg => msg.id === msgId); // messages - list of all current chat's messages
}

const displayMessage = msg => {
  // here a code to display
}

const sendMessage = (dialogJidOrUserId, msg) => {
  const messageId = ConnectyCube.chat.send(dialogJidOrUserId, msg);

  this.displayMessage(msg);

  return messageId;
}

const onMessage = (senderId, msg) => {
  // use for some more conditions:
  // const isPrivateMessage = msg.type === 'chat';
  // const isGroupMessage = msg.type === 'groupchat';
  // const isSelfUser = currentUserId === senderId;
 const isMessageExist = this.isMessageExistById(msg.id)

  if (!isMessageExist) {
    this.displayMessage(msg);
  }
...

FYI:

joy-mollick commented 2 years ago

Message gets duplicates , so many bugs of sample RNChat project !!!!! When you close app without seeing the received messages ,then when you open again ,you will see double double messages of the last unseen messages.