ContactsStore encapsulation improved

This commit is contained in:
Michał Cieślak 2024-11-15 11:59:50 +01:00
parent 6718491198
commit cf1ee80dc2
4 changed files with 47 additions and 36 deletions

View File

@ -154,7 +154,8 @@ MembersSelectorBase {
Connections { Connections {
enabled: root.visible enabled: root.visible
target: root.rootStore.contactsStore.mainModuleInst target: root.rootStore.contactsStore
function onResolvedENS(resolvedPubKey: string, resolvedAddress: string, uuid: string) { function onResolvedENS(resolvedPubKey: string, resolvedAddress: string, uuid: string) {
if (resolvedPubKey === "") { if (resolvedPubKey === "") {
root.suggestionsDialog.forceHide = false root.suggestionsDialog.forceHide = false

View File

@ -78,7 +78,8 @@ StatusModal {
} }
Connections { Connections {
target: contactsStore.mainModuleInst target: root.contactsStore
function onResolvedENS(resolvedPubKey: string, resolvedAddress: string, uuid: string) { function onResolvedENS(resolvedPubKey: string, resolvedAddress: string, uuid: string) {
if(!d.showChatKeyValidationIndicator){ if(!d.showChatKeyValidationIndicator){
d.showPasteButton = false d.showPasteButton = false

View File

@ -1,47 +1,58 @@
import QtQuick 2.13 import QtQuick 2.15
import utils 1.0
import StatusQ 0.1 import StatusQ 0.1
import utils 1.0
QtObject { QtObject {
id: root id: root
property var contactsModule readonly property QtObject _d: QtObject {
id: d
property var globalUtilsInst: globalUtils readonly property var contactsModuleInst: profileSectionModule.contactsModule
property var mainModuleInst: Global.appIsReady? mainModule : null readonly property var mainModuleInst: mainModule
readonly property var globalUtilsInst: globalUtils
Component.onCompleted: {
mainModuleInst.resolvedENS.connect(root.resolvedENS)
}
}
property string myPublicKey: userProfile.pubKey property string myPublicKey: userProfile.pubKey
// contactsModel holds all available contacts // contactsModel holds all available contacts
property var contactsModel: contactsModule.contactsModel property var contactsModel: d.contactsModuleInst.contactsModel
readonly property var contactsModelAdaptor: ContactsModelAdaptor { readonly property var contactsModelAdaptor: ContactsModelAdaptor {
allContacts: contactsModel allContacts: contactsModel
} }
signal resolvedENS(string resolvedPubKey, string resolvedAddress, string uuid)
property var myContactsModel: contactsModelAdaptor.mutualContacts property var myContactsModel: contactsModelAdaptor.mutualContacts
property var blockedContactsModel: contactsModelAdaptor.blockedContacts property var blockedContactsModel: contactsModelAdaptor.blockedContacts
property var receivedContactRequestsModel: contactsModelAdaptor.pendingReceivedRequestContacts property var receivedContactRequestsModel: contactsModelAdaptor.pendingReceivedRequestContacts
property var sentContactRequestsModel: contactsModelAdaptor.pendingSentRequestContacts property var sentContactRequestsModel: contactsModelAdaptor.pendingSentRequestContacts
readonly property var showcasePublicKey: contactsModule.showcasePublicKey readonly property var showcasePublicKey: d.contactsModuleInst.showcasePublicKey
// Showcase models for a contact with showcasePublicKey // Showcase models for a contact with showcasePublicKey
readonly property var showcaseContactCommunitiesModel: contactsModule.showcaseContactCommunitiesModel readonly property var showcaseContactCommunitiesModel: d.contactsModuleInst.showcaseContactCommunitiesModel
readonly property var showcaseContactAccountsModel: contactsModule.showcaseContactAccountsModel readonly property var showcaseContactAccountsModel: d.contactsModuleInst.showcaseContactAccountsModel
readonly property var showcaseContactCollectiblesModel: contactsModule.showcaseContactCollectiblesModel readonly property var showcaseContactCollectiblesModel: d.contactsModuleInst.showcaseContactCollectiblesModel
readonly property var showcaseContactAssetsModel: contactsModule.showcaseContactAssetsModel readonly property var showcaseContactAssetsModel: d.contactsModuleInst.showcaseContactAssetsModel
readonly property var showcaseContactSocialLinksModel: contactsModule.showcaseContactSocialLinksModel readonly property var showcaseContactSocialLinksModel: d.contactsModuleInst.showcaseContactSocialLinksModel
readonly property bool isShowcaseForAContactLoading: contactsModule.showcaseForAContactLoading readonly property bool isShowcaseForAContactLoading: d.contactsModuleInst.showcaseForAContactLoading
// Support models for showcase for a contact with showcasePublicKey // Support models for showcase for a contact with showcasePublicKey
readonly property var showcaseCollectiblesModel: contactsModule.showcaseCollectiblesModel readonly property var showcaseCollectiblesModel: d.contactsModuleInst.showcaseCollectiblesModel
signal resolvedENS(string resolvedPubKey, string resolvedAddress, string uuid)
// Sets showcasePublicKey and updates showcase models with corresponding data // Sets showcasePublicKey and updates showcase models with corresponding data
function requestProfileShowcase(publicKey) { function requestProfileShowcase(publicKey) {
root.contactsModule.requestProfileShowcase(publicKey) d.contactsModuleInst.requestProfileShowcase(publicKey)
} }
// Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections. // Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
@ -49,32 +60,32 @@ QtObject {
// property var sentButRejectedContactRequestsModel: contactsModule.sentButRejectedContactRequestsModel // property var sentButRejectedContactRequestsModel: contactsModule.sentButRejectedContactRequestsModel
function resolveENS(value) { function resolveENS(value) {
root.mainModuleInst.resolveENS(value, "") d.mainModuleInst.resolveENS(value, "")
} }
function generateAlias(pubKey) { function generateAlias(pubKey) {
return root.globalUtilsInst.generateAlias(pubKey) return d.globalUtilsInst.generateAlias(pubKey)
} }
function joinPrivateChat(pubKey) { function joinPrivateChat(pubKey) {
Global.changeAppSectionBySectionType(Constants.appSection.chat) Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.contactsModule.switchToOrCreateOneToOneChat(pubKey) d.contactsModuleInst.switchToOrCreateOneToOneChat(pubKey)
} }
function unblockContact(pubKey) { function unblockContact(pubKey) {
root.contactsModule.unblockContact(pubKey) d.contactsModuleInst.unblockContact(pubKey)
} }
function blockContact(pubKey) { function blockContact(pubKey) {
root.contactsModule.blockContact(pubKey) d.contactsModuleInst.blockContact(pubKey)
} }
function removeContact(pubKey) { function removeContact(pubKey) {
root.contactsModule.removeContact(pubKey) d.contactsModuleInst.removeContact(pubKey)
} }
function changeContactNickname(pubKey, nickname, displayName, isEdit) { function changeContactNickname(pubKey, nickname, displayName, isEdit) {
root.contactsModule.changeContactNickname(pubKey, nickname) d.contactsModuleInst.changeContactNickname(pubKey, nickname)
let message = "" let message = ""
if (nickname === "") { // removed nickname if (nickname === "") { // removed nickname
@ -91,37 +102,37 @@ QtObject {
} }
function sendContactRequest(pubKey, message) { function sendContactRequest(pubKey, message) {
root.contactsModule.sendContactRequest(pubKey, message) d.contactsModuleInst.sendContactRequest(pubKey, message)
Global.displaySuccessToastMessage(qsTr("Contact request sent")) Global.displaySuccessToastMessage(qsTr("Contact request sent"))
} }
function acceptContactRequest(pubKey, contactRequestId) { function acceptContactRequest(pubKey, contactRequestId) {
root.contactsModule.acceptContactRequest(pubKey, contactRequestId) d.contactsModuleInst.acceptContactRequest(pubKey, contactRequestId)
} }
function dismissContactRequest(pubKey, contactRequestId) { function dismissContactRequest(pubKey, contactRequestId) {
root.contactsModule.dismissContactRequest(pubKey, contactRequestId) d.contactsModuleInst.dismissContactRequest(pubKey, contactRequestId)
} }
function getLatestContactRequestForContactAsJson(pubKey) { function getLatestContactRequestForContactAsJson(pubKey) {
let resp = root.contactsModule.getLatestContactRequestForContactAsJson(pubKey) let resp = d.contactsModuleInst.getLatestContactRequestForContactAsJson(pubKey)
return JSON.parse(resp) return JSON.parse(resp)
} }
function markAsTrusted(pubKey) { function markAsTrusted(pubKey) {
root.contactsModule.markAsTrusted(pubKey) d.contactsModuleInst.markAsTrusted(pubKey)
} }
function markUntrustworthy(pubKey) { function markUntrustworthy(pubKey) {
root.contactsModule.markUntrustworthy(pubKey) d.contactsModuleInst.markUntrustworthy(pubKey)
} }
function removeTrustStatus(pubKey) { function removeTrustStatus(pubKey) {
root.contactsModule.removeTrustStatus(pubKey) d.contactsModuleInst.removeTrustStatus(pubKey)
} }
function requestContactInfo(publicKey) { function requestContactInfo(publicKey) {
root.contactsModule.requestContactInfo(publicKey) d.contactsModuleInst.requestContactInfo(publicKey)
} }
function getContactPublicKeyByAddress(address) { function getContactPublicKeyByAddress(address) {
@ -129,6 +140,6 @@ QtObject {
} }
function getLinkToProfile(publicKey) { function getLinkToProfile(publicKey) {
return root.contactsModule.shareUserUrlWithData(publicKey) return d.contactsModuleInst.shareUserUrlWithData(publicKey)
} }
} }

View File

@ -20,9 +20,7 @@ QtObject {
readonly property bool fetchingUpdate: aboutModuleInst.fetching readonly property bool fetchingUpdate: aboutModuleInst.fetching
property ContactsStore contactsStore: ContactsStore { property ContactsStore contactsStore: ContactsStore {}
contactsModule: profileSectionModuleInst.contactsModule
}
property AdvancedStore advancedStore: AdvancedStore { property AdvancedStore advancedStore: AdvancedStore {
walletModule: profileSectionModuleInst.walletModule walletModule: profileSectionModuleInst.walletModule