diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index cf636b4..cedbf24 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -316,7 +316,7 @@ Page { id: messageDateText text: Functions.getDateTimeElapsed(display.date) font.pixelSize: Theme.fontSizeTiny - color: chatPage.myUserId === display.sender_user_id ? Theme.highlightColor : Theme.primaryColor + color: chatPage.myUserId === display.sender_user_id ? Theme.secondaryHighlightColor : Theme.secondaryColor horizontalAlignment: (chatPage.myUserId === display.sender_user_id) ? Text.AlignRight : Text.AlignLeft } diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 9750d30..22289d9 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -64,9 +64,14 @@ bool compareMessages(const QVariant &message1, const QVariant &message2) void ChatModel::handleMessagesReceived(const QVariantList &messages) { - qDebug() << "[ChatModel] Receiving new messages :)"; - this->messagesMutex.lock(); + qDebug() << "[ChatModel] Receiving new messages :)" << messages.size(); + if (messages.size() == 0) { + emit noMessagesAvailable(); + return; + } + + this->messagesMutex.lock(); this->messagesToBeAdded.clear(); QListIterator messagesIterator(messages); while (messagesIterator.hasNext()) { @@ -80,8 +85,8 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages) this->insertMessages(); this->messagesMutex.unlock(); - // First call only returns one message, we need to get a little more than that... - if (this->messagesToBeAdded.size() == 1 && !this->inReload) { + // First call only returns a few messages, we need to get a little more than that... + if (this->messagesToBeAdded.size() < 10 && !this->inReload) { qDebug() << "[ChatModel] Only one message received in first call, loading more..."; this->inReload = true; this->tdLibWrapper->getChatHistory(this->chatId, this->messagesToBeAdded.first().toMap().value("id").toLongLong()); diff --git a/src/chatmodel.h b/src/chatmodel.h index 8f89f9e..41cbd9a 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -21,6 +21,7 @@ public: signals: void messagesReceived(); + void noMessagesAvailable(); void newMessageReceived(); public slots: