onRecvMessageRevokedWithInfo method

void onRecvMessageRevokedWithInfo(
  1. String msgID,
  2. V2TimUserFullInfo operateUser,
  3. String reason
)

Implementation

void onRecvMessageRevokedWithInfo(String msgID, V2TimUserFullInfo operateUser, String reason) async {
  final findRes = await TencentCloudChat.instance.chatSDKInstance.messageSDK.findMessages(msgIds: [msgID]);
  if (findRes.code == 0 && findRes.data != null && findRes.data!.isNotEmpty && findRes.data?.first != null) {
    final V2TimMessage targetMessage = findRes.data!.first;
    targetMessage.status = MessageStatus.V2TIM_MSG_STATUS_LOCAL_REVOKED;
    targetMessage.revokerInfo = operateUser;
    targetMessage.revokeReason = reason;

    String conversationID = TencentCloudChatUtils.checkString(targetMessage.groupID) ?? TencentCloudChatUtils.checkString(targetMessage.userID) ?? "";
    List<V2TimMessage> messageList = getMessageList(key: conversationID);
    // Check if the message list already contains the new message.
    int index = messageList.indexWhere((element) => element.msgID == targetMessage.msgID);
    if (index > -1) {
      messageList.replaceRange(index, index + 1, [targetMessage]);
      // Update the message list in the data store.
      updateMessageList(
        userID: targetMessage.userID,
        groupID: targetMessage.groupID,
        messageList: messageList,
        disableNotify: true,
      );

      messageNeedUpdate = targetMessage;
    }
  }
}