sendDocumentMessage method
dynamic
sendDocumentMessage(
- String documentPath,
- String replyMessageId
)
Implementation
sendDocumentMessage(String documentPath, String replyMessageId) async {
if (!availableFeatures.value.isDocumentAttachmentAvailable.checkNull()) {
DialogUtils.showFeatureUnavailable();
return;
}
var busyStatus = !profile.isGroupProfile.checkNull()
? await Mirrorfly.isBusyStatusEnabled()
: false;
if (!busyStatus.checkNull()) {
if (isReplying.value) {
replyMessageId = replyChatMessage.messageId;
}
isReplying(false);
//old method is deprecated Instead of use below new method
/*Mirrorfly.sendDocumentMessage(profile.jid!, documentPath, replyMessageId,topicId: topicId)
.then((value) {
ChatMessageModel chatMessageModel = sendMessageModelFromJson(value);
// chatList.insert(0, chatMessageModel);
scrollToBottom();
updateLastMessage(value);
return chatMessageModel;
});*/
Mirrorfly.sendMessage(
messageParams: MessageParams.document(
toJid: profile.jid.checkNull(),
replyMessageId: replyMessageId,
topicId: topicId,
// metaData: messageMetaData, //#metaData
fileMessageParams: FileMessageParams(file: File(documentPath))),
flyCallback: (response) {
if (response.isSuccess) {
LogMessage.d("document message", response.data.toString());
scrollToBottom();
updateLastMessage(response.data);
} else {
LogMessage.d("sendMessage", response.errorMessage);
showError(response.exception);
}
});
} else {
//show busy status popup
messageObject = MessageObject(
toJid: profile.jid.toString(),
replyMessageId: (isReplying.value) ? replyChatMessage.messageId : "",
messageType: Constants.mText,
file: documentPath);
showBusyStatusAlert(disableBusyChatAndSend);
}
}