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
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-09-22 07:13:03 +00:00
|
|
|
StatusFlatButton {
|
|
|
|
id: joinBtn
|
|
|
|
|
2022-09-13 07:56:47 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 44
|
2022-09-28 14:59:22 +00:00
|
|
|
|
2022-09-22 07:13:03 +00:00
|
|
|
text: qsTr("Go to Community")
|
2022-09-13 07:56:47 +00:00
|
|
|
|
2022-09-22 07:13:03 +00:00
|
|
|
onClicked: {
|
|
|
|
if (d.invitedCommunity.joined || d.invitedCommunity.spectated) {
|
|
|
|
root.store.setActiveCommunity(communityId)
|
|
|
|
} else {
|
|
|
|
root.store.spectateCommunity(communityId, userProfile.name)
|
2022-09-28 14:59:22 +00:00
|
|
|
}
|
2022-09-13 07:56:47 +00:00
|
|
|
}
|
2022-09-22 07:13:03 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
// FIXME: extract StatusButtonBackground or expose radius property in StatusBaseButton
|
|
|
|
background.radius = 16
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|