ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

Read message status #307

Closed richanshah closed 10 months ago

richanshah commented 1 year ago

@TatankaConCube , For group chat I have observed that if one memeber of that group read the message then sender side it got changed to green tick but other group members have read the message yet, is there any way to handle this?

TatankaConCube commented 1 year ago

do you need to skip reading the message if any other opponent already read it? but in this case, only one user will present in the readIds array and you will not know if other users read the message.

richanshah commented 1 year ago

@TatankaConCube no, u misunderstood it. If possible then only if all group members have read the chats then do a green tick of the message , so if any members has not read message yet then i dont want to do green tick.

richanshah commented 1 year ago

@TatankaConCube let me know the changes require for this feature

TatankaConCube commented 1 year ago

then you need to check if the array readIds of the message contains all items from the array occupantsIds of the dialog.

richanshah commented 1 year ago
bool? containsAllReadIds(List<int>? readIds, List<int?> occupantsIds) {
  if (readIds == null) {
    return false;
  }

  // Filter out the IDs that are not equal to the user's ID and check if all remaining IDs are in occupantsIds.
  final filteredIds = readIds.where((id) => id != controller.cubeUser.id).toList();
  return occupantsIds.every((id) => filteredIds.contains(id));
}

i tried this logic , but its not working as expected

TatankaConCube commented 1 year ago

what do you mean? does the sender receive the read status events from all read users? what issues do you have here?

richanshah commented 1 year ago

containsAllReadIds(message.readIds, controller.occupants.keys.toList()) == true this condition is not getting true , do u think any other changes needed?

TatankaConCube commented 1 year ago

here you delete current user

final filteredIds = readIds.where((id) => id != controller.cubeUser.id).toList();

and here you check if occupants' ids contains all read ids

occupantsIds.every((id) => filteredIds.contains(id))

your filteredIds always doesn't contains the current user and occupantsIds always contain it. I'm right?

richanshah commented 1 year ago

yes i have removed filteredIds concept but still its not updating. so i guess there is something missing

TatankaConCube commented 1 year ago

first of all, compare these two arrays in the log. Do they contain the same IDs?

TatankaConCube commented 1 year ago

then investigate how you add users to the readIds, do you add all users who read the message?

richanshah commented 1 year ago

add users to the readIds, do you add all users who read the message?

its the same logic as per your demo

richanshah commented 1 year ago

first of all, compare these two arrays in the log. Do they contain the same IDs?

yes

richanshah commented 1 year ago

filteredIds= [10909924, 10999317], occupantsIds= [10999317, 10909924, 10909837], readIds = [10909837, 10909924, 10999317]

TatankaConCube commented 1 year ago

and the method every returns false?

richanshah commented 1 year ago

no I dont think this logic has any issue but still its not updating in the ui , if u can try and check in ur demo please let me know if it gets done, i have alredy tried.

TatankaConCube commented 1 year ago

but you said before

containsAllReadIds(message.readIds, controller.occupants.keys.toList()) == true this condition is not getting true

I don't know how to help here, it is your requirements and your app. Here are a lot of reasons why UI is not updating. Our API in this case works as expected (all read packages arrive on the sender side).

richanshah commented 1 year ago

ok will check and if gets resolve will update u

richanshah commented 1 year ago

thanks for help

TatankaConCube commented 10 months ago

no activity for a long time. closing...