fix(InviteBubble): adapt invite bubble depending on access level
This commit is contained in:
parent
0fe7da0480
commit
b213aa230d
|
@ -1,4 +1,5 @@
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
|
import QtQuick.Dialogs 1.3
|
||||||
import "../../../../../shared"
|
import "../../../../../shared"
|
||||||
import "../../../../../shared/status"
|
import "../../../../../shared/status"
|
||||||
import "../../../../../imports"
|
import "../../../../../imports"
|
||||||
|
@ -9,7 +10,6 @@ Item {
|
||||||
property string communityId
|
property string communityId
|
||||||
property var invitedCommunity
|
property var invitedCommunity
|
||||||
property int innerMargin: 12
|
property int innerMargin: 12
|
||||||
property bool joined: false
|
|
||||||
property bool isLink: false
|
property bool isLink: false
|
||||||
|
|
||||||
id: root
|
id: root
|
||||||
|
@ -125,18 +125,79 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusButton {
|
StatusButton {
|
||||||
|
property int access: invitedCommunity.access
|
||||||
|
property bool isPendingRequest: {
|
||||||
|
if (invitedCommunity.access !== Constants.communityChatOnRequestAccess) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return chatsModel.communities.isCommunityRequestPending(communityId)
|
||||||
|
}
|
||||||
|
id: joinBtn
|
||||||
type: "secondary"
|
type: "secondary"
|
||||||
anchors.top: sep2.bottom
|
anchors.top: sep2.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 44
|
height: 44
|
||||||
enabled: !invitedCommunity.joined && !root.joined
|
enabled: {
|
||||||
//% "Joined"
|
if (invitedCommunity.ensOnly && !profileModel.profile.ensVerified) {
|
||||||
text: root.joined || invitedCommunity.joined || invitedCommunity.isMember ? qsTrId("joined") :
|
return false
|
||||||
//% "Join"
|
}
|
||||||
qsTrId("join")
|
if (joinBtn.access === Constants.communityChatInvitationOnlyAccess || isPendingRequest) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (invitedCommunity.canJoin) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return !invitedCommunity.joined
|
||||||
|
}
|
||||||
|
text: {
|
||||||
|
if (invitedCommunity.ensOnly && !profileModel.profile.ensVerified) {
|
||||||
|
return qsTr("Membership requires an ENS username")
|
||||||
|
}
|
||||||
|
if (invitedCommunity.canJoin) {
|
||||||
|
return qsTr("Join")
|
||||||
|
}
|
||||||
|
if (invitedCommunity.joined || invitedCommunity.isMember) {
|
||||||
|
return qsTr("Joined")
|
||||||
|
}
|
||||||
|
if (isPendingRequest) {
|
||||||
|
return qsTr("Pending")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(joinBtn.access) {
|
||||||
|
case Constants.communityChatPublicAccess: return qsTr("Join")
|
||||||
|
case Constants.communityChatInvitationOnlyAccess: return qsTr("You need to be invited");
|
||||||
|
case Constants.communityChatOnRequestAccess: return qsTr("Request to join")
|
||||||
|
default: return qsTr("Unknown community");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
chatsModel.communities.joinCommunity(communityId, true)
|
let error
|
||||||
root.joined = true
|
if (joinBtn.access === Constants.communityChatOnRequestAccess) {
|
||||||
|
error = chatsModel.communities.requestToJoinCommunity(communityId,
|
||||||
|
profileModel.profile.ensVerified ? profileModel.profile.username : "")
|
||||||
|
if (!error) {
|
||||||
|
enabled = false
|
||||||
|
text = qsTr("Pending")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error = chatsModel.communities.joinCommunity(communityId, true)
|
||||||
|
enabled = false
|
||||||
|
text = qsTr("Joined")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
joiningError.text = error
|
||||||
|
return joiningError.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: joiningError
|
||||||
|
//% "Error joining the community"
|
||||||
|
title: qsTrId("error-joining-the-community")
|
||||||
|
icon: StandardIcon.Critical
|
||||||
|
standardButtons: StandardButton.Ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,12 +227,12 @@ ModalPopup {
|
||||||
if (ensOnly && !profileModel.profile.ensVerified) {
|
if (ensOnly && !profileModel.profile.ensVerified) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (canJoin) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (access === Constants.communityChatInvitationOnlyAccess || isPendingRequest) {
|
if (access === Constants.communityChatInvitationOnlyAccess || isPendingRequest) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (canJoin) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ ModalPopup {
|
||||||
anchors.top: titleText.bottom
|
anchors.top: titleText.bottom
|
||||||
anchors.topMargin: 2
|
anchors.topMargin: 2
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Style.current.darkGrey
|
color: Style.current.secondaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {
|
Separator {
|
||||||
|
@ -103,7 +103,7 @@ ModalPopup {
|
||||||
anchors.rightMargin: Style.current.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
color: Style.current.darkGrey
|
color: Style.current.secondaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGImage {
|
SVGImage {
|
||||||
|
|
Loading…
Reference in New Issue