1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix some messages being saved with history disabled

This commit is contained in:
tux3 2015-12-31 14:36:12 +01:00
parent 7f34290129
commit f2ba03b45f
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 19 additions and 7 deletions

View File

@ -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

View File

@ -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);