forwardMessageOneByOne method

void forwardMessageOneByOne(
  1. String conversationId, {
  2. String? postScript,
  3. bool exitMultiMode = true,
})

逐条转发 exitMultiMode 是否退出多选模式 postScript 转发后的附言 conversationId 转发的目标会话id

Implementation

void forwardMessageOneByOne(
  String conversationId, {
  String? postScript,
  bool exitMultiMode = true,
}) async {
  if (!await haveConnectivity()) {
    return;
  }
  _selectedMessages.removeWhere(
    (element) =>
        element.sendingState == NIMMessageSendingState.failed ||
        element.sendingState == NIMMessageSendingState.sending,
  );
  for (var element in _selectedMessages) {
    forwardMessage(element, conversationId);
  }
  if (postScript?.isNotEmpty == true) {
    ChatMessageRepo.sendTextMessageWithMessageAck(
      conversationId: conversationId,
      text: postScript!,
    ).then((msgSend) {
      if (msgSend.code == ChatMessageRepo.errorInBlackList) {
        ChatMessageRepo.saveTipsMessage(
          conversationId,
          S.of().chatMessageSendFailedByBlackList,
        );
      }
    });
  }
  if (exitMultiMode) {
    isMultiSelected = false;
  }
  notifyListeners();
}