fix(UnfurlingUrls): Fix community invitation when community cannot be fetched

This commit is contained in:
Alex Jbanca 2023-02-27 19:27:37 +02:00 committed by Alex Jbanca
parent 606d30abc6
commit 2accc52b15
2 changed files with 20 additions and 11 deletions

View File

@ -28,6 +28,15 @@ Control {
id: d
property var invitedCommunity
readonly property string communityName: !!d.invitedCommunity ? d.invitedCommunity.name : ""
readonly property string communityDescription: !!d.invitedCommunity ? d.invitedCommunity.description : ""
readonly property string communityImage: !!d.invitedCommunity ? d.invitedCommunity.image : ""
readonly property string communityColor: !!d.invitedCommunity ? d.invitedCommunity.color : ""
readonly property int communityNbMembers: !!d.invitedCommunity ? d.invitedCommunity.nbMembers : 0
readonly property bool communityVerified: false //!!d.invitedCommunity ? d.invitedCommunity.verified : false TODO: add this to the community object if we should support verified communities
readonly property bool communityJoined: !!d.invitedCommunity ? d.invitedCommunity.joined : false
readonly property bool communitySpectated: !!d.invitedCommunity ? d.invitedCommunity.spectated : false
readonly property int margin: 12
readonly property int radius: 16
@ -91,8 +100,8 @@ Control {
Layout.topMargin: 8
Layout.bottomMargin: 8
text: d.invitedCommunity.verifed ? qsTr("Verified community invitation") : qsTr("Community invitation")
color: d.invitedCommunity.verifed ? Theme.palette.primaryColor1 : Theme.palette.baseColor1
text: d.communityVerified ? qsTr("Verified community invitation") : qsTr("Community invitation")
color: d.communityVerified ? Theme.palette.primaryColor1 : Theme.palette.baseColor1
font.weight: Font.Medium
font.pixelSize: 13
}
@ -118,13 +127,13 @@ Control {
Layout.preferredWidth: 40
Layout.preferredHeight: 40
name: d.invitedCommunity.name
name: d.communityName
asset {
width: 40
height: 40
name: d.invitedCommunity.image
color: d.invitedCommunity.color
name: d.communityImage
color: d.communityColor
isImage: true
}
}
@ -135,7 +144,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: d.invitedCommunity.name
text: d.communityName
font.weight: Font.Bold
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pixelSize: 17
@ -145,7 +154,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: d.invitedCommunity.description
text: d.communityDescription
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: Theme.palette.directColor1
}
@ -153,7 +162,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: qsTr("%n member(s)", "", d.invitedCommunity.nbMembers)
text: qsTr("%n member(s)", "", d.communityNbMembers)
font.pixelSize: 13
font.weight: Font.Medium
color: Theme.palette.baseColor1
@ -177,7 +186,7 @@ Control {
radius: d.radius - 1 // We do -1, otherwise there's a gap between border and button
onClicked: {
if (d.invitedCommunity.joined || d.invitedCommunity.spectated) {
if (d.communityJoined || d.communitySpectated) {
root.store.setActiveCommunity(communityId)
} else {
root.store.spectateCommunity(communityId, userProfile.name)

View File

@ -183,10 +183,10 @@ Column {
store: root.store
communityId: invitationData ? invitationData.communityId : ""
anchors.left: parent.left
visible: invitationData && !invitationData.fetching
visible: !!invitationData && !invitationData.fetching
Connections {
enabled: invitationData && invitationData.fetching
enabled: !!invitationData && invitationData.fetching
target: root.store.communitiesModuleInst
function onCommunityAdded(communityId: string) {
if (communityId !== invitationData.communityId) return