Commit 79853f99 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(src/components/chat/ChatProxyModel): increment properly visible messages number

parent 0988bb93
...@@ -83,6 +83,8 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) { ...@@ -83,6 +83,8 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) {
if (m_chat_room == message->getChatRoom()) { if (m_chat_room == message->getChatRoom()) {
insertMessageAtEnd(message); insertMessageAtEnd(message);
m_chat_room->markAsRead(); m_chat_room->markAsRead();
emit messageReceived(message);
} }
} }
); );
......
...@@ -72,7 +72,8 @@ signals: ...@@ -72,7 +72,8 @@ signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sip_address);
void allEntriesRemoved (); void allEntriesRemoved ();
void messageSent (std::shared_ptr<linphone::ChatMessage> &message); void messageSent (const std::shared_ptr<linphone::ChatMessage> &message);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
private: private:
void fillMessageEntry ( void fillMessageEntry (
......
...@@ -27,6 +27,20 @@ const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50; ...@@ -27,6 +27,20 @@ const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(&m_chat_model_filter); setSourceModel(&m_chat_model_filter);
ChatModel *chat = static_cast<ChatModel *>(m_chat_model_filter.sourceModel());
QObject::connect(
chat, &ChatModel::messageReceived, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++;
}
);
QObject::connect(
chat, &ChatModel::messageSent, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++;
}
);
} }
void ChatProxyModel::loadMoreEntries () { void ChatProxyModel::loadMoreEntries () {
...@@ -42,7 +56,6 @@ void ChatProxyModel::loadMoreEntries () { ...@@ -42,7 +56,6 @@ void ChatProxyModel::loadMoreEntries () {
invalidateFilter(); invalidateFilter();
count = rowCount() - count; count = rowCount() - count;
if (count > 0) if (count > 0)
emit moreEntriesLoaded(count); emit moreEntriesLoaded(count);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment