onReceiveMessageModified method

void onReceiveMessageModified(
  1. V2TimMessage newMessage
)

Callback for receiving message was modified function(V2TimMessage)

Implementation

void onReceiveMessageModified(V2TimMessage newMessage) {
  String conversationID = TencentCloudChatUtils.checkString(newMessage.groupID) ?? TencentCloudChatUtils.checkString(newMessage.userID) ?? "";
  List<V2TimMessage> messageList = getMessageList(key: conversationID);

  // Check if the message list already contains the new message.
  int index = messageList.indexWhere((element) => element.msgID == newMessage.msgID);

  if (index > -1) {
    messageList.replaceRange(index, index + 1, [newMessage]);
    // Update the message list in the data store.
    messageNeedUpdate = newMessage;

    updateMessageList(
      userID: newMessage.userID,
      groupID: newMessage.groupID,
      messageList: messageList,
      disableNotify: true,
    );
  }
}