References to Global.userProfile removed from multiple components

This commit is contained in:
Michał Cieślak 2024-10-15 14:26:45 +02:00 committed by Michał
parent 8fb9440235
commit 02993196e9
12 changed files with 42 additions and 36 deletions

View File

@ -5,6 +5,8 @@ import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
import AppLayouts.Communities.panels 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Profile.stores 1.0 as ProfileStores
import utils 1.0
@ -15,6 +17,7 @@ import Storybook 1.0
import StatusQ 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
SplitView {
id: root
@ -48,17 +51,6 @@ SplitView {
}
}
// Global.userProfile mock
QtObject {
readonly property string pubKey: "0x043a7ed0e8d1012cf04" // Mike from UsersModel
Component.onCompleted: {
Global.userProfile = this
}
Component.onDestruction: {
Global.userProfile = {}
}
}
MembersTabPanel {
id: membersTabPanelPage
SplitView.fillWidth: true
@ -67,6 +59,12 @@ SplitView {
model: usersModelWithMembershipState
panelType: viewStateSelector.currentValue
rootStore: ChatStores.RootStore {
contactsStore: ProfileStores.ContactsStore {
readonly property string myPublicKey: "0x000"
}
}
onKickUserClicked: {
logs.logEvent("MembersTabPanel::onKickUserClicked", ["id", "name"], arguments)
}

View File

@ -100,14 +100,6 @@ SplitView {
}
}
Component.onCompleted: {
Global.userProfile = {
name: "Anna",
pubKey: "Oxdeadbeef",
icon: ModelsData.collectibles.cryptoPunks
}
}
ListModel {
id: linksModel
ListElement {

View File

@ -150,7 +150,7 @@ Item {
// The admin that initited the pending state can change the state. Actions are not visible for other admins
readonly property bool ctaAllowed: !isRejectedPending && !isAcceptedPending && !isBanPending && !isUnbanPending && !isKickPending
readonly property bool itsMe: model.pubKey.toLowerCase() === Global.userProfile.pubKey.toLowerCase()
readonly property bool itsMe: model.pubKey.toLowerCase() === rootStore.contactsStore.myPublicKey.toLowerCase()
readonly property bool isHovered: memberItem.hovered
readonly property bool canBeBanned: {
if (memberItem.itsMe) {
@ -315,7 +315,6 @@ Item {
Global.openMenu(memberContextMenuComponent, this, {
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname,
myPublicKey: Global.userProfile.pubKey,
publicKey: model.pubKey,
displayName: memberItem.title || model.displayName,
userIcon: icon.name,

View File

@ -496,6 +496,7 @@ StatusSectionLayout {
id: keycardPopup
active: false
sourceComponent: KeycardPopup {
myKeyUid: store.profileStore.keyUid
sharedKeycardModule: root.store.keycardStore.keycardModule.keycardSharedModule
emojiPopup: root.emojiPopup
}

View File

@ -11,7 +11,7 @@ QtObject {
property var globalUtilsInst: globalUtils
property var mainModuleInst: Global.appIsReady? mainModule : null
property string myPublicKey: !!Global.userProfile? Global.userProfile.pubKey : ""
property string myPublicKey: userProfile.pubKey
// contactsModel holds all available contacts
property var contactsModel: contactsModule.contactsModel

View File

@ -17,12 +17,12 @@ QtObject {
}
}
property string pubkey: !!Global.userProfile? Global.userProfile.pubKey : ""
property string icon: !!Global.userProfile? Global.userProfile.icon : ""
property string preferredUsername: !!Global.userProfile? Global.userProfile.preferredName : ""
property string pubkey: userProfile.pubKey
property string icon: userProfile.icon
property string preferredUsername: userProfile.preferredName
readonly property string chainId: mainModule.appNetworkId
property string username: !!Global.userProfile? Global.userProfile.username : ""
property string username: userProfile.username
function setPrefferedEnsUsername(ensName) {
if(!root.ensUsernamesModule)

View File

@ -421,6 +421,7 @@ Item {
rootStore: appMain.rootStore
communityTokensStore: appMain.communityTokensStore
communitiesStore: appMain.communitiesStore
profileStore: appMain.profileStore
devicesStore: appMain.rootStore.profileSectionStore.devicesStore
currencyStore: appMain.currencyStore
walletAssetsStore: appMain.walletAssetsStore
@ -1870,6 +1871,7 @@ Item {
id: keycardPopupForAuthenticationOrSigning
active: false
sourceComponent: KeycardPopup {
myKeyUid: appMain.profileStore.keyUid
sharedKeycardModule: appMain.rootStore.mainModuleInst.keycardSharedModuleForAuthenticationOrSigning
}
@ -1882,6 +1884,7 @@ Item {
id: keycardPopup
active: false
sourceComponent: KeycardPopup {
myKeyUid: appMain.profileStore.keyUid
sharedKeycardModule: appMain.rootStore.mainModuleInst.keycardSharedModule
}

View File

@ -43,6 +43,7 @@ QtObject {
required property AppLayoutStores.RootStore rootStore
required property CommunityTokensStore communityTokensStore
property CommunitiesStore communitiesStore
property ProfileStores.ProfileStore profileStore
property ProfileStores.DevicesStore devicesStore
property CurrenciesStore currencyStore
property WalletStore.WalletAssetsStore walletAssetsStore
@ -446,6 +447,9 @@ QtObject {
Component {
id: contactOutgoingVerificationRequestPopupComponent
OutgoingContactVerificationRequestPopup {
profileStore: root.profileStore
onVerificationRequestCanceled: {
rootStore.contactStore.cancelVerificationRequest(publicKey)
}

View File

@ -10,9 +10,13 @@ import StatusQ.Controls 0.1
import shared.views.chat 1.0
import AppLayouts.Profile.stores 1.0 as ProfileStores
CommonContactDialog {
id: root
property ProfileStores.ProfileStore profileStore
property int verificationStatus
property string verificationChallenge
property string verificationResponse
@ -70,13 +74,13 @@ CommonContactDialog {
id: challengeMessage
timestamp: root.verificationRequestedAt
messageDetails.messageText: root.verificationChallenge
messageDetails.sender.id: Global.userProfile.pubKey
messageDetails.sender.displayName: Global.userProfile.name
messageDetails.sender.profileImage.name: Global.userProfile.icon
messageDetails.sender.id: root.profileStore.pubkey
messageDetails.sender.displayName: root.profileStore.name
messageDetails.sender.profileImage.name: root.profileStore.icon
messageDetails.sender.profileImage.assetSettings.isImage: true
messageDetails.sender.profileImage.colorId: Utils.colorIdForPubkey(Global.userProfile.pubKey)
messageDetails.sender.profileImage.colorHash: Utils.getColorHashAsJson(Global.userProfile.pubKey, !!Global.userProfile.preferredName)
messageDetails.sender.isEnsVerified: !!Global.userProfile.preferredName
messageDetails.sender.profileImage.colorId: Utils.colorIdForPubkey(root.profileStore.pubkey)
messageDetails.sender.profileImage.colorHash: Utils.getColorHashAsJson(root.profileStore.pubkey, !!root.profileStore.preferredName)
messageDetails.sender.isEnsVerified: !!root.profileStore.preferredName
Layout.fillWidth: true
}

View File

@ -11,6 +11,8 @@ import utils 1.0
StatusModal {
id: root
property alias myKeyUid: content.myKeyUid
property var sharedKeycardModule
property var emojiPopup

View File

@ -7,6 +7,8 @@ import "./states"
Item {
id: root
property string myKeyUid
property var sharedKeycardModule
property var emojiPopup
readonly property alias primaryButtonEnabled: d.primaryButtonEnabled
@ -158,6 +160,7 @@ Item {
Component {
id: confirmationComponent
KeycardConfirmation {
myKeyUid: root.myKeyUid
sharedKeycardModule: root.sharedKeycardModule
Component.onCompleted: {

View File

@ -13,6 +13,8 @@ import "../helpers"
Item {
id: root
property string myKeyUid
property var sharedKeycardModule
signal confirmationUpdated(bool value)
@ -73,10 +75,8 @@ Item {
horizontalAlignment: Text.AlignHCenter
Layout.preferredHeight: Constants.keycard.general.titleHeight
text: {
// we need to check userProfile since factory reset flow is also available before user logs in the app
if (!!Global.userProfile &&
!!root.sharedKeycardModule.keyPairForProcessing &&
root.sharedKeycardModule.keyPairForProcessing.keyUid === Global.userProfile.keyUid)
if (!!root.sharedKeycardModule.keyPairForProcessing &&
root.sharedKeycardModule.keyPairForProcessing.keyUid === root.myKeyUid)
return qsTr("Warning, this Keycard stores your main Status profile and\naccounts. A factory reset will permanently delete it.")
return qsTr("A factory reset will delete the key on this Keycard.\nAre you sure you want to do this?")