diff --git a/Linphone/core/chat/message/EventLogList.cpp b/Linphone/core/chat/message/EventLogList.cpp index 764c5cca9..41c28e703 100644 --- a/Linphone/core/chat/message/EventLogList.cpp +++ b/Linphone/core/chat/message/EventLogList.cpp @@ -81,45 +81,32 @@ void EventLogList::connectItem(const QSharedPointer &item) { } void EventLogList::setChatCore(QSharedPointer core) { - auto updateChatCore = [this](QSharedPointer core) { - if (mChatCore != core) { - if (mChatCore) { - disconnect(mChatCore.get(), &ChatCore::eventsInserted, this, nullptr); - disconnect(mChatCore.get(), &ChatCore::eventListCleared, this, nullptr); - } - mChatCore = core; - if (mChatCore) { - connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); }); - connect(mChatCore.get(), &ChatCore::eventsInserted, this, - [this](QList> list) { - auto eventsList = getSharedList(); - for (auto &event : list) { - auto it = std::find_if( - eventsList.begin(), eventsList.end(), - [event](const QSharedPointer item) { return item == event; }); - if (it == eventsList.end()) { - connectItem(event); - add(event); - int index; - get(event.get(), &index); - emit eventInserted(index, new EventLogGui(event)); - } - } - }); - } - lUpdate(); - emit chatGuiChanged(); + if (mChatCore != core) { + if (mChatCore) { + disconnect(mChatCore.get(), &ChatCore::eventsInserted, this, nullptr); + disconnect(mChatCore.get(), &ChatCore::eventListCleared, this, nullptr); } - }; - if (mIsUpdating) { - connect(this, &EventLogList::isUpdatingChanged, this, [this, core, updateChatCore] { - if (!mIsUpdating) { - updateChatCore(core); - disconnect(this, &EventLogList::isUpdatingChanged, this, nullptr); - } - }); - } else { - updateChatCore(core); + mChatCore = core; + if (mChatCore) { + connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); }); + connect(mChatCore.get(), &ChatCore::eventsInserted, this, [this](QList> list) { + auto eventsList = getSharedList(); + for (auto &event : list) { + auto it = std::find_if(eventsList.begin(), eventsList.end(), + [event](const QSharedPointer item) { return item == event; }); + if (it == eventsList.end()) { + connectItem(event); + add(event); + int index; + get(event.get(), &index); + emit eventInserted(index, new EventLogGui(event)); + } + } + }); + } + lUpdate(); + // setIsUpdating(false); + emit chatGuiChanged(); } } diff --git a/Linphone/data/languages/de.ts b/Linphone/data/languages/de.ts index 9b7ad0126..3c682aa01 100644 --- a/Linphone/data/languages/de.ts +++ b/Linphone/data/languages/de.ts @@ -2112,65 +2112,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… - + chat_message_draft_sending_text - + chat_room_delete "Delete" Löschen - + chat_room_mute - + chat_room_unmute "Mute" - + chat_room_mark_as_read "Mark as read" - + chat_room_leave "leave" - + chat_list_leave_chat_popup_title leave the conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? - + chat_list_delete_chat_popup_title Delete the conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? diff --git a/Linphone/data/languages/en.ts b/Linphone/data/languages/en.ts index 16e870808..61fe3a30d 100644 --- a/Linphone/data/languages/en.ts +++ b/Linphone/data/languages/en.ts @@ -2089,65 +2089,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 is writing… - + chat_message_draft_sending_text Draft : %1 - + chat_room_delete "Delete" Delete - + chat_room_mute Mute - + chat_room_unmute "Mute" Unmute - + chat_room_mark_as_read "Mark as read" Mark as read - + chat_room_leave "leave" Leave - + chat_list_leave_chat_popup_title leave the conversation ? Leave the conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? - + chat_list_delete_chat_popup_title Delete the conversation ? Delete the conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? This conversation and all its messages will be deleted. Do You want to continue ? diff --git a/Linphone/data/languages/fr.ts b/Linphone/data/languages/fr.ts index 9bbcddda9..7a9ac2d47 100644 --- a/Linphone/data/languages/fr.ts +++ b/Linphone/data/languages/fr.ts @@ -2089,65 +2089,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 est en train d'écrire… - + chat_message_draft_sending_text Brouillon : %1 - + chat_room_delete "Delete" Supprimer - + chat_room_mute Mettre en sourdine - + chat_room_unmute "Mute" Enlever la sourdine - + chat_room_mark_as_read "Mark as read" Marquer comme lu - + chat_room_leave "leave" Quitter la conversation - + chat_list_leave_chat_popup_title leave the conversation ? Quitter la conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? Vous ne pourrez plus envoyer ou recevoir de messages dans cette conversation. Souhaitez-vous continuer ? - + chat_list_delete_chat_popup_title Delete the conversation ? Supprimer la conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? La conversation et tous ses messages seront supprimés. Souhaitez-vous continuer ? diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index e9eedf35c..d7c34b315 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -18,7 +18,9 @@ ListView { property real busyIndicatorSize: Utils.getSizeWithScreenRatio(60) property ChatGui currentChatGui: model.getAt(currentIndex) || null + onCurrentChatGuiChanged: positionViewAtIndex(currentIndex, ListView.Center) property ChatGui chatToSelect: null + property ChatGui chatToSelectLater: null onChatToSelectChanged: { var index = chatProxy.findChatIndex(chatToSelect) if (index != -1) { @@ -28,10 +30,7 @@ ListView { } onChatClicked: (chat) => {selectChat(chat)} - onCountChanged: { - selectChat(currentChatGui) - } - + signal markAllAsRead() signal chatClicked(ChatGui chat) @@ -41,14 +40,11 @@ ListView { loading = true } filterText: mainItem.searchText + onFilterTextChanged: { + chatToSelectLater = currentChatGui + } initialDisplayItems: Math.max(20, Math.round(2 * mainItem.height / Utils.getSizeWithScreenRatio(56))) displayItemsStep: 3 * initialDisplayItems / 2 - onModelReset: { - loading = false - if (mainItem.chatToSelect) { - selectChat(mainItem.chatToSelect) - } - } onModelAboutToBeReset: { loading = true } @@ -58,7 +54,18 @@ ListView { mainItem.currentIndex = index } onLayoutChanged: { - selectChat(mainItem.currentChatGui) + loading = false + if (mainItem.chatToSelectLater) { + selectChat(mainItem.chatToSelectLater) + mainItem.chatToSelectLater = null + } + else if (mainItem.chatToSelect) { + selectChat(mainItem.chatToSelect) + mainItem.chatToSelect = null + } + else { + selectChat(mainItem.currentChatGui) + } } onChatCreated: (chat) => { selectChat(chat) diff --git a/Linphone/view/Page/Main/Chat/ChatPage.qml b/Linphone/view/Page/Main/Chat/ChatPage.qml index 315834520..7f091b00f 100644 --- a/Linphone/view/Page/Main/Chat/ChatPage.qml +++ b/Linphone/view/Page/Main/Chat/ChatPage.qml @@ -267,7 +267,7 @@ AbstractMainPage { Layout.rightMargin: Utils.getSizeWithScreenRatio(8) Layout.topMargin: Utils.getSizeWithScreenRatio(18) onGroupCreationRequested: { - console.log("groupe call requetsed") + console.log("groupe call requested") listStackView.push(groupChatItem) } onContactClicked: (contact) => { @@ -371,9 +371,7 @@ AbstractMainPage { visible: chat != undefined //&& (chat.core.isBasic || chat.core.conferenceJoined) anchors.fill: parent chat: mainItem.selectedChatGui ? mainItem.selectedChatGui : null - onChatChanged: { - if (mainItem.selectedChatGui !== chat) mainItem.selectedChatGui = chat - } + // Reset current chat when switching account, otherwise the binding makes // the last chat from last account the current chat for the new default account Connections { @@ -387,7 +385,7 @@ AbstractMainPage { Connections { target: mainItem function onSelectedChatGuiChanged() { - if (mainItem.selectedChatGui) selectedChatView.chat = mainItem.selectedChatGui + selectedChatView.chat = mainItem.selectedChatGui ? mainItem.selectedChatGui : null } } Binding {