Browse Source

Fix some messages being saved with history disabled

reviewable/pr2771/r1
tux3 10 years ago
parent
commit
f2ba03b45f
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 22
      src/widget/form/chatform.cpp
  2. 4
      src/widget/widget.cpp

22
src/widget/form/chatform.cpp

@ -949,13 +949,23 @@ void ChatForm::SendMessageStr(QString msg) @@ -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())
{
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
{
offMsgEngine->registerReceipt(rec, id, ma);
});
/// 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

4
src/widget/widget.cpp

@ -1080,7 +1080,9 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool @@ -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);

Loading…
Cancel
Save