2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick 2.12
|
2021-07-19 12:25:52 +00:00
|
|
|
|
import QtQuick.Controls 2.3
|
2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick.Dialogs 1.3
|
2021-07-19 12:25:52 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
import utils 1.0
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusModal {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property var store
|
2021-12-16 15:24:25 +00:00
|
|
|
|
property QtObject community: root.store.communitiesModuleInst.observedCommunity
|
2020-12-11 20:29:46 +00:00
|
|
|
|
property string communityId: community.id
|
|
|
|
|
property string name: community.name
|
|
|
|
|
property string description: community.description
|
2020-12-11 20:38:10 +00:00
|
|
|
|
property int access: community.access
|
2021-12-16 15:24:25 +00:00
|
|
|
|
property string source: community.image
|
2022-01-11 21:53:18 +00:00
|
|
|
|
property int nbMembers: community.members.count
|
2021-02-10 20:37:17 +00:00
|
|
|
|
property bool ensOnly: community.ensOnly
|
|
|
|
|
property bool canJoin: community.canJoin
|
|
|
|
|
property bool canRequestAccess: community.canRequestAccess
|
2021-03-09 11:50:45 +00:00
|
|
|
|
property bool isMember: community.isMember
|
2021-12-16 15:24:25 +00:00
|
|
|
|
property string communityColor: community.color || Style.current.blue
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
header.title: name
|
|
|
|
|
header.subTitle: {
|
|
|
|
|
let subTitle = ""
|
|
|
|
|
switch(access) {
|
|
|
|
|
case Constants.communityChatPublicAccess:
|
2022-04-04 11:26:30 +00:00
|
|
|
|
subTitle = qsTr("Public community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
2022-02-09 09:43:23 +00:00
|
|
|
|
case Constants.communityChatInvitationOnlyAccess:
|
2022-04-04 11:26:30 +00:00
|
|
|
|
subTitle = qsTr("Invitation only community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
2022-02-09 09:43:23 +00:00
|
|
|
|
case Constants.communityChatOnRequestAccess:
|
2022-04-04 11:26:30 +00:00
|
|
|
|
subTitle = qsTr("On request community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
2021-12-16 15:24:25 +00:00
|
|
|
|
default:
|
|
|
|
|
subTitle = qsTr("Unknown community");
|
2021-07-19 12:25:52 +00:00
|
|
|
|
break;
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
if (ensOnly) {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
subTitle += qsTr(" - ENS only")
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
return subTitle
|
|
|
|
|
}
|
2021-03-23 19:13:36 +00:00
|
|
|
|
|
2021-09-02 14:40:10 +00:00
|
|
|
|
contentItem: Column {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
width: root.width
|
2021-07-19 12:25:52 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
height: childrenRect.height + 8
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: description
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 16
|
2021-10-22 20:49:47 +00:00
|
|
|
|
text: root.description
|
2021-07-19 12:25:52 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
wrapMode: Text.WordWrap
|
2021-07-26 13:53:39 +00:00
|
|
|
|
width: parent.width
|
2022-03-28 12:53:50 +00:00
|
|
|
|
textFormat: Text.PlainText
|
2021-03-23 19:13:36 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusIcon {
|
|
|
|
|
id: statusIcon
|
|
|
|
|
anchors.top: description.bottom
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
icon: "tiny/contact"
|
|
|
|
|
width: 16
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusBaseText {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("%1 members").arg(nbMembers)
|
2021-07-19 12:25:52 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
anchors.left: statusIcon.right
|
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
|
anchors.verticalCenter: statusIcon.verticalCenter
|
2020-12-11 20:38:10 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
StatusModalDivider {
|
|
|
|
|
topPadding: 8
|
|
|
|
|
bottomPadding: 8
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
Item {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: parent.width - 32
|
|
|
|
|
height: 34
|
|
|
|
|
StatusBaseText {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
text: qsTr("Channels")
|
2021-07-19 12:25:52 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 4
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
|
StatusScrollView {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
width: root.width
|
2021-07-19 12:25:52 +00:00
|
|
|
|
height: 300
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2022-07-13 12:29:38 +00:00
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
|
StatusListView {
|
2021-07-19 12:25:52 +00:00
|
|
|
|
id: chatList
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
model: community.chats
|
|
|
|
|
delegate: StatusListItem {
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
title: "#" + model.name
|
|
|
|
|
subTitle: model.description
|
2022-08-11 11:55:08 +00:00
|
|
|
|
asset.isLetterIdenticon: true
|
|
|
|
|
asset.bgColor: root.communityColor
|
2021-07-19 12:25:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
leftButtons: [
|
2022-08-02 13:48:07 +00:00
|
|
|
|
StatusBackButton {
|
2020-12-11 20:29:46 +00:00
|
|
|
|
id: backButton
|
|
|
|
|
onClicked: {
|
2021-10-22 20:49:47 +00:00
|
|
|
|
root.close()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
]
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-19 12:25:52 +00:00
|
|
|
|
rightButtons: [
|
2020-12-11 20:29:46 +00:00
|
|
|
|
StatusButton {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
property bool isPendingRequest: {
|
|
|
|
|
if (access !== Constants.communityChatOnRequestAccess) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2022-01-28 20:44:52 +00:00
|
|
|
|
return false
|
2021-12-13 14:24:21 +00:00
|
|
|
|
// Not Refactored Yet
|
|
|
|
|
// return root.store.chatsModelInst.communities.isCommunityRequestPending(root.communityId)
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
text: {
|
2021-12-13 14:24:21 +00:00
|
|
|
|
// Not Refactored Yet
|
|
|
|
|
// if (root.ensOnly && !root.store.profileModelInst.profile.ensVerified) {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
// return qsTr("Membership requires an ENS username")
|
2021-12-13 14:24:21 +00:00
|
|
|
|
// }
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.canJoin) {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
return qsTr("Join ‘%1’").arg(root.name);
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
if (isPendingRequest) {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
return qsTr("Pending")
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
2021-10-22 20:49:47 +00:00
|
|
|
|
switch(root.access) {
|
2022-04-04 11:26:30 +00:00
|
|
|
|
case Constants.communityChatPublicAccess: return qsTr("Join ‘%1’").arg(root.name);
|
|
|
|
|
case Constants.communityChatInvitationOnlyAccess: return qsTr("You need to be invited");
|
|
|
|
|
case Constants.communityChatOnRequestAccess: return qsTr("Request to join ‘%1’").arg(root.name);
|
|
|
|
|
default: return qsTr("Unknown community");
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
enabled: {
|
2021-12-13 14:24:21 +00:00
|
|
|
|
// Not Refactored Yet
|
|
|
|
|
// if (root.ensOnly && !root.store.profileModelInst.profile.ensVerified) {
|
|
|
|
|
// return false
|
|
|
|
|
// }
|
2021-10-22 20:49:47 +00:00
|
|
|
|
if (root.access === Constants.communityChatInvitationOnlyAccess || isPendingRequest) {
|
2021-02-10 20:37:17 +00:00
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 19:54:09 +00:00
|
|
|
|
if (canJoin) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
return true
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
onClicked: {
|
2021-12-13 14:24:21 +00:00
|
|
|
|
// Not Refactored Yet
|
2021-12-16 15:24:25 +00:00
|
|
|
|
let error
|
2022-01-28 20:44:52 +00:00
|
|
|
|
if (access === Constants.communityChatOnRequestAccess &&
|
|
|
|
|
!root.community.amISectionAdmin
|
|
|
|
|
&& !root.isMember) {
|
2021-12-16 15:24:25 +00:00
|
|
|
|
// TODO refactor
|
|
|
|
|
return
|
|
|
|
|
// error = root.store.chatsModelInst.communities.requestToJoinCommunity(root.communityId, userProfile.name)
|
|
|
|
|
// if (!error) {
|
|
|
|
|
// enabled = false
|
2022-04-04 11:26:30 +00:00
|
|
|
|
// text = qsTr("Pending")
|
2021-12-16 15:24:25 +00:00
|
|
|
|
// }
|
|
|
|
|
} else {
|
2022-05-31 11:16:11 +00:00
|
|
|
|
error = root.store.communitiesModuleInst.joinCommunity(root.communityId, root.store.userProfileInst.ensName)
|
2021-12-16 15:24:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
joiningError.text = error
|
|
|
|
|
return joiningError.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
root.close()
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-19 12:25:52 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: joiningError
|
2022-04-04 11:26:30 +00:00
|
|
|
|
title: qsTr("Error joining the community")
|
2021-07-19 12:25:52 +00:00
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
|
standardButtons: StandardButton.Ok
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|