diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index d90507e26..ac970f844 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -949,13 +949,23 @@ void ChatForm::SendMessageStr(QString msg) else rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg); - auto* offMsgEngine = getOfflineMsgEngine(); - Nexus::getProfile()->getHistory()->addNewMessage(f->getToxId().publicKey, qt_msg_hist, - Core::getInstance()->getSelfId().publicKey, timestamp, status, Core::getInstance()->getUsername(), - [offMsgEngine,rec,ma](int64_t id) + + Profile* profile = Nexus::getProfile(); + if (profile->isHistoryEnabled()) { - offMsgEngine->registerReceipt(rec, id, ma); - }); + auto* offMsgEngine = getOfflineMsgEngine(); + profile->getHistory()->addNewMessage(f->getToxId().publicKey, qt_msg_hist, + Core::getInstance()->getSelfId().publicKey, timestamp, status, Core::getInstance()->getUsername(), + [offMsgEngine,rec,ma](int64_t id) + { + offMsgEngine->registerReceipt(rec, id, ma); + }); + } + else + { + /// TODO: Make faux-offline messaging work partially with the history disabled + ma->markAsSent(QDateTime::currentDateTime()); + } msgEdit->setLastMessage(msg); //set last message only when sending it diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 6aaff7966..b7fffb3ee 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1080,7 +1080,9 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool QDateTime timestamp = QDateTime::currentDateTime(); f->getChatForm()->addMessage(f->getToxId(), message, isAction, timestamp, true); - Nexus::getProfile()->getHistory()->addNewMessage(f->getToxId().publicKey, isAction ? "/me " + f->getDisplayedName() + " " + message : message, + Profile* profile = Nexus::getProfile(); + if (profile->isHistoryEnabled()) + profile->getHistory()->addNewMessage(f->getToxId().publicKey, isAction ? "/me " + f->getDisplayedName() + " " + message : message, f->getToxId().publicKey, timestamp, true, f->getDisplayedName()); newFriendMessageAlert(friendId);