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 {
enabled: root.visible
target: root.rootStore.contactsStore.mainModuleInst
target: root.rootStore.contactsStore
function onResolvedENS(resolvedPubKey: string, resolvedAddress: string, uuid: string) {
if (resolvedPubKey === "") {
root.suggestionsDialog.forceHide = false

View File

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

View File

@ -1,47 +1,58 @@
import QtQuick 2.13
import utils 1.0
import QtQuick 2.15
import StatusQ 0.1
import utils 1.0
QtObject {
id: root
property var contactsModule
readonly property QtObject _d: QtObject {
id: d
property var globalUtilsInst: globalUtils
property var mainModuleInst: Global.appIsReady? mainModule : null
readonly property var contactsModuleInst: profileSectionModule.contactsModule
readonly property var mainModuleInst: mainModule
readonly property var globalUtilsInst: globalUtils
Component.onCompleted: {
mainModuleInst.resolvedENS.connect(root.resolvedENS)
}
}
property string myPublicKey: userProfile.pubKey
// contactsModel holds all available contacts
property var contactsModel: contactsModule.contactsModel
property var contactsModel: d.contactsModuleInst.contactsModel
readonly property var contactsModelAdaptor: ContactsModelAdaptor {
allContacts: contactsModel
}
signal resolvedENS(string resolvedPubKey, string resolvedAddress, string uuid)
property var myContactsModel: contactsModelAdaptor.mutualContacts
property var blockedContactsModel: contactsModelAdaptor.blockedContacts
property var receivedContactRequestsModel: contactsModelAdaptor.pendingReceivedRequestContacts
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
readonly property var showcaseContactCommunitiesModel: contactsModule.showcaseContactCommunitiesModel
readonly property var showcaseContactAccountsModel: contactsModule.showcaseContactAccountsModel
readonly property var showcaseContactCollectiblesModel: contactsModule.showcaseContactCollectiblesModel
readonly property var showcaseContactAssetsModel: contactsModule.showcaseContactAssetsModel
readonly property var showcaseContactSocialLinksModel: contactsModule.showcaseContactSocialLinksModel
readonly property var showcaseContactCommunitiesModel: d.contactsModuleInst.showcaseContactCommunitiesModel
readonly property var showcaseContactAccountsModel: d.contactsModuleInst.showcaseContactAccountsModel
readonly property var showcaseContactCollectiblesModel: d.contactsModuleInst.showcaseContactCollectiblesModel
readonly property var showcaseContactAssetsModel: d.contactsModuleInst.showcaseContactAssetsModel
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
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
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.
@ -49,32 +60,32 @@ QtObject {
// property var sentButRejectedContactRequestsModel: contactsModule.sentButRejectedContactRequestsModel
function resolveENS(value) {
root.mainModuleInst.resolveENS(value, "")
d.mainModuleInst.resolveENS(value, "")
}
function generateAlias(pubKey) {
return root.globalUtilsInst.generateAlias(pubKey)
return d.globalUtilsInst.generateAlias(pubKey)
}
function joinPrivateChat(pubKey) {
Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.contactsModule.switchToOrCreateOneToOneChat(pubKey)
d.contactsModuleInst.switchToOrCreateOneToOneChat(pubKey)
}
function unblockContact(pubKey) {
root.contactsModule.unblockContact(pubKey)
d.contactsModuleInst.unblockContact(pubKey)
}
function blockContact(pubKey) {
root.contactsModule.blockContact(pubKey)
d.contactsModuleInst.blockContact(pubKey)
}
function removeContact(pubKey) {
root.contactsModule.removeContact(pubKey)
d.contactsModuleInst.removeContact(pubKey)
}
function changeContactNickname(pubKey, nickname, displayName, isEdit) {
root.contactsModule.changeContactNickname(pubKey, nickname)
d.contactsModuleInst.changeContactNickname(pubKey, nickname)
let message = ""
if (nickname === "") { // removed nickname
@ -91,37 +102,37 @@ QtObject {
}
function sendContactRequest(pubKey, message) {
root.contactsModule.sendContactRequest(pubKey, message)
d.contactsModuleInst.sendContactRequest(pubKey, message)
Global.displaySuccessToastMessage(qsTr("Contact request sent"))
}
function acceptContactRequest(pubKey, contactRequestId) {
root.contactsModule.acceptContactRequest(pubKey, contactRequestId)
d.contactsModuleInst.acceptContactRequest(pubKey, contactRequestId)
}
function dismissContactRequest(pubKey, contactRequestId) {
root.contactsModule.dismissContactRequest(pubKey, contactRequestId)
d.contactsModuleInst.dismissContactRequest(pubKey, contactRequestId)
}
function getLatestContactRequestForContactAsJson(pubKey) {
let resp = root.contactsModule.getLatestContactRequestForContactAsJson(pubKey)
let resp = d.contactsModuleInst.getLatestContactRequestForContactAsJson(pubKey)
return JSON.parse(resp)
}
function markAsTrusted(pubKey) {
root.contactsModule.markAsTrusted(pubKey)
d.contactsModuleInst.markAsTrusted(pubKey)
}
function markUntrustworthy(pubKey) {
root.contactsModule.markUntrustworthy(pubKey)
d.contactsModuleInst.markUntrustworthy(pubKey)
}
function removeTrustStatus(pubKey) {
root.contactsModule.removeTrustStatus(pubKey)
d.contactsModuleInst.removeTrustStatus(pubKey)
}
function requestContactInfo(publicKey) {
root.contactsModule.requestContactInfo(publicKey)
d.contactsModuleInst.requestContactInfo(publicKey)
}
function getContactPublicKeyByAddress(address) {
@ -129,6 +140,6 @@ QtObject {
}
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
property ContactsStore contactsStore: ContactsStore {
contactsModule: profileSectionModuleInst.contactsModule
}
property ContactsStore contactsStore: ContactsStore {}
property AdvancedStore advancedStore: AdvancedStore {
walletModule: profileSectionModuleInst.walletModule