mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 23:28:09 +00:00
Avoid to update chat room tile on onIsComposingReceived because there is no need to do that (and updating lead to reload data).
Do not add an already displayed message.
This commit is contained in:
parent
d0ca9c36ef
commit
bac4bf937b
2 changed files with 11 additions and 2 deletions
|
|
@ -885,6 +885,15 @@ bool ChatRoomModel::isTerminated(const std::shared_ptr<linphone::ChatRoom>& chat
|
|||
return chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted;
|
||||
}
|
||||
|
||||
bool ChatRoomModel::exists(const std::shared_ptr<linphone::ChatMessage> message) const{
|
||||
auto entry = std::find_if(mList.begin(), mList.end(), [message](const QSharedPointer<QObject>& entry ){
|
||||
auto chatEventEntry = entry.objectCast<ChatEvent>();
|
||||
return chatEventEntry->mType == ChatRoomModel::EntryType::MessageEntry && chatEventEntry.objectCast<ChatMessageModel>()->getChatMessage() == message;
|
||||
});
|
||||
// if not find, load more entries and find it in new entries.
|
||||
return entry != mList.end();
|
||||
}
|
||||
|
||||
void ChatRoomModel::addBindingCall(){ // If a call is binding to this chat room, we avoid cleaning data (Add=+1, remove=-1)
|
||||
++mBindingCalls;
|
||||
}
|
||||
|
|
@ -1088,7 +1097,7 @@ void ChatRoomModel::insertCalls (const QList<std::shared_ptr<linphone::CallLog>
|
|||
|
||||
QSharedPointer<ChatMessageModel> ChatRoomModel::insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message) {
|
||||
QSharedPointer<ChatMessageModel> model;
|
||||
if(mIsInitialized){
|
||||
if(mIsInitialized && !exists(message)){
|
||||
model = ChatMessageModel::create(message);
|
||||
if(model){
|
||||
connect(model.get(), &ChatMessageModel::remove, this, &ChatRoomModel::removeEntry);
|
||||
|
|
@ -1213,7 +1222,6 @@ void ChatRoomModel::onIsComposingReceived(const std::shared_ptr<linphone::ChatRo
|
|||
if(isComposing)
|
||||
mComposers[remoteAddress] = Utils::getDisplayName(remoteAddress);
|
||||
emit isRemoteComposingChanged();
|
||||
updateLastUpdateTime();
|
||||
}
|
||||
|
||||
void ChatRoomModel::onMessageReceived(const std::shared_ptr<linphone::ChatRoom> & chatRoom, const std::shared_ptr<linphone::ChatMessage> & message){
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ public:
|
|||
void updateNewMessageNotice(const int& count);
|
||||
Q_INVOKABLE int loadTillMessage(ChatMessageModel * message);// Load all entries till message and return its index. -1 if not found.
|
||||
static bool isTerminated(const std::shared_ptr<linphone::ChatRoom>& chatRoom);
|
||||
bool exists(const std::shared_ptr<linphone::ChatMessage> message) const;
|
||||
|
||||
void addBindingCall(); // If a call is binding to this chat room, we avoid cleaning data (Add=+1, remove=-1)
|
||||
void removeBindingCall();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue