diff --git a/src/app/modules/main/profile_section/contacts/view.nim b/src/app/modules/main/profile_section/contacts/view.nim index 09c8c7fd74..39757679d2 100644 --- a/src/app/modules/main/profile_section/contacts/view.nim +++ b/src/app/modules/main/profile_section/contacts/view.nim @@ -1,6 +1,6 @@ import NimQml -import ../../../shared_models/[user_model, user_item] +import ../../../shared_models/[user_model] import ./io_interface import models/showcase_contact_generic_model @@ -72,12 +72,6 @@ QtObject: proc contactInfoRequestFinished(self: View, publicKey: string, ok: bool) {.signal.} - proc hasPendingContactRequest*(self: View, publicKey: string): bool {.slot.} = - if not self.contactsModel.isContactWithIdAdded(publicKey): - return false - let userItem = self.contactsModel.getItemByPubKey(publicKey) - return userItem.contactRequest == ContactRequest.Sent - proc sendContactRequest*(self: View, publicKey: string, message: string) {.slot.} = self.delegate.sendContactRequest(publicKey, message) diff --git a/storybook/pages/MembersSelectorPage.qml b/storybook/pages/MembersSelectorPage.qml index 42d010de80..57fb8868c8 100644 --- a/storybook/pages/MembersSelectorPage.qml +++ b/storybook/pages/MembersSelectorPage.qml @@ -40,7 +40,11 @@ SplitView { QtObject { function getContactDetailsAsJson() { - return JSON.stringify({ ensVerified: false }) + return JSON.stringify({ + ensVerified: false, + isCurrentUser: false, + contactRequestState: Constants.ContactRequestState.Mutual + }) } Component.onCompleted: { @@ -53,18 +57,18 @@ SplitView { } } - ChatStores.RootStore { - id: rootStoreMock + ListModel { + id: contacts - readonly property var contactsModel: ListModel { - id: contactsModel - - Component.onCompleted: { - for(let i=0; i < 20; i++) { - append(usersModelEditor.getNewUser(i)) - } + Component.onCompleted: { + for(let i=0; i < 20; i++) { + append(usersModelEditor.getNewUser(i)) } } + } + + ChatStores.RootStore { + id: rootStoreMock readonly property var contactsStore: QtObject { readonly property var mainModuleInst: null @@ -187,6 +191,8 @@ SplitView { return true } } + + contactsModel: contacts } } } @@ -205,6 +211,8 @@ SplitView { sourceComponent: MembersEditSelectorView { rootStore: rootStoreMock usersStore: usersStoreMock + + contactsModel: contacts } } } @@ -241,11 +249,11 @@ SplitView { UsersModelEditor { id: usersModelEditor anchors.fill: parent - model: contactsModel + model: contacts - onRemoveClicked: contactsModel.remove(index, 1) - onRemoveAllClicked: contactsModel.clear() - onAddClicked: contactsModel.append(usersModelEditor.getNewUser(contactsModel.count)) + onRemoveClicked: contacts.remove(index, 1) + onRemoveAllClicked: contacts.clear() + onAddClicked: contacts.append(usersModelEditor.getNewUser(contacts.count)) } } } diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index a0abf76f04..0e37c65da3 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -30,8 +30,6 @@ QtObject { property bool openCreateChat: false - property var contactsModel: root.contactsStore.myContactsModel - // Important: // Each `ChatLayout` has its own chatCommunitySectionModule // (on the backend chat and community sections share the same module since they are actually the same) diff --git a/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml b/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml index 2cb42eb9fe..7ba71f11f7 100644 --- a/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatHeaderContentView.qml @@ -346,6 +346,7 @@ Item { usersStore: UsersStore { usersModule: root.chatContentModule.usersModule } + contactsModel: root.rootStore.contactsStore.myContactsModel onConfirmed: root.state = d.stateInfoButtonContent onRejected: root.state = d.stateInfoButtonContent diff --git a/ui/app/AppLayouts/Chat/views/CreateChatView.qml b/ui/app/AppLayouts/Chat/views/CreateChatView.qml index 2b647212c6..9f7243373b 100644 --- a/ui/app/AppLayouts/Chat/views/CreateChatView.qml +++ b/ui/app/AppLayouts/Chat/views/CreateChatView.qml @@ -3,8 +3,9 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import QtQml.Models 2.15 -import StatusQ.Controls 0.1 +import StatusQ 0.1 import StatusQ.Components 0.1 +import StatusQ.Controls 0.1 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 @@ -63,6 +64,7 @@ Page { rootStore: root.rootStore utilsStore: root.utilsStore + contactsModel: root.rootStore.contactsStore.myContactsModel function createChat() { if (model.count === 0) { @@ -178,7 +180,7 @@ Page { StatusBaseText { anchors.centerIn: parent width: Math.min(553, parent.width - 2 * Theme.padding) - visible: root.rootStore.contactsModel.count === 0 + visible: root.rootStore.contactsStore.myContactsModel.ModelCount.empty horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.WordWrap diff --git a/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml b/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml index 1a94869d01..df576bf6c1 100644 --- a/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml +++ b/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml @@ -100,10 +100,10 @@ MembersSelectorBase { return } - const hasPendingContactRequest = root.rootStore.contactsStore.hasPendingContactRequest(contactDetails.publicKey) + const hasPendingContactRequest = contactDetails.contactRequestState === Constants.ContactRequestState.Sent if ((root.model.count === 0 && hasPendingContactRequest) || - contactDetails.publicKey === root.rootStore.contactsStore.myPublicKey || contactDetails.isBlocked) { + contactDetails.isCurrentUser || contactDetails.isBlocked) { // List is empty and we have a contact request // OR it's our own chat key or a banned user // Then open the contact's profile popup diff --git a/ui/app/AppLayouts/Chat/views/private/MembersSelectorBase.qml b/ui/app/AppLayouts/Chat/views/private/MembersSelectorBase.qml index cc8b7891e8..e62d98535b 100644 --- a/ui/app/AppLayouts/Chat/views/private/MembersSelectorBase.qml +++ b/ui/app/AppLayouts/Chat/views/private/MembersSelectorBase.qml @@ -19,6 +19,8 @@ InlineSelectorPanel { property ChatStores.RootStore rootStore + property alias contactsModel: suggestionsModel.sourceModel + readonly property int membersLimit: 20 // see: https://github.com/status-im/status-mobile/issues/13066 property bool limitReached: model.count >= membersLimit @@ -29,9 +31,7 @@ InlineSelectorPanel { warningLabel.visible: limitReached suggestionsModel: SortFilterProxyModel { - id: _suggestionsModel - - sourceModel: root.rootStore.contactsModel + id: suggestionsModel function searchPredicate(displayName, localNickname, nameAlias) { return displayName.toLowerCase().includes(root.edit.text.toLowerCase()) || @@ -52,14 +52,14 @@ InlineSelectorPanel { enabled: root.edit.text !== "" && root.pastedChatKey == "" expression: { root.edit.text // ensure expression is reevaluated when edit.text changes - return _suggestionsModel.searchPredicate(model.displayName, model.localNickname, model.alias) + return suggestionsModel.searchPredicate(model.displayName, model.localNickname, model.alias) } expectedRoles: ["displayName", "localNickname", "alias"] }, FastExpressionFilter { expression: { root.model.count // ensure expression is reevaluated when members model changes - return _suggestionsModel.notAMemberPredicate(model.pubKey) + return suggestionsModel.notAMemberPredicate(model.pubKey) } expectedRoles: ["pubKey"] }, diff --git a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml index 1592fdd68f..acd500a091 100644 --- a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml @@ -56,10 +56,6 @@ QtObject { return root.globalUtilsInst.generateAlias(pubKey) } - function hasPendingContactRequest(pubKey) { - return root.contactsModule.hasPendingContactRequest(pubKey) - } - function joinPrivateChat(pubKey) { Global.changeAppSectionBySectionType(Constants.appSection.chat) root.contactsModule.switchToOrCreateOneToOneChat(pubKey) diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index e668c15076..5632709078 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -1218,7 +1218,7 @@ Loader { onRemoveTrustStatus: root.rootStore.contactsStore.removeTrustStatus(profileContextMenu.pubKey) onRemoveContact: Global.removeContactRequested(profileContextMenu.pubKey) onBlockContact: Global.blockContactRequested(profileContextMenu.pubKey) - onRemoveFromGroup: root.store.removeMemberFromGroupChat(profileContextMenu.pubKey) + onRemoveFromGroup: root.rootStore.removeMemberFromGroupChat(profileContextMenu.pubKey) onMarkAsTrusted: Global.openMarkAsIDVerifiedPopup(profileContextMenu.pubKey, null) onRemoveTrustedMark: Global.openRemoveIDVerificationDialog(profileContextMenu.pubKey, null)