Skip to content
Snippets Groups Projects
Commit 0dd3a397 authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

conversationsadapter: do not listen to signals when in settings

Change-Id: Iba3e67431c817362c3242af9d56c8985c2e62534
Gitlab: #21
parent def680ab
No related branches found
No related tags found
No related merge requests found
......@@ -138,6 +138,7 @@ ConversationsAdapter::accountChangedSetUp(const QString &accountId)
LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type);
updateConversationsFilterWidget();
disconnectConversationModel();
connectConversationModel();
}
......@@ -178,22 +179,20 @@ ConversationsAdapter::setConversationFilter(lrc::api::profile::Type filter)
LRCInstance::getCurrentConversationModel()->setFilter(currentTypeFilter_);
}
void
ConversationsAdapter::refill()
{
if (conversationSmartListModel_)
conversationSmartListModel_->fillConversationsList();
}
bool
ConversationsAdapter::connectConversationModel()
ConversationsAdapter::connectConversationModel(bool updateFilter)
{
// Signal connections
auto currentConversationModel = LRCInstance::getCurrentConversationModel();
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(modelUpdatedConnection_);
QObject::disconnect(filterChangedConnection_);
QObject::disconnect(newConversationConnection_);
QObject::disconnect(conversationRemovedConnection_);
QObject::disconnect(conversationClearedConnection);
QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(searchStatusChangedConnection_);
QObject::disconnect(searchResultUpdatedConnection_);
modelSortedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::modelSorted,
[this]() {
......@@ -271,10 +270,23 @@ ConversationsAdapter::connectConversationModel()
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
currentConversationModel->setFilter("");
if (updateFilter) currentConversationModel->setFilter("");
return true;
}
void
ConversationsAdapter::disconnectConversationModel()
{
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(modelUpdatedConnection_);
QObject::disconnect(filterChangedConnection_);
QObject::disconnect(conversationRemovedConnection_);
QObject::disconnect(conversationClearedConnection);
QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(searchStatusChangedConnection_);
QObject::disconnect(searchResultUpdatedConnection_);
}
void
ConversationsAdapter::updateConversationForNewContact(const QString &convUid)
{
......
......@@ -33,12 +33,14 @@ public:
explicit ConversationsAdapter(QObject *parent = nullptr);
~ConversationsAdapter();
Q_INVOKABLE bool connectConversationModel();
Q_INVOKABLE bool connectConversationModel(bool updateFilter = true);
Q_INVOKABLE void disconnectConversationModel();
Q_INVOKABLE void selectConversation(const QString &accountId,
const QString &convUid,
bool preventSendingSignal = true);
Q_INVOKABLE void selectConversation(const QString &uid);
Q_INVOKABLE void deselectConversation();
Q_INVOKABLE void refill();
Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationsFilterWidget();
Q_INVOKABLE void setConversationFilter(const QString &type);
......
......@@ -270,6 +270,8 @@ public:
static void
setSelectedAccountId(const QString &accountId = {})
{
if (accountId == instance().selectedAccountId_)
return; // No need to select current selected account
instance().selectedAccountId_ = accountId;
// Last selected account should be set as preferred.
......
......@@ -117,9 +117,14 @@ Window {
mainViewStack.push(settingsView, StackView.Immediate)
sidePanelViewStack.push(leftPanelSettingsView, StackView.Immediate)
}
ConversationsAdapter.disconnectConversationModel()
} else {
ConversationsAdapter.connectConversationModel(false)
ConversationsAdapter.refill() // to be sure to have latest informations
mainViewWindowSidePanel.forceUpdateConversationSmartListView()
if (!sidePanelHidden) {
sidePanelViewStack.pop(mainViewWindowSidePanel, StackView.Immediate)
mainViewStack.pop(StackView.Immediate)
......
......@@ -128,6 +128,7 @@ Rectangle {
Connections {
id: accountConnections_ContactModel
target: ClientWrapper.contactModel
enabled: accountViewRect.visible
function onModelUpdated(uri, needsSorted) {
updateAndShowBannedContactsSlot()
......@@ -145,6 +146,7 @@ Rectangle {
Connections {
id: accountConnections_DeviceModel
target: ClientWrapper.deviceModel
enabled: accountViewRect.visible
function onDeviceAdded(id) {
updateAndShowDevicesSlot()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment