diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index 19bfbffce..bc7b351d9 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -857,7 +857,8 @@ void ChatRoomModel::updateNewMessageNotice(const int& count){ } } mUnreadMessageNotice = ChatNoticeModel::create(ChatNoticeModel::NoticeType::NoticeUnreadMessages, lastUnreadMessage,lastReceivedMessage, QString::number(count)); - prepend(mUnreadMessageNotice); + if(mIsInitialized) + prepend(mUnreadMessageNotice); qDebug() << "New message notice timestamp to :" << lastUnreadMessage.toString() << " recv at " << lastReceivedMessage.toString(); } } @@ -931,14 +932,16 @@ void ChatRoomModel::removeBindingCall(){ } void ChatRoomModel::resetData(){ - if( mBindingCalls == 0) + if( mBindingCalls == 0) { ProxyListModel::resetData(); + mIsInitialized = false; + } } void ChatRoomModel::initEntries(){ if( mList.size() > mLastEntriesStep) resetData(); - if(mList.size() <= (mUnreadMessageNotice ? 1 : 0)) { + if(!mIsInitialized) { qDebug() << "Internal Entries : Init"; // On call : reinitialize all entries. This allow to free up memory QList > entries; @@ -981,11 +984,11 @@ void ChatRoomModel::initEntries(){ endInsertRows(); auto lastIndex = index(mList.size()-1,0); emit dataChanged(firstIndex,lastIndex); - updateNewMessageNotice(mChatRoom->getUnreadMessagesCount()); + updateNewMessageNotice(mChatRoom->getUnreadMessagesCount());// it will prepend notice if needed. } - qDebug() << "Internal Entries : End"; + qDebug() << "Internal Entries (" << mList.size() << ") : End "; + mIsInitialized = true; } - mIsInitialized = true; } void ChatRoomModel::setEntriesLoading(const bool& loading){ if( mEntriesLoading != loading){ diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp index a48ecafc7..6348199fd 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp @@ -291,10 +291,8 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) { } mChatRoomModel = CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoomModel); - setSourceModel(mChatRoomModel.get()); - sort(0); + if (mChatRoomModel) { - ChatRoomModel *ChatRoomModel = mChatRoomModel.get(); QObject::connect(ChatRoomModel, &ChatRoomModel::isRemoteComposingChanged, this, &ChatRoomProxyModel::handleIsRemoteComposingChanged); QObject::connect(ChatRoomModel, &ChatRoomModel::messageReceived, this, &ChatRoomProxyModel::handleMessageReceived); @@ -304,6 +302,8 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) { QObject::connect(ChatRoomModel, &ChatRoomModel::chatRoomDeleted, this, &ChatRoomProxyModel::chatRoomDeleted); mChatRoomModel->initEntries();// This way, we don't load huge chat rooms (that lead to freeze GUI) } + setSourceModel(mChatRoomModel.get()); + sort(0); } } diff --git a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml index 9d4ebc305..d99cbf7aa 100644 --- a/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/IncomingMessage.qml @@ -43,12 +43,8 @@ RowLayout { width: ChatStyle.entry.message.incoming.avatarSize // The avatar is only visible for the first message of a incoming messages sequence. - visible: { - if (index <= 0) { - return true // 1. First message, so visible. - } - return !$chatEntry.isOutgoing && !mainRow.isTopGrouped - } + visible: index <= 0 ? true // 1. First message, so visible. + : $chatEntry && !$chatEntry.isOutgoing && !mainRow.isTopGrouped || false TooltipArea{ delay:0 text:avatar.username+'\n'+$chatEntry.fromSipAddress diff --git a/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml b/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml index 8101854ea..3d1079c05 100644 --- a/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml +++ b/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml @@ -97,11 +97,12 @@ Notification { onClicked: notification._close(function () { AccountSettingsModel.setDefaultAccountFromSipAddress(notification.localAddress) + var chatroom = notification.timelineModel.getChatRoomModel() + console.debug("Load conversation from notification: "+chatroom) + //notification.notificationData.window.setView('Conversation', { + // chatRoomModel: chatroom + // }) notification.timelineModel.selected = true - console.debug("Load conversation from notification") - notification.notificationData.window.setView('Conversation', { - chatRoomModel:notification.timelineModel.getChatRoomModel() - }) App.smartShowWindow(notification.notificationData.window) }) }