summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pica-client/chatwindow.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/pica-client/chatwindow.cpp b/pica-client/chatwindow.cpp
index a746561..9d52ee9 100644
--- a/pica-client/chatwindow.cpp
+++ b/pica-client/chatwindow.cpp
@@ -219,11 +219,27 @@ void ChatWindow::msg_from_peer(QString msg)
void ChatWindow::msg_delivered()
{
- QTextCursor c(chatw->document());
- c.setPosition(undelivered_msgs.first());
- c.deleteChar();
- c.insertText("+");
- undelivered_msgs.removeFirst();
+ if (undelivered_msgs.isEmpty())
+ {
+ // undelivered_msgs can be empty if new chatwindow instance was created
+ // and undelivered message from previous chat session is delivered
+ // after that.
+
+ QByteArray my_id = Accounts::GetCurrentAccount().id;
+ QMap<QByteArray, QList<QString> > undl = hist.GetUndeliveredMessages();
+
+ if (!undl[my_id].isEmpty())
+ put_message(undl[my_id].first(), my_id , true);
+ }
+
+ if (!undelivered_msgs.isEmpty())
+ {
+ QTextCursor c(chatw->document());
+ c.setPosition(undelivered_msgs.first());
+ c.deleteChar();
+ c.insertText("+");
+ undelivered_msgs.removeFirst();
+ }
hist.SetDelivered(peer_id_);
}