Mark all messages as read in small chats

This commit is contained in:
Sebastian J. Wolf 2020-09-16 21:12:39 +02:00
parent 9070caa2a3
commit b5f39f78c0
3 changed files with 14 additions and 0 deletions

View file

@ -186,6 +186,10 @@ Page {
chatView.lastReadSentIndex = lastReadSentIndex;
chatView.positionViewAtIndex(modelIndex, ListView.Contain);
chatPage.loading = false;
if (chatView.height > chatView.contentHeight) {
console.log("[ChatPage] Chat content quite small...");
tdLibWrapper.viewMessage(chatInformation.id, chatModel.getMessage(chatView.count - 1).id);
}
}
onNewMessageReceived: {
// Notify user about new messages...

View file

@ -91,6 +91,15 @@ QVariantMap ChatModel::getChatInformation()
return this->chatInformation;
}
QVariantMap ChatModel::getMessage(const int &index)
{
if (index < this->messages.size()) {
return this->messages.at(index).toMap();
} else {
return QVariantMap();
}
}
bool compareMessages(const QVariant &message1, const QVariant &message2)
{
QVariantMap messageMap1 = message1.toMap();

View file

@ -39,6 +39,7 @@ public:
Q_INVOKABLE void initialize(const QVariantMap &chatInformation);
Q_INVOKABLE void triggerLoadMoreHistory();
Q_INVOKABLE QVariantMap getChatInformation();
Q_INVOKABLE QVariantMap getMessage(const int &index);
signals:
void messagesReceived(const int &modelIndex, const int &lastReadSentIndex);