From e203df4012b92b26938e340d0c15a6b53c2535ba Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 1 Oct 2025 14:09:19 +0200 Subject: [PATCH] Quick code review --- Linphone/model/chat/ChatModel.cpp | 14 +++++++++----- Linphone/model/chat/ChatModel.hpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Linphone/model/chat/ChatModel.cpp b/Linphone/model/chat/ChatModel.cpp index 661b778fe..d8ce56a1c 100644 --- a/Linphone/model/chat/ChatModel.cpp +++ b/Linphone/model/chat/ChatModel.cpp @@ -61,14 +61,17 @@ std::list> ChatModel::getSharedDocuments() co } std::list> ChatModel::getHistory() const { + // Pas besoin de faire le filtre au niveau app, tu peux utiliser juste getHistory(count) qui renvoie ce qu'il faut, ça sera sans doute plus efficace int filter = mMonitor->hasCapability((int)linphone::ChatRoom::Capabilities::Conference) ? static_cast(linphone::ChatRoom::HistoryFilter::ChatMessage) | static_cast(linphone::ChatRoom::HistoryFilter::InfoNoDevice) : static_cast(linphone::ChatRoom::HistoryFilter::ChatMessage); - return mMonitor->getHistory(0, filter); + // Ne fais pas le getHistory(0), ça va charger tout l'histoire d'une chat room pour rien (ce qui explique le spinner quand tu ouvres une conversation) + // A la place ne prend que 20-30 items et rajoute un scroll listener pour les charger à la volée avec getHistoryRangeEvents(currentCount, step) + return mMonitor->getHistory(30, filter); } -std::list> ChatModel::getChatMessageHistory() const { +/*std::list> ChatModel::getChatMessageHistory() const { auto history = mMonitor->getHistory(0, (int)linphone::ChatRoom::HistoryFilter::ChatMessage); std::list> res; for (auto &eventLog : history) { @@ -76,7 +79,7 @@ std::list> ChatModel::getChatMessageHisto if (chatMessage) res.push_back(chatMessage); } return res; -} +}*/ QString ChatModel::getIdentifier() const { return Utils::coreStringToAppString(mMonitor->getIdentifier()); @@ -123,9 +126,10 @@ int ChatModel::getUnreadMessagesCount() const { void ChatModel::markAsRead() { mMonitor->markAsRead(); - for (auto &message : getChatMessageHistory()) { + /*for (auto &message : getChatMessageHistory()) { message->markAsRead(); - } + }*/ + mMonitor->markAsRead(); // pas besoin d'itérer sur tout l'historique des messages, ça fera gagner du temps emit messagesRead(); } diff --git a/Linphone/model/chat/ChatModel.hpp b/Linphone/model/chat/ChatModel.hpp index c57a02b43..82d0acb74 100644 --- a/Linphone/model/chat/ChatModel.hpp +++ b/Linphone/model/chat/ChatModel.hpp @@ -49,7 +49,7 @@ public: std::list> getSharedMedias() const; std::list> getSharedDocuments() const; std::list> getHistory() const; - std::list> getChatMessageHistory() const; + //std::list> getChatMessageHistory() const; QString getIdentifier() const; void deleteHistory(); void deleteMessage(std::shared_ptr message);