2020-12-11 20:38:10 +00:00
|
|
|
import QtQuick 2.3
|
2021-04-29 19:54:09 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2022-06-08 14:43:46 +00:00
|
|
|
import QtQuick.Layouts 1.14
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2021-10-18 12:32:48 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-09-13 07:56:47 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-18 12:32:48 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2021-10-18 12:32:48 +00:00
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
implicitHeight: loader.height
|
|
|
|
implicitWidth: loader.width
|
|
|
|
|
2021-10-21 00:41:54 +00:00
|
|
|
property var store
|
2022-09-13 07:56:47 +00:00
|
|
|
property string communityId
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property var invitedCommunity
|
|
|
|
property bool invitationPending
|
|
|
|
|
|
|
|
readonly property int margin: 12
|
|
|
|
|
|
|
|
function getCommunity() {
|
|
|
|
try {
|
|
|
|
const communityJson = root.store.getSectionByIdJson(communityId)
|
2021-10-21 00:41:54 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
if (!communityJson) {
|
|
|
|
root.store.requestCommunityInfo(communityId)
|
|
|
|
return null
|
|
|
|
}
|
2022-06-20 11:39:40 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
return JSON.parse(communityJson);
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Error parsing community", e)
|
2022-02-11 21:41:34 +00:00
|
|
|
}
|
2021-07-22 15:22:02 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
return null
|
2022-02-11 21:41:34 +00:00
|
|
|
}
|
2021-07-22 15:22:02 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
function reevaluate() {
|
|
|
|
invitedCommunity = getCommunity()
|
|
|
|
invitationPending = root.store.isCommunityRequestPending(communityId)
|
|
|
|
}
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
Component.onCompleted: {
|
2022-09-13 07:56:47 +00:00
|
|
|
d.reevaluate()
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-06-20 11:39:40 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.communitiesModuleInst
|
|
|
|
onCommunityChanged: function (communityId) {
|
|
|
|
if (communityId === root.communityId) {
|
2022-09-13 07:56:47 +00:00
|
|
|
d.reevaluate()
|
2022-06-20 11:39:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.store.communitiesModuleInst
|
|
|
|
onCommunityAdded: function (communityId) {
|
|
|
|
if (communityId === root.communityId) {
|
2022-09-13 07:56:47 +00:00
|
|
|
d.reevaluate()
|
2022-06-20 11:39:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.communitiesModuleInst
|
|
|
|
onCommunityAccessRequested: function (communityId) {
|
|
|
|
if (communityId === root.communityId) {
|
|
|
|
d.reevaluate()
|
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
}
|
|
|
|
}
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
Loader {
|
2022-09-13 07:56:47 +00:00
|
|
|
id: loader
|
|
|
|
|
|
|
|
active: !!d.invitedCommunity
|
|
|
|
|
|
|
|
sourceComponent: Rectangle {
|
|
|
|
id: rectangleBubble
|
|
|
|
|
|
|
|
width: 270
|
|
|
|
height: columnLayout.implicitHeight
|
|
|
|
radius: 16
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
border.width: 1
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
2022-09-15 16:10:03 +00:00
|
|
|
name: "pending"
|
|
|
|
when: d.invitationPending
|
2022-09-13 07:56:47 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
2022-09-15 16:10:03 +00:00
|
|
|
text: qsTr("Pending")
|
2022-09-13 07:56:47 +00:00
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
2022-09-15 16:10:03 +00:00
|
|
|
name: "requiresEns"
|
|
|
|
when: d.invitedCommunity.ensOnly && !userProfile.ensName
|
2022-09-13 07:56:47 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
2022-09-15 16:10:03 +00:00
|
|
|
text: qsTr("Membership requires an ENS username")
|
2022-09-13 07:56:47 +00:00
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
2022-09-15 16:10:03 +00:00
|
|
|
name: "inviteOnly"
|
|
|
|
when: d.invitedCommunity.access === Constants.communityChatInvitationOnlyAccess
|
2022-09-13 07:56:47 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
2022-09-15 16:10:03 +00:00
|
|
|
text: qsTr("You need to be invited")
|
2022-09-13 07:56:47 +00:00
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "joined"
|
|
|
|
when: (d.invitedCommunity.joined && d.invitedCommunity.isMember) ||
|
|
|
|
(d.invitedCommunity.access === Constants.communityChatPublicAccess &&
|
|
|
|
d.invitedCommunity.joined)
|
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
|
|
|
text: qsTr("View")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "requestToJoin"
|
|
|
|
when: d.invitedCommunity.access === Constants.communityChatOnRequestAccess &&
|
|
|
|
!d.invitedCommunity.joined
|
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
|
|
|
text: qsTr("Request Access")
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
|
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "unjoined"
|
|
|
|
when: d.invitedCommunity.access === Constants.communityChatPublicAccess &&
|
|
|
|
!d.invitedCommunity.joined
|
|
|
|
PropertyChanges {
|
|
|
|
target: joinBtn
|
|
|
|
text: qsTr("Join")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: columnLayout
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
spacing: 0
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
|
2022-06-08 14:43:46 +00:00
|
|
|
ColumnLayout {
|
2022-09-13 07:56:47 +00:00
|
|
|
id: invitationDescriptionLayout
|
|
|
|
|
|
|
|
Layout.leftMargin: d.margin
|
|
|
|
Layout.rightMargin: d.margin
|
|
|
|
Layout.topMargin: 8
|
|
|
|
Layout.bottomMargin: 8
|
|
|
|
|
|
|
|
spacing: 4
|
2022-06-08 14:43:46 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
2022-09-13 07:56:47 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: d.invitedCommunity.verifed ? qsTr("Verified community invitation") : qsTr("Community invitation")
|
|
|
|
color: d.invitedCommunity.verifed ? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
2022-06-08 14:43:46 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 13
|
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
|
2022-06-08 14:43:46 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: invitedYou
|
2022-09-13 07:56:47 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2022-06-08 14:43:46 +00:00
|
|
|
visible: text != ""
|
|
|
|
text: {
|
|
|
|
// Not Refactored Yet
|
|
|
|
return ""
|
|
|
|
// if (root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.oneToOne) {
|
|
|
|
// return isCurrentUser ?
|
2022-04-04 11:26:30 +00:00
|
|
|
// qsTr("You invited %1 to join a community").arg(root.store.chatsModelInst.userNameOrAlias(root.store.chatsModelInst.channelView.activeChannel.id))
|
|
|
|
// : qsTr("%1 invited you to join a community").arg(displayUserName)
|
2022-06-08 14:43:46 +00:00
|
|
|
// } else {
|
|
|
|
// return isCurrentUser ?
|
2022-04-04 11:26:30 +00:00
|
|
|
// qsTr("You shared a community")
|
|
|
|
// : qsTr("A community has been shared")
|
2022-06-08 14:43:46 +00:00
|
|
|
// }
|
|
|
|
}
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 15
|
fix(communities): re-joining of left communities
Fixes: #2649.
Upon receipt of status-go signals which included communities that have been left (`joined: false`), those communities were being rejoined automatically when they should not have been.
fix(communities): Invitation bubble button state updates
The community state inside of the invitation bubble was not reactive to any community actions (such as joining, leaving, updating). In addition, requesting to join a community changed the button’s text to “Pending”, but upon approval, the button’s state was not updating.
The component was setting an observed community in the Component.onCompleted event, which was occurring for all invitation bubbles, but because the community wasn’t bound correctly to the bubble, once a bubble with a different community was encountered, the community in context of the bubble wasn’t updated and instead used a local copy. Once the community was bound correctly (to be reactive), the states started working correctly.
The invitation bubble has been simplied so that it has states instead of using lots of if/else statements inside of the property bindings. This simplified the component’s logic for things like onClick action and made it a lot easier to read and modify.
2021-06-24 07:21:45 +00:00
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: 1
|
|
|
|
color: Style.current.separator
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
RowLayout {
|
|
|
|
id: communityDescriptionLayout
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
Layout.leftMargin: d.margin
|
|
|
|
Layout.rightMargin: d.margin
|
|
|
|
Layout.topMargin: 12
|
|
|
|
Layout.bottomMargin: 12
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
spacing: 12
|
|
|
|
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.preferredWidth: 40
|
|
|
|
Layout.preferredHeight: 40
|
|
|
|
|
|
|
|
name: d.invitedCommunity.name
|
|
|
|
|
|
|
|
asset {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
name: d.invitedCommunity.image
|
|
|
|
color: d.invitedCommunity.color
|
|
|
|
isImage: true
|
|
|
|
}
|
2022-06-08 14:43:46 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 2
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: d.invitedCommunity.name
|
|
|
|
font.weight: Font.Bold
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
font.pixelSize: 17
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: d.invitedCommunity.description
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2022-09-15 16:27:00 +00:00
|
|
|
text: qsTr("%n member(s)", "", d.invitedCommunity.nbMembers)
|
2022-09-13 07:56:47 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Medium
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
2022-06-08 14:43:46 +00:00
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
}
|
2022-06-08 14:43:46 +00:00
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: 1
|
|
|
|
color: Style.current.separator
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatButton {
|
|
|
|
id: joinBtn
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
|
|
|
|
text: qsTr("Unsupported state")
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (rectangleBubble.state === "joined") {
|
|
|
|
root.store.setActiveCommunity(communityId);
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (rectangleBubble.state === "unjoined") {
|
|
|
|
Global.openPopup(communityIntroDialog, { joinMethod: () => {
|
|
|
|
let error = root.store.joinCommunity(communityId, userProfile.name)
|
|
|
|
if (error) joiningError.showError(error)
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
else if (rectangleBubble.state === "requestToJoin") {
|
|
|
|
Global.openPopup(communityIntroDialog, { joinMethod: () => {
|
|
|
|
let error = root.store.requestToJoinCommunity(communityId, userProfile.name)
|
|
|
|
if (error) joiningError.showError(error)
|
|
|
|
} });
|
2021-04-29 19:54:09 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
// FIXME: extract StatusButtonBackground or expose radius property in StatusBaseButton
|
|
|
|
background.radius = 16
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityIntroDialog
|
|
|
|
|
|
|
|
CommunityIntroDialog {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
property var joinMethod: () => {}
|
|
|
|
|
|
|
|
name: d.invitedCommunity ? d.invitedCommunity.name : ""
|
|
|
|
introMessage: d.invitedCommunity ? d.invitedCommunity.introMessage : ""
|
|
|
|
imageSrc: d.invitedCommunity ? d.invitedCommunity.image : ""
|
|
|
|
|
|
|
|
onJoined: joinMethod()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: joiningError
|
|
|
|
|
|
|
|
function showError(error) {
|
|
|
|
joiningError.text = error
|
|
|
|
joiningError.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
title: qsTr("Error joining the community")
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|