updateMessageList method

bool updateMessageList(
  1. List<MessageReceipt> list,
  2. MessageReceipt messageReceipt,
  3. String type
)

Implementation

bool updateMessageList(
    List<MessageReceipt> list, MessageReceipt messageReceipt, String type) {
  bool isMatchFound = false;
  for (int i = 0; i < messageReceiptList.length; i++) {
    if (messageReceiptList[i].sender.uid == messageReceipt.sender.uid) {
      if (type == "read") {
        messageReceiptList[i].deliveredAt ??= messageReceipt.readAt;
        messageReceiptList[i].readAt = messageReceipt.readAt;
      } else {
        messageReceiptList[i].deliveredAt = messageReceipt.deliveredAt;
      }
      update();
      isMatchFound = true;
      break;
    }
  }
  return isMatchFound;
}