Access to user profile encapsulated in profile store
This commit is contained in:
parent
dc3a1ca39b
commit
c4828a094b
|
@ -35,7 +35,7 @@ QtObject {
|
|||
// Each `ChatLayout` has its own chatCommunitySectionModule
|
||||
// (on the backend chat and community sections share the same module since they are actually the same)
|
||||
property var chatCommunitySectionModule
|
||||
readonly property var sectionDetails: _d.sectionDetailsInstantiator.count ? _d.sectionDetailsInstantiator.objectAt(0) : null
|
||||
readonly property var sectionDetails: d.sectionDetailsInstantiator.count ? d.sectionDetailsInstantiator.objectAt(0) : null
|
||||
|
||||
property var communityItemsModel: chatCommunitySectionModule.model
|
||||
|
||||
|
@ -148,9 +148,9 @@ QtObject {
|
|||
|
||||
readonly property string overviewChartData: chatCommunitySectionModule.overviewChartData
|
||||
|
||||
readonly property bool isUserAllowedToSendMessage: _d.isUserAllowedToSendMessage
|
||||
readonly property string chatInputPlaceHolderText: _d.chatInputPlaceHolderText
|
||||
readonly property var oneToOneChatContact: _d.oneToOneChatContact
|
||||
readonly property bool isUserAllowedToSendMessage: d.isUserAllowedToSendMessage
|
||||
readonly property string chatInputPlaceHolderText: d.chatInputPlaceHolderText
|
||||
readonly property var oneToOneChatContact: d.oneToOneChatContact
|
||||
// Since qml component doesn't follow encaptulation from the backend side, we're introducing
|
||||
// a method which will return appropriate chat content module for selected chat/channel
|
||||
function currentChatContentModule() {
|
||||
|
@ -288,8 +288,6 @@ QtObject {
|
|||
property var communitiesModuleInst: communitiesModule
|
||||
property var communitiesList: communitiesModuleInst.model
|
||||
|
||||
property var userProfileInst: userProfile
|
||||
|
||||
property string signingPhrase: walletSection.signingPhrase
|
||||
|
||||
property string channelEmoji: chatCommunitySectionModule && chatCommunitySectionModule.emoji ? chatCommunitySectionModule.emoji : ""
|
||||
|
@ -306,7 +304,7 @@ QtObject {
|
|||
|
||||
readonly property int loginType: getLoginType()
|
||||
|
||||
property string name: userProfileInst.name
|
||||
property string name: d.userProfileInst.name
|
||||
|
||||
property StickersStore stickersStore: StickersStore {
|
||||
stickersModule: stickersModuleInst
|
||||
|
@ -317,7 +315,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function isCurrentUser(pubkey) {
|
||||
return userProfileInst.pubKey === pubkey
|
||||
return d.userProfileInst.pubKey === pubkey
|
||||
}
|
||||
|
||||
function displayName(name, pubkey) {
|
||||
|
@ -325,7 +323,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function myPublicKey() {
|
||||
return userProfileInst.pubKey
|
||||
return d.userProfileInst.pubKey
|
||||
}
|
||||
|
||||
function createCommunity(args = {
|
||||
|
@ -601,12 +599,12 @@ QtObject {
|
|||
}
|
||||
|
||||
function getLoginType() {
|
||||
if(!userProfileInst)
|
||||
if(!d.userProfileInst)
|
||||
return Constants.LoginType.Password
|
||||
|
||||
if(userProfileInst.usingBiometricLogin)
|
||||
if(d.userProfileInst.usingBiometricLogin)
|
||||
return Constants.LoginType.Biometrics
|
||||
if(userProfileInst.isKeycardUser)
|
||||
if(d.userProfileInst.isKeycardUser)
|
||||
return Constants.LoginType.Keycard
|
||||
return Constants.LoginType.Password
|
||||
}
|
||||
|
@ -638,7 +636,10 @@ QtObject {
|
|||
}
|
||||
|
||||
readonly property QtObject _d: QtObject {
|
||||
id: _d
|
||||
id: d
|
||||
|
||||
readonly property var userProfileInst: userProfile
|
||||
|
||||
readonly property var sectionDetailsInstantiator: Instantiator {
|
||||
model: SortFilterProxyModel {
|
||||
sourceModel: mainModuleInst.sectionsModel
|
||||
|
@ -664,51 +665,51 @@ QtObject {
|
|||
readonly property bool amIMember: chatCommunitySectionModule ? chatCommunitySectionModule.amIMember : false
|
||||
|
||||
property var oneToOneChatContact: undefined
|
||||
readonly property string oneToOneChatContactName: !!_d.oneToOneChatContact ? ProfileUtils.displayName(_d.oneToOneChatContact.localNickname,
|
||||
_d.oneToOneChatContact.name,
|
||||
_d.oneToOneChatContact.displayName,
|
||||
_d.oneToOneChatContact.alias) : ""
|
||||
readonly property string oneToOneChatContactName: !!d.oneToOneChatContact ? ProfileUtils.displayName(d.oneToOneChatContact.localNickname,
|
||||
d.oneToOneChatContact.name,
|
||||
d.oneToOneChatContact.displayName,
|
||||
d.oneToOneChatContact.alias) : ""
|
||||
|
||||
//Update oneToOneChatContact when the contact is updated
|
||||
readonly property var myContactsModelConnection: Connections {
|
||||
target: root.contactsStore.myContactsModel ?? null
|
||||
enabled: _d.activeChatType === Constants.chatType.oneToOne
|
||||
enabled: d.activeChatType === Constants.chatType.oneToOne
|
||||
|
||||
function onItemChanged(pubKey) {
|
||||
if (pubKey === _d.activeChatId) {
|
||||
_d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
if (pubKey === d.activeChatId) {
|
||||
d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var receivedContactsReqModelConnection: Connections {
|
||||
target: root.contactsStore.receivedContactRequestsModel ?? null
|
||||
enabled: _d.activeChatType === Constants.chatType.oneToOne
|
||||
enabled: d.activeChatType === Constants.chatType.oneToOne
|
||||
|
||||
function onItemChanged(pubKey) {
|
||||
if (pubKey === _d.activeChatId) {
|
||||
_d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
if (pubKey === d.activeChatId) {
|
||||
d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var sentContactReqModelConnection: Connections {
|
||||
target: root.contactsStore.sentContactRequestsModel ?? null
|
||||
enabled: _d.activeChatType === Constants.chatType.oneToOne
|
||||
enabled: d.activeChatType === Constants.chatType.oneToOne
|
||||
|
||||
function onItemChanged(pubKey) {
|
||||
if (pubKey === _d.activeChatId) {
|
||||
_d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
if (pubKey === d.activeChatId) {
|
||||
d.oneToOneChatContact = Utils.getContactDetailsAsJson(pubKey, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool isUserAllowedToSendMessage: {
|
||||
if (_d.activeChatType === Constants.chatType.oneToOne && _d.oneToOneChatContact) {
|
||||
return _d.oneToOneChatContact.contactRequestState === Constants.ContactRequestState.Mutual
|
||||
} else if (_d.activeChatType === Constants.chatType.privateGroupChat) {
|
||||
return _d.amIMember
|
||||
} else if (_d.activeChatType === Constants.chatType.communityChat) {
|
||||
if (d.activeChatType === Constants.chatType.oneToOne && d.oneToOneChatContact) {
|
||||
return d.oneToOneChatContact.contactRequestState === Constants.ContactRequestState.Mutual
|
||||
} else if (d.activeChatType === Constants.chatType.privateGroupChat) {
|
||||
return d.amIMember
|
||||
} else if (d.activeChatType === Constants.chatType.communityChat) {
|
||||
return currentChatContentModule().chatDetails.canPost
|
||||
}
|
||||
|
||||
|
@ -716,10 +717,10 @@ QtObject {
|
|||
}
|
||||
|
||||
readonly property string chatInputPlaceHolderText: {
|
||||
if(!_d.isUserAllowedToSendMessage && _d.activeChatType === Constants.chatType.privateGroupChat) {
|
||||
if(!d.isUserAllowedToSendMessage && d.activeChatType === Constants.chatType.privateGroupChat) {
|
||||
return qsTr("You need to be a member of this group to send messages")
|
||||
} else if(!_d.isUserAllowedToSendMessage && _d.activeChatType === Constants.chatType.oneToOne) {
|
||||
return qsTr("Add %1 as a contact to send a message").arg(_d.oneToOneChatContactName)
|
||||
} else if(!d.isUserAllowedToSendMessage && d.activeChatType === Constants.chatType.oneToOne) {
|
||||
return qsTr("Add %1 as a contact to send a message").arg(d.oneToOneChatContactName)
|
||||
}
|
||||
|
||||
return qsTr("Message")
|
||||
|
@ -727,8 +728,8 @@ QtObject {
|
|||
|
||||
//Update oneToOneChatContact when activeChat id changes
|
||||
Binding on oneToOneChatContact {
|
||||
when: _d.activeChatId && _d.activeChatType === Constants.chatType.oneToOne
|
||||
value: Utils.getContactDetailsAsJson(_d.activeChatId, false)
|
||||
when: d.activeChatId && d.activeChatType === Constants.chatType.oneToOne
|
||||
value: Utils.getContactDetailsAsJson(d.activeChatId, false)
|
||||
restoreMode: Binding.RestoreBindingOrValue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ import SortFilterProxyModel 0.2
|
|||
|
||||
import AppLayouts.Communities.popups 1.0
|
||||
import AppLayouts.Communities.panels 1.0
|
||||
import AppLayouts.Profile.stores 1.0
|
||||
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
||||
import AppLayouts.Chat.stores 1.0 as ChatStores
|
||||
|
||||
import "../helpers"
|
||||
import "../controls"
|
||||
import "../popups"
|
||||
import "../panels"
|
||||
import "../../Wallet"
|
||||
import "../stores"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
@ -40,9 +40,9 @@ Item {
|
|||
property var parentModule
|
||||
|
||||
property SharedStores.RootStore sharedRootStore
|
||||
property RootStore rootStore
|
||||
property CreateChatPropertiesStore createChatPropertiesStore
|
||||
property ContactsStore contactsStore
|
||||
property ChatStores.RootStore rootStore
|
||||
property ChatStores.CreateChatPropertiesStore createChatPropertiesStore
|
||||
property ProfileStores.ContactsStore contactsStore
|
||||
property var emojiPopup
|
||||
property var stickersPopup
|
||||
|
||||
|
@ -101,11 +101,11 @@ Item {
|
|||
model: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.urlsModel : null
|
||||
}
|
||||
|
||||
readonly property UsersStore activeUsersStore: UsersStore {
|
||||
readonly property ChatStores.UsersStore activeUsersStore: ChatStores.UsersStore {
|
||||
usersModule: !!d.activeChatContentModule ? d.activeChatContentModule.usersModule : null
|
||||
}
|
||||
|
||||
readonly property MessageStore activeMessagesStore: MessageStore {
|
||||
readonly property ChatStores.MessageStore activeMessagesStore: ChatStores.MessageStore {
|
||||
messageModule: d.activeChatContentModule ? d.activeChatContentModule.messagesModule : null
|
||||
chatSectionModule: root.rootStore.chatCommunitySectionModule
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ Item {
|
|||
}
|
||||
|
||||
onKeyUpPress: {
|
||||
d.activeMessagesStore.setEditModeOnLastMessage(root.rootStore.userProfileInst.pubKey)
|
||||
d.activeMessagesStore.setEditModeOnLastMessage(root.contactsStore.myPublicKey)
|
||||
}
|
||||
|
||||
onLinkPreviewReloaded: (link) => d.activeChatContentModule.inputAreaModule.reloadLinkPreview(link)
|
||||
|
|
|
@ -8,8 +8,6 @@ import SortFilterProxyModel 0.2
|
|||
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
||||
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
||||
|
||||
import "../Profile/stores"
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
|
@ -27,12 +25,12 @@ QtObject {
|
|||
|
||||
readonly property int loginType: getLoginType()
|
||||
function getLoginType() {
|
||||
if(!userProfileInst)
|
||||
if(!d.userProfileInst)
|
||||
return Constants.LoginType.Password
|
||||
|
||||
if(userProfileInst.usingBiometricLogin)
|
||||
if(d.userProfileInst.usingBiometricLogin)
|
||||
return Constants.LoginType.Biometrics
|
||||
if(userProfileInst.isKeycardUser)
|
||||
if(d.userProfileInst.isKeycardUser)
|
||||
return Constants.LoginType.Keycard
|
||||
return Constants.LoginType.Password
|
||||
}
|
||||
|
@ -136,7 +134,7 @@ QtObject {
|
|||
appSearchModule: root.mainModuleInst.appSearchModule
|
||||
}
|
||||
|
||||
property ProfileSectionStore profileSectionStore: ProfileSectionStore {
|
||||
property ProfileStores.ProfileSectionStore profileSectionStore: ProfileStores.ProfileSectionStore {
|
||||
}
|
||||
|
||||
property var chatSearchModel: mainModuleInst.chatSearchModel
|
||||
|
@ -149,7 +147,7 @@ QtObject {
|
|||
mainModuleInst.switchTo(sectionId, chatId)
|
||||
}
|
||||
|
||||
property var userProfileInst: userProfile
|
||||
|
||||
readonly property var accounts: walletSectionAccounts.accounts
|
||||
|
||||
property ProfileStores.ContactsStore contactStore: profileSectionStore.contactsStore
|
||||
|
@ -166,6 +164,12 @@ QtObject {
|
|||
|
||||
property var flatNetworks: networksModule.flatNetworks
|
||||
|
||||
readonly property QtObject _d: QtObject {
|
||||
id: d
|
||||
|
||||
readonly property var userProfileInst: userProfile
|
||||
}
|
||||
|
||||
function getEtherscanLink(chainID) {
|
||||
return networksModule.getBlockExplorerURL(chainID)
|
||||
}
|
||||
|
@ -207,7 +211,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function setCurrentUserStatus(newStatus) {
|
||||
if (userProfileInst && userProfileInst.currentUserStatus !== newStatus) {
|
||||
if (d.userProfileInst && d.userProfileInst.currentUserStatus !== newStatus) {
|
||||
mainModuleInst.setCurrentUserStatus(newStatus)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,12 @@ import StatusQ.Layout 0.1
|
|||
import StatusQ.Popups 0.1
|
||||
import StatusQ.Popups.Dialog 0.1
|
||||
|
||||
import AppLayouts.stores 1.0 as AppStores
|
||||
import AppLayouts.Chat.stores 1.0 as ChatStores
|
||||
import AppLayouts.Communities.stores 1.0
|
||||
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
||||
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
||||
import AppLayouts.Wallet.popups 1.0 as WalletPopups
|
||||
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
||||
import AppLayouts.stores 1.0 as AppStores
|
||||
|
||||
import mainui.activitycenter.stores 1.0
|
||||
import mainui.activitycenter.popups 1.0
|
||||
|
@ -59,7 +60,9 @@ Item {
|
|||
currencyStore: appMain.currencyStore
|
||||
}
|
||||
|
||||
property AppStores.RootStore rootStore: AppStores.RootStore {}
|
||||
readonly property AppStores.RootStore rootStore: AppStores.RootStore {}
|
||||
readonly property ProfileStores.ProfileSectionStore profileSectionStore: rootStore.profileSectionStore
|
||||
readonly property ProfileStores.ProfileStore profileStore: profileSectionStore.profileStore
|
||||
|
||||
property ChatStores.RootStore rootChatStore: ChatStores.RootStore {
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
|
@ -106,7 +109,7 @@ Item {
|
|||
rootStore: appMain.rootStore
|
||||
rootChatStore: appMain.rootChatStore
|
||||
communityTokensStore: appMain.communityTokensStore
|
||||
profileStore: appMain.rootStore.profileSectionStore.profileStore
|
||||
profileStore: appMain.profileStore
|
||||
|
||||
sendModalPopup: sendModal
|
||||
}
|
||||
|
@ -651,7 +654,7 @@ Item {
|
|||
walletAssetsStore: appMain.walletAssetsStore
|
||||
sendModalPopup: sendModal
|
||||
|
||||
isWalletEnabled: appMain.rootStore.profileSectionStore.profileStore.isWalletEnabled
|
||||
isWalletEnabled: appMain.profileStore.isWalletEnabled
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -823,16 +826,16 @@ Item {
|
|||
objectName: "statusProfileNavBarTabButton"
|
||||
property bool opened: false
|
||||
|
||||
name: appMain.rootStore.userProfileInst.name
|
||||
icon.source: appMain.rootStore.userProfileInst.icon
|
||||
name: appMain.profileStore.name
|
||||
icon.source: appMain.profileStore.icon
|
||||
implicitWidth: 32
|
||||
implicitHeight: 32
|
||||
identicon.asset.width: width
|
||||
identicon.asset.height: height
|
||||
identicon.asset.useAcronymForLetterIdenticon: true
|
||||
identicon.asset.color: Utils.colorForPubkey(appMain.rootStore.userProfileInst.pubKey)
|
||||
identicon.ringSettings.ringSpecModel: Utils.getColorHashAsJson(appMain.rootStore.userProfileInst.pubKey,
|
||||
appMain.rootStore.userProfileInst.preferredName)
|
||||
identicon.asset.color: Utils.colorForPubkey(appMain.profileStore.pubkey)
|
||||
identicon.ringSettings.ringSpecModel: Utils.getColorHashAsJson(appMain.profileStore.pubkey,
|
||||
appMain.profileStore.preferredName)
|
||||
|
||||
badge.visible: true
|
||||
badge.anchors {
|
||||
|
@ -849,7 +852,7 @@ Item {
|
|||
badge.border.width: 2
|
||||
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
|
||||
badge.color: {
|
||||
switch(appMain.rootStore.userProfileInst.currentUserStatus){
|
||||
switch(appMain.profileStore.currentUserStatus){
|
||||
case Constants.currentUserStatus.automatic:
|
||||
case Constants.currentUserStatus.alwaysOnline:
|
||||
return Style.current.green;
|
||||
|
@ -866,12 +869,12 @@ Item {
|
|||
y: profileButton.y - userStatusContextMenu.height + profileButton.height
|
||||
x: profileButton.x + profileButton.width + 5
|
||||
|
||||
pubKey: appMain.rootStore.userProfileInst.pubKey
|
||||
name: appMain.rootStore.userProfileInst.name
|
||||
icon: appMain.rootStore.userProfileInst.icon
|
||||
isEnsVerified: !!appMain.rootStore.userProfileInst.preferredName
|
||||
pubKey: appMain.profileStore.pubkey
|
||||
name: appMain.profileStore.name
|
||||
icon: appMain.profileStore.icon
|
||||
isEnsVerified: !!appMain.profileStore.preferredName
|
||||
|
||||
currentUserStatus: appMain.rootStore.userProfileInst.currentUserStatus
|
||||
currentUserStatus: appMain.profileStore.currentUserStatus
|
||||
|
||||
onViewProfileRequested: Global.openProfilePopup(pubKey)
|
||||
onCopyLinkRequested: ClipboardUtils.setText(appMain.rootStore.contactStore.getLinkToProfile(pubKey))
|
||||
|
|
|
@ -8,7 +8,6 @@ QtObject {
|
|||
|
||||
property var profileSectionModuleInst: profileSectionModule
|
||||
property var privacyModule: profileSectionModuleInst.privacyModule
|
||||
property var userProfileInst: !!Global.userProfile? Global.userProfile : null
|
||||
property var appSettingsInst: Global.appIsReady && !!appSettings? appSettings : null
|
||||
property var accountSensitiveSettings: Global.appIsReady && !!localAccountSensitiveSettings? localAccountSensitiveSettings : null
|
||||
property real volume: !!appSettingsInst ? appSettingsInst.volume * 0.01 : 0.5
|
||||
|
|
Loading…
Reference in New Issue