chore: adapt to new user/member backend models structure

This commit is contained in:
Patryk Osmaczko 2022-06-07 20:32:55 +02:00 committed by Michał Cieślak
parent 036212c5e3
commit 869db82f86
2 changed files with 39 additions and 29 deletions

View File

@ -48,30 +48,35 @@ StatusListItem {
*/ */
property string userName: "" property string userName: ""
/*! /*!
\qmlproperty string StatusMemberListItem::chatKey \qmlproperty string StatusMemberListItem::pubKey
This property holds the chat key of the member represented. This property holds the chat public key of the member represented.
*/ */
property string chatKey: "" property string pubKey: ""
/*! /*!
\qmlproperty string StatusMemberListItem::isMutualContact \qmlproperty string StatusMemberListItem::isContact
This property holds if the member represented is a mutual contact. This property holds if the member represented is contact.
*/ */
property bool isMutualContact: false property bool isContact: false
/*! /*!
\qmlproperty string StatusMemberListItem::trustIndicator \qmlproperty string StatusMemberListItem::isVerified
This property holds the trust indicator of the member represented. Possible values are: This property holds if the member represented is verified contact.
\list
\li StatusContactVerificationIcons.TrustedType.None
\li StatusContactVerificationIcons.TrustedType.Verified
\li StatusContactVerificationIcons.TrustedType.Untrustworthy
\endlist
*/ */
property var trustIndicator: StatusContactVerificationIcons.TrustedType.None property bool isVerified: false
/*! /*!
\qmlproperty string StatusMemberListItem::isOnline \qmlproperty string StatusMemberListItem::isUntrustworthy
This property holds if the member represented is untrustworthy.
*/
property bool isUntrustworthy: false
/*!
\qmlproperty string StatusMemberListItem::status
This property holds the connectivity status of the member represented. This property holds the connectivity status of the member represented.
0 - offline
1 - online
2 - doNotDisturb
3 - idle
*/ */
property bool isOnline: false // FIXME: move Constants.userStatus from status-desktop
property int status: 0
/*! /*!
\qmlproperty string StatusMemberListItem::isAdmin \qmlproperty string StatusMemberListItem::isAdmin
This property holds the admin status of the member represented. This property holds the admin status of the member represented.
@ -87,33 +92,37 @@ StatusListItem {
if(root.userName !== "" && root.nickName !== "") if(root.userName !== "" && root.nickName !== "")
compose = "(" + root.userName + ")" compose = "(" + root.userName + ")"
if(compose !== "" && root.chatKey !== "") if(compose !== "" && root.pubKey !== "")
// Composition // Composition
compose += " • " + composeShortKeyChat(root.chatKey) compose += " • " + composeShortKeyChat(root.pubKey)
else if(root.chatKey !== "") else if(root.pubKey !== "")
compose = composeShortKeyChat(root.chatKey) compose = composeShortKeyChat(root.pubKey)
return compose return compose
} }
// Short keychat composition: // Short keychat composition:
function composeShortKeyChat(chatKey) { function composeShortKeyChat(pubKey) {
return chatKey.substring(0, 5) + "..." + chatKey.substring(chatKey.length - 3) return pubKey.substring(0, 5) + "..." + pubKey.substring(pubKey.length - 3)
} }
} }
// root object settings: // root object settings:
title: (root.nickName === "") ? root.userName : root.nickName title: (root.nickName === "") ? root.userName : root.nickName
statusListItemTitleIcons.sourceComponent: StatusContactVerificationIcons { statusListItemTitleIcons.sourceComponent: StatusContactVerificationIcons {
isMutualContact: root.isMutualContact isMutualContact: root.isContact
trustIndicator: root.trustIndicator trustIndicator: {
if (root.isVerified) return StatusContactVerificationIcons.TrustedType.Verified
else if (root.isUntrustworthy) return StatusContactVerificationIcons.TrustedType.Untrustworthy
return StatusContactVerificationIcons.TrustedType.None
}
} }
subTitle: d.composeSubtitile() subTitle: d.composeSubtitile()
statusListItemSubTitle.font.pixelSize: 10 statusListItemSubTitle.font.pixelSize: 10
icon.isLetterIdenticon: !root.image.source.toString() icon.isLetterIdenticon: !root.image.source.toString()
statusListItemIcon.badge.visible: true statusListItemIcon.badge.visible: true
statusListItemIcon.badge.color: root.isOnline ? Theme.palette.successColor1 : Theme.palette.baseColor1 statusListItemIcon.badge.color: root.status === 1 ? Theme.palette.successColor1 : Theme.palette.baseColor1 // FIXME
color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4 color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4
// Default sizes / positions by design // Default sizes / positions by design

View File

@ -409,13 +409,14 @@ Item {
} }
nickName: model.nickName nickName: model.nickName
userName: model.name userName: model.name
chatKey: root.compressedKeyGetter(model.publicId) pubKey: root.compressedKeyGetter(model.publicId)
trustIndicator: model.trustIndicator isVerified: false // FIXME
isMutualContact: model.isMutualContact isUntrustworthy: false // FIXME
isContact: model.isMutualContact
image.source: model.icon image.source: model.icon
image.isIdenticon: model.isIdenticon image.isIdenticon: model.isIdenticon
icon.color: Theme.palette.userCustomizationColors[root.colorIdForPubkeyGetter(model.publicId)] icon.color: Theme.palette.userCustomizationColors[root.colorIdForPubkeyGetter(model.publicId)]
isOnline: model.onlineStatus status: model.onlineStatus
statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4 statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4
ringSettings.ringSpecModel: root.ringSpecModelGetter(publicId) ringSettings.ringSpecModel: root.ringSpecModelGetter(publicId)
color: (sensor.containsMouse || highlighted) ? Theme.palette.baseColor2 : "transparent" color: (sensor.containsMouse || highlighted) ? Theme.palette.baseColor2 : "transparent"