refactor(@desktop/general): qml updated according to the new `userProfile` instance

This commit is contained in:
Sale Djenic 2021-10-29 20:06:18 +02:00 committed by Jakub
parent 188d38be39
commit cc5ccbc951
22 changed files with 42 additions and 47 deletions

View File

@ -179,7 +179,7 @@ StatusAppThreePanelLayout {
CommunityUserListPanel {
currentTime: chatColumn.currentTime
messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: root.rootStore.profileModelInst.profile.pubKey
profilePubKey: userProfile.pubKey
contactsList: root.rootStore.profileModelInst.contacts.list
community: root.rootStore.chatsModelInst.communities.activeCommunity
currentUserName: Utils.removeStatusEns(root.rootStore.profileModelInst.ens.preferredUsername
@ -194,7 +194,7 @@ StatusAppThreePanelLayout {
currentTime: chatColumn.currentTime
userList: chatColumn.userList
messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: root.rootStore.profileModelInst.profile.pubKey
profilePubKey: userProfile.pubKey
contactsList: root.rootStore.profileModelInst.contacts.list
isOnline: root.rootStore.chatsModelInst.isOnline
}

View File

@ -35,7 +35,7 @@ Loader {
return profileImageSource
}
identiconImage.showLoadingIndicator = false
return !isCurrentUser || isReplyImage ? identicon : profileModel.profile.identicon
return !isCurrentUser || isReplyImage ? identicon : userProfile.thumbnailImage
}
smooth: false
antialiasing: true

View File

@ -150,7 +150,7 @@ Item {
id: menuButton
width: 32
height: 32
visible: model.pubKey.toLowerCase() !== profileModel.profile.pubKey.toLowerCase()
visible: model.pubKey.toLowerCase() !== userProfile.pubKey.toLowerCase()
icon.name: "more"
type: StatusFlatRoundButton.Type.Secondary
onClicked: {
@ -171,7 +171,7 @@ Item {
text: qsTrId("view-profile")
icon.name: "channel"
onTriggered: openPopup(profilePopup, {
noFooter: profileModel.profile.pubKey !== model.pubKey,
noFooter: userProfile.pubKey !== model.pubKey,
userName: model.userName,
fromAuthor: model.pubKey,
identicon: memberItem.image.source,

View File

@ -38,12 +38,11 @@ ModalPopup {
contactList.membersData.append({
//% "(You)"
name: popup.store.profileModelInst.profile.username + " " + qsTrId("(you)"),
pubKey: popup.store.profileModelInst.profile.pubKey,
name: userProfile.username + " " + qsTrId("(you)"),
pubKey: userProfile.pubKey,
address: "",
identicon: popup.store.profileModelInst.profile.identicon,
//TODO move to store
thumbnailImage: profileModule.model.thumbnailImage,
identicon: userProfile.identicon,
thumbnailImage: userProfile.thumbnailImage,
isUser: true
});
noContactsRect.visible = !popup.store.profileModelInst.contacts.list.hasAddedContacts();

View File

@ -60,7 +60,7 @@ ModalPopup {
onOpened: {
addMembers = false;
if (popup.channel) {
popup.isAdmin = popup.channel.isAdmin(popup.store.profileModelInst.profile.pubKey)
popup.isAdmin = popup.channel.isAdmin(userProfile.pubKey)
}
btnSelectMembers.enabled = false;
resetSelectedMembers();
@ -320,7 +320,7 @@ ModalPopup {
font.pixelSize: 17
StyledText {
visible: model.publicKey === profileModel.profile.pubKey
visible: model.publicKey === userProfile.pubKey
anchors.left: parent.right
anchors.leftMargin: 5
//% "(You)"

View File

@ -22,7 +22,7 @@ ModalPopup {
case Constants.chatTypePublic: return false
case Constants.chatTypeStatusUpdate: return false
case Constants.chatTypeOneToOne: return true
case Constants.chatTypePrivateGroupChat: return popup.rootStore.chatsModelInst.channelView.activeChannel.isAdmin(profileModel.profile.pubKey)
case Constants.chatTypePrivateGroupChat: return popup.rootStore.chatsModelInst.channelView.activeChannel.isAdmin(userProfile.pubKey)
case Constants.chatTypeCommunity: return popup.rootStore.chatsModelInst.communities.activeCommunity.admin
default: return false
}

View File

@ -64,7 +64,7 @@ ModalPopup {
anchors.left: parent.left
anchors.leftMargin: 2
anchors.verticalCenter: parent.verticalCenter
source: appMain.getProfileImage(popup.store.profileModuleInst.model.pubKey)
source: appMain.getProfileImage(userProfile.pubKey)
}
StyledText {

View File

@ -54,7 +54,7 @@ StatusModal {
isEnsVerified = chatsModel.ensView.isEnsVerified(this.fromAuthor)
isBlocked = profileModel.contacts.isContactBlocked(this.fromAuthor);
alias = chatsModel.alias(this.fromAuthor) || ""
isCurrentUser = profileModel.profile.pubKey === this.fromAuthor
isCurrentUser = userProfile.pubKey === this.fromAuthor
showFooter = _showFooter;
popup.open()
}

View File

@ -356,7 +356,7 @@ StatusModal {
chatsModel.transactions.acceptRequestTransaction(transactionId,
messageId,
root.store.profileModelInst.profile.pubKey + transactionId.substr(2))
userProfile.pubKey + transactionId.substr(2))
//% "Transaction pending..."
toastMessage.title = qsTrId("ens-transaction-pending")

View File

@ -200,7 +200,7 @@ StatusModal {
let error
if (access === Constants.communityChatOnRequestAccess && !root.isMember) {
error = root.store.chatsModelInst.communities.requestToJoinCommunity(root.communityId,
root.store.profileModelInst.profile.ensVerified ? root.store.profileModelInst.profile.username : "")
root.store.profileModelInst.profile.ensVerified ? userProfile.username : "")
if (!error) {
enabled = false
//% "Pending"

View File

@ -427,8 +427,7 @@ Item {
}
EmptyChatPanel {
//TODO move profileModule to store
onShareChatKeyClicked: openProfilePopup(root.rootStore.profileModelInst.profile.username, root.rootStore.profileModelInst.profile.pubKey, profileModule.model.thumbnailImage);
onShareChatKeyClicked: openProfilePopup(userProfile.username, userProfile.pubKey, userProfile.thumbnailImage);
}
Loader {

View File

@ -30,7 +30,7 @@ Item {
if (!!root.store) {
switch (root.store.chatsModelInst.channelView.activeChannel.chatType) {
case Constants.chatTypeOneToOne: return true
case Constants.chatTypePrivateGroupChat: return root.store.chatsModelInst.channelView.activeChannel.isAdmin(root.store.profileModelInst.profile.pubKey) ? true : isCurrentUser
case Constants.chatTypePrivateGroupChat: return root.store.chatsModelInst.channelView.activeChannel.isAdmin(userProfile.pubKey) ? true : isCurrentUser
case Constants.chatTypePublic: return isCurrentUser
case Constants.chatTypeCommunity: return root.store.chatsModelInst.communities.activeCommunity.admin ? true : isCurrentUser
case Constants.chatTypeStatusUpdate: return false

View File

@ -309,7 +309,7 @@ Item {
}
else if (rectangleBubble.state === "requestToJoin") {
error = root.store.chatsModelInst.communities.requestToJoinCommunity(communityId,
root.store.profileModelInst.profile.ensVerified ? root.store.profileModelInst.profile.username : "")
root.store.profileModelInst.profile.ensVerified ? userProfile.username : "")
if (!error) {
rectangleBubble.isPendingRequest = root.store.chatsModelInst.communities.isCommunityRequestPending(communityId)
}

View File

@ -319,7 +319,7 @@ StatusPopupMenu {
case Constants.chatTypePublic: return false
case Constants.chatTypeStatusUpdate: return false
case Constants.chatTypeOneToOne: return true
case Constants.chatTypePrivateGroupChat: return root.store.chatsModelInst.channelView.activeChannel.isAdmin(root.store.profileModelInst.profile.pubKey)
case Constants.chatTypePrivateGroupChat: return root.store.chatsModelInst.channelView.activeChannel.isAdmin(userProfile.pubKey)
case Constants.chatTypeCommunity: return root.store.chatsModelInst.communities.activeCommunity.admin
}

View File

@ -100,7 +100,7 @@ Column {
property int replyMessageIndex: !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageIndex(responseTo) : -1
property string repliedMessageAuthor: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName") : "" : "";
property string repliedMessageAuthorPubkey: replyMessageIndex > -1 ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "publicKey") : "";
property bool repliedMessageAuthorIsCurrentUser: replyMessageIndex > -1 ? repliedMessageAuthorPubkey === profileModel.profile.pubKey : "";
property bool repliedMessageAuthorIsCurrentUser: replyMessageIndex > -1 ? repliedMessageAuthorPubkey === userProfile.pubKey : "";
property bool repliedMessageIsEdited: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "isEdited") === "true" : false : false;
property string repliedMessageContent: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message") : "" : "";
property int repliedMessageType: replyMessageIndex > -1 ? !!root.chatsModel ? parseInt(root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")) : 0 : 0;
@ -140,7 +140,7 @@ Column {
}
byEmoji[reaction.emojiId].count++;
byEmoji[reaction.emojiId].fromAccounts.push(root.chatsModel.userNameOrAlias(reaction.from));
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === root.rootStore.profileModelInst.profile.pubKey) {
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === userProfile.pubKey) {
byEmoji[reaction.emojiId].currentUserReacted = true
}

View File

@ -36,7 +36,7 @@ Item {
property bool isText: true
property var clickMessage: function(){}
property string identicon: store.identicon
//property string identicon: profileModel.profile.identicon
//property string identicon: userProfile.thumbnailImage
property int timestamp: 1577872140
property var messageStore

View File

@ -43,7 +43,7 @@ ScrollView {
if(parentPopup){
popup.parentPopup = parentPopup;
}
popup.openPopup(root.store.profileModelInst.profile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
popup.openPopup(userProfile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
}
StatusImageModal {

View File

@ -82,7 +82,7 @@ QtObject {
property int replyMessageIndex: chatsModel.messageView.messageList.getMessageIndex(responseTo);
property string repliedMessageAuthor: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName") : "";
property string repliedMessageAuthorPubkey: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "publicKey") : "";
property bool repliedMessageAuthorIsCurrentUser: replyMessageIndex > -1 ? repliedMessageAuthorPubkey === profileModel.profile.pubKey : "";
property bool repliedMessageAuthorIsCurrentUser: replyMessageIndex > -1 ? repliedMessageAuthorPubkey === userProfile.pubKey : "";
property bool repliedMessageIsEdited: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "isEdited") === "true" : false;
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message") : "";
property int repliedMessageType: replyMessageIndex > -1 ? parseInt(chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")) : 0;
@ -122,7 +122,7 @@ QtObject {
}
byEmoji[reaction.emojiId].count++;
byEmoji[reaction.emojiId].fromAccounts.push(chatsModel.userNameOrAlias(reaction.from));
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === profileModel.profile.pubKey) {
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === userProfile.pubKey) {
byEmoji[reaction.emojiId].currentUserReacted = true
}

View File

@ -47,9 +47,8 @@ Item {
}
function getProfileImage(pubkey, isCurrentUser, useLargeImage) {
if (isCurrentUser || (isCurrentUser === undefined && pubkey === profileModel.profile.pubKey)) {
//TODO move profileModule to store
return profileModule.model.thumbnailImage
if (isCurrentUser || (isCurrentUser === undefined && pubkey === userProfile.pubKey)) {
return userProfile.thumbnailImage
}
const index = profileModel.contacts.list.getContactIndexByPubkey(pubkey)
@ -131,7 +130,7 @@ Item {
if(parentPopup){
popup.parentPopup = parentPopup;
}
popup.openPopup(profileModule.model.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
popup.openPopup(userProfile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
profilePopupOpened = true
}
@ -355,19 +354,18 @@ Item {
navBarProfileButton: StatusNavBarTabButton {
id: profileButton
property bool opened: false
//TODO move profileModule to store
icon.source: profileModule.model.thumbnailImage || ""
icon.source: userProfile.thumbnailImage
badge.visible: true
badge.anchors.rightMargin: 4
badge.anchors.topMargin: 25
badge.implicitHeight: 15
badge.implicitWidth: 15
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
//badge.color: profileModule.model.sendUserStatus ? Style.current.green : Style.current.midGrey
badge.color: appMain.rootStore.profileModelInst.profile.sendUserStatus ? Style.current.green : Style.current.midGrey
badge.color: {
return userProfile.sendUserStatus ? Style.current.green : Style.current.midGrey
/*
// Use this code once support for custom user status is added
switch(profileModel.profile.currentUserStatus){
switch(userProfile.currentUserStatus){
case Constants.statusType_Online:
return Style.current.green;
case Constants.statusType_DoNotDisturb:
@ -375,6 +373,7 @@ Item {
default:
return Style.current.midGrey;
}*/
}
badge.border.width: 3
onClicked: {
userStatusContextMenu.opened ?

View File

@ -45,7 +45,7 @@ Item {
root.validationError = qsTr("Enter a valid chat key or ENS username");
pubKey = ""
ensUsername = "";
} else if (profileModel.profile.pubKey === chatKey.text) {
} else if (userProfile.pubKey === chatKey.text) {
//% "Can't chat with yourself"
root.validationError = qsTrId("can-t-chat-with-yourself");
} else {
@ -101,7 +101,7 @@ Item {
searchResults.address = "";
searchResults.showProfileNotFoundMessage = true
} else {
if (profileModel.profile.pubKey === resolvedPubKey) {
if (userProfile.pubKey === resolvedPubKey) {
//% "Can't chat with yourself"
root.validationError = qsTrId("can-t-chat-with-yourself");
} else {

View File

@ -30,12 +30,12 @@ PopupMenu {
anchors.top: parent.top
anchors.topMargin: 4
anchors.horizontalCenter: parent.horizontalCenter
image.source: profileModule.model.thumbnailImage || ""
image.source: userProfile.thumbnailImage || ""
image.isIdenticon: true
}
StyledText {
id: username
text: Utils.removeStatusEns(root.store.profileModelInst.ens.preferredUsername || profileModule.model.username)
text: Utils.removeStatusEns(profileModel.ens.preferredUsername || userProfile.username)
elide: Text.ElideRight
maximumLineCount: 3
horizontalAlignment: Text.AlignHCenter
@ -71,8 +71,7 @@ PopupMenu {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
//TODO move profileModule to store
openProfilePopup(profileModule.model.username, profileModule.model.pubKey, profileModule.model.thumbnailImage || "");
openProfilePopup(userProfile.username, userProfile.pubKey, userProfile.thumbnailImage);
root.close()
}
}
@ -87,7 +86,7 @@ PopupMenu {
Action {
text: qsTr("Online")
onTriggered: {
if (root.store.profileModelInst.profile.sendUserStatus != true) {
if (userProfile.sendUserStatus != true) {
root.store.profileModelInst.profile.setSendUserStatus(true)
}
root.close()
@ -101,7 +100,7 @@ PopupMenu {
Action {
text: qsTr("Offline")
onTriggered: {
if (root.store.profileModelInst.profile.sendUserStatus != false) {
if (userProfile.sendUserStatus != false) {
root.store.profileModelInst.profile.setSendUserStatus(false)
}
root.close()

View File

@ -861,8 +861,7 @@ Rectangle {
anchors.leftMargin: Style.current.smallPadding
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
//TODO move thumbnail image to store
image.source: profileModule.model.thumbnailImage || profileModule.model.identicon
image.source: userProfile.thumbnailImage
image.isIdenticon: true
visible: control.isStatusUpdateInput
}