2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
import QtGraphicalEffects 1.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2022-05-13 15:27:26 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2021-07-02 12:34:01 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
2023-05-30 17:51:57 +00:00
|
|
|
import shared.controls.chat.menuItems 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import shared.panels 1.0
|
2024-01-24 16:35:53 +00:00
|
|
|
import shared.stores 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import shared.views.chat 1.0
|
2023-05-30 17:51:57 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.popups 1.0
|
|
|
|
import AppLayouts.Communities.panels 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Communities.stores 1.0 as CommunitiesStores
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2022-09-22 07:13:03 +00:00
|
|
|
// FIXME: Rework me to use ColumnLayout instead of anchors!!
|
2021-07-02 12:34:01 +00:00
|
|
|
Item {
|
2021-07-22 14:53:19 +00:00
|
|
|
id: root
|
2022-07-25 20:30:34 +00:00
|
|
|
objectName: "communityColumnView"
|
2023-05-02 09:37:12 +00:00
|
|
|
width: Constants.chatSectionLeftColumnWidth
|
2021-07-22 14:53:19 +00:00
|
|
|
height: parent.height
|
|
|
|
|
2021-11-26 15:37:57 +00:00
|
|
|
// Important:
|
|
|
|
// We're here in case of CommunitySection
|
|
|
|
// This module is set from `ChatLayout` (each `ChatLayout` has its own communitySectionModule)
|
|
|
|
property var communitySectionModule
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2021-11-26 15:37:57 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property ChatStores.RootStore store
|
|
|
|
property CommunitiesStores.CommunitiesStore communitiesStore
|
|
|
|
required property WalletStores.WalletAssetsStore walletAssetsStore
|
2024-01-24 16:35:53 +00:00
|
|
|
required property CurrenciesStore currencyStore
|
2023-03-17 18:58:07 +00:00
|
|
|
property var communityData
|
2024-10-26 01:25:50 +00:00
|
|
|
property int joinedMembersCount
|
2024-02-06 09:31:36 +00:00
|
|
|
property alias createChannelPopup: createChannelPopup
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2024-04-04 16:03:10 +00:00
|
|
|
property int requestToJoinState: Constants.RequestToJoinState.None
|
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
// Community transfer ownership related props:
|
|
|
|
required property bool isPendingOwnershipRequest
|
2023-10-23 11:32:50 +00:00
|
|
|
signal finaliseOwnershipClicked
|
2023-09-28 10:09:47 +00:00
|
|
|
|
2023-06-14 16:00:41 +00:00
|
|
|
readonly property bool isSectionAdmin:
|
|
|
|
communityData.memberRole === Constants.memberRole.owner ||
|
2023-08-22 18:09:34 +00:00
|
|
|
communityData.memberRole === Constants.memberRole.admin ||
|
|
|
|
communityData.memberRole === Constants.memberRole.tokenMaster
|
2023-06-14 16:00:41 +00:00
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
signal infoButtonClicked
|
|
|
|
signal manageButtonClicked
|
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property bool showJoinButton: !communityData.joined || root.communityData.amIBanned
|
|
|
|
readonly property bool showFinaliseOwnershipButton: root.isPendingOwnershipRequest
|
2023-10-16 11:19:34 +00:00
|
|
|
readonly property bool discordImportInProgress: (root.communitiesStore.discordImportProgress > 0 && root.communitiesStore.discordImportProgress < 100)
|
|
|
|
|| root.communitiesStore.discordImportInProgress
|
2023-10-05 12:28:58 +00:00
|
|
|
|
2024-04-04 16:03:10 +00:00
|
|
|
readonly property int requestToJoinState: root.communitySectionModule.requestToJoinState
|
|
|
|
readonly property bool invitationPending: d.requestToJoinState !== Constants.RequestToJoinState.None
|
2023-09-28 10:09:47 +00:00
|
|
|
}
|
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
ColumnHeaderPanel {
|
2020-12-11 20:29:46 +00:00
|
|
|
id: communityHeader
|
2023-01-26 18:52:41 +00:00
|
|
|
|
2022-05-13 15:27:26 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2023-01-26 18:52:41 +00:00
|
|
|
name: communityData.name
|
2024-10-26 01:25:50 +00:00
|
|
|
membersCount: root.joinedMembersCount
|
2023-01-26 18:52:41 +00:00
|
|
|
image: communityData.image
|
|
|
|
color: communityData.color
|
2023-06-14 16:00:41 +00:00
|
|
|
amISectionAdmin: root.isSectionAdmin
|
2023-01-26 18:52:41 +00:00
|
|
|
openCreateChat: root.store.openCreateChat
|
|
|
|
onInfoButtonClicked: root.infoButtonClicked()
|
|
|
|
onAdHocChatButtonClicked: root.store.openCloseCreateChatView()
|
2022-07-25 19:20:12 +00:00
|
|
|
}
|
2022-05-13 15:27:26 +00:00
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
Loader {
|
|
|
|
id: columnHeaderButton
|
2022-09-22 07:13:03 +00:00
|
|
|
|
|
|
|
anchors.top: communityHeader.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.halfPadding
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
2022-09-22 07:13:03 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2023-09-28 10:09:47 +00:00
|
|
|
sourceComponent: d.showFinaliseOwnershipButton ? finaliseCommunityOwnershipBtn :
|
|
|
|
d.showJoinButton ? joinCommunityButton : undefined
|
2023-10-05 12:28:58 +00:00
|
|
|
active: d.showFinaliseOwnershipButton || d.showJoinButton
|
2022-09-22 07:13:03 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 19:05:05 +00:00
|
|
|
ChatsLoadingPanel {
|
|
|
|
chatSectionModule: root.communitySectionModule
|
|
|
|
width: parent.width
|
2023-10-05 12:28:58 +00:00
|
|
|
anchors.top: columnHeaderButton.active ? columnHeaderButton.bottom : communityHeader.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: active ? Theme.halfPadding : 0
|
2023-03-16 19:05:05 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusMenu {
|
2022-07-25 19:20:12 +00:00
|
|
|
id: adminPopupMenu
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2023-10-16 11:19:34 +00:00
|
|
|
hideDisabledItems: !showInviteButton
|
2022-07-25 19:20:12 +00:00
|
|
|
|
2022-07-25 20:30:34 +00:00
|
|
|
property bool showInviteButton: false
|
|
|
|
|
2022-07-25 19:20:12 +00:00
|
|
|
onClosed: adminPopupMenu.showInviteButton = false
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-07-25 19:20:12 +00:00
|
|
|
objectName: "createCommunityChannelBtn"
|
|
|
|
text: qsTr("Create channel")
|
|
|
|
icon.name: "channel"
|
|
|
|
onTriggered: Global.openPopup(createChannelPopup)
|
|
|
|
}
|
|
|
|
|
2023-09-01 07:58:48 +00:00
|
|
|
StatusAction {
|
|
|
|
objectName: "importCommunityChannelBtn"
|
|
|
|
text: qsTr("Create channel via Discord import")
|
|
|
|
icon.name: "download"
|
2023-10-16 11:19:34 +00:00
|
|
|
enabled: !d.discordImportInProgress
|
2023-10-16 18:26:47 +00:00
|
|
|
onTriggered: {
|
|
|
|
Global.openPopup(createChannelPopup, {isDiscordImport: true, communityId: communityData.id})
|
|
|
|
}
|
2023-09-01 07:58:48 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-07-25 19:20:12 +00:00
|
|
|
objectName: "createCommunityCategoryBtn"
|
|
|
|
text: qsTr("Create category")
|
|
|
|
icon.name: "channel-category"
|
|
|
|
onTriggered: Global.openPopup(createCategoryPopup)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: invitePeopleBtn.enabled
|
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-07-25 19:20:12 +00:00
|
|
|
id: invitePeopleBtn
|
|
|
|
text: qsTr("Invite people")
|
|
|
|
icon.name: "share-ios"
|
|
|
|
enabled: communityData.canManageUsers && adminPopupMenu.showInviteButton
|
2023-09-12 08:55:40 +00:00
|
|
|
objectName: "invitePeople"
|
2022-09-28 21:07:18 +00:00
|
|
|
onTriggered: {
|
|
|
|
Global.openInviteFriendsToCommunityPopup(root.communityData,
|
2022-10-25 17:15:44 +00:00
|
|
|
root.communitySectionModule,
|
|
|
|
null)
|
2022-09-28 21:07:18 +00:00
|
|
|
}
|
2022-07-25 19:20:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-07-14 11:03:36 +00:00
|
|
|
id: scrollView
|
2023-09-28 10:09:47 +00:00
|
|
|
|
2023-10-05 12:28:58 +00:00
|
|
|
anchors.top: columnHeaderButton.active ? columnHeaderButton.bottom : communityHeader.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.halfPadding
|
2022-05-13 15:27:26 +00:00
|
|
|
anchors.bottom: createChatOrCommunity.top
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2023-05-31 20:58:23 +00:00
|
|
|
|
|
|
|
contentWidth: availableWidth
|
2021-07-02 12:34:01 +00:00
|
|
|
contentHeight: communityChatListAndCategories.height
|
2022-05-06 19:30:17 +00:00
|
|
|
+ bannerColumn.height
|
2023-05-31 20:58:23 +00:00
|
|
|
+ bannerColumn.anchors.topMargin
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
|
|
StatusChatListAndCategories {
|
|
|
|
id: communityChatListAndCategories
|
2023-05-31 20:58:23 +00:00
|
|
|
width: scrollView.availableWidth
|
2023-06-14 16:00:41 +00:00
|
|
|
draggableItems: root.isSectionAdmin
|
|
|
|
draggableCategories: root.isSectionAdmin
|
2021-11-26 15:37:57 +00:00
|
|
|
|
|
|
|
model: root.communitySectionModule.model
|
2022-07-22 11:24:28 +00:00
|
|
|
highlightItem: !root.store.openCreateChat
|
|
|
|
|
2021-11-26 15:37:57 +00:00
|
|
|
onChatItemSelected: {
|
2022-07-22 11:24:28 +00:00
|
|
|
Global.closeCreateChatView()
|
2023-01-27 15:24:00 +00:00
|
|
|
root.communitySectionModule.setActiveItem(id)
|
2021-11-26 15:37:57 +00:00
|
|
|
}
|
2021-07-28 12:40:51 +00:00
|
|
|
|
2023-06-14 16:00:41 +00:00
|
|
|
showCategoryActionButtons: root.isSectionAdmin
|
|
|
|
showPopupMenu: root.isSectionAdmin && communityData.canManageUsers
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2022-09-14 23:00:18 +00:00
|
|
|
onChatItemUnmuted: root.communitySectionModule.unmuteChat(id)
|
2023-03-20 15:07:16 +00:00
|
|
|
onChatItemReordered: function(categoryId, chatId, to) {
|
|
|
|
root.store.reorderCommunityChat(categoryId, chatId, to);
|
2022-02-01 22:41:45 +00:00
|
|
|
}
|
2022-01-25 14:51:38 +00:00
|
|
|
onChatListCategoryReordered: root.store.reorderCommunityCategories(categoryId, to)
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2022-01-31 13:33:42 +00:00
|
|
|
onCategoryAddButtonClicked: Global.openPopup(createChannelPopup, {
|
2023-09-28 10:09:47 +00:00
|
|
|
categoryId: id
|
|
|
|
})
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2024-04-15 18:34:44 +00:00
|
|
|
onToggleCollapsedCommunityCategory: root.store.toggleCollapsedCommunityCategory(categoryId, collapsed)
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
popupMenu: StatusMenu {
|
2023-10-16 11:19:34 +00:00
|
|
|
hideDisabledItems: false
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Create channel")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon.name: "channel"
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2022-01-06 15:54:13 +00:00
|
|
|
onTriggered: Global.openPopup(createChannelPopup)
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
|
|
|
|
2023-09-01 07:58:48 +00:00
|
|
|
StatusAction {
|
|
|
|
objectName: "importCommunityChannelBtn"
|
|
|
|
text: qsTr("Create channel via Discord import")
|
|
|
|
icon.name: "download"
|
2023-10-16 11:19:34 +00:00
|
|
|
enabled: !d.discordImportInProgress
|
2023-10-16 18:26:47 +00:00
|
|
|
onTriggered: Global.openPopup(createChannelPopup, {isDiscordImport: true, communityId: root.communityData.id})
|
2023-09-01 07:58:48 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Create category")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon.name: "channel-category"
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2022-01-28 00:02:06 +00:00
|
|
|
onTriggered: Global.openPopup(createCategoryPopup)
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
StatusMenuSeparator {}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Invite people")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon.name: "share-ios"
|
2022-01-10 16:44:54 +00:00
|
|
|
enabled: communityData.canManageUsers
|
2023-09-12 08:55:40 +00:00
|
|
|
objectName: "invitePeople"
|
2022-09-28 21:07:18 +00:00
|
|
|
onTriggered: {
|
|
|
|
Global.openInviteFriendsToCommunityPopup(root.communityData,
|
2022-10-25 17:15:44 +00:00
|
|
|
root.communitySectionModule,
|
|
|
|
null)
|
2022-09-28 21:07:18 +00:00
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
categoryPopupMenu: StatusMenu {
|
2023-05-30 17:51:57 +00:00
|
|
|
id: contextMenuCategory
|
2023-02-08 22:58:14 +00:00
|
|
|
property var categoryItem
|
2021-06-25 09:13:54 +00:00
|
|
|
|
2023-05-30 17:51:57 +00:00
|
|
|
MuteChatMenuItem {
|
|
|
|
enabled: !!categoryItem && !categoryItem.muted
|
|
|
|
title: qsTr("Mute category")
|
|
|
|
onMuteTriggered: {
|
|
|
|
root.communitySectionModule.muteCategory(categoryItem.itemId, interval)
|
|
|
|
contextMenuCategory.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2023-05-30 17:51:57 +00:00
|
|
|
enabled: !!categoryItem && categoryItem.muted
|
|
|
|
text: qsTr("Unmute category")
|
2022-06-29 14:30:40 +00:00
|
|
|
icon.name: "notification"
|
|
|
|
onTriggered: {
|
2023-05-30 17:51:57 +00:00
|
|
|
root.communitySectionModule.unmuteCategory(categoryItem.itemId)
|
2022-06-29 14:30:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-08-16 19:39:32 +00:00
|
|
|
objectName: "editCategoryMenuItem"
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Edit Category")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon.name: "edit"
|
|
|
|
onTriggered: {
|
2023-09-28 10:09:47 +00:00
|
|
|
Global.openPopup(createCategoryPopup, {
|
|
|
|
isEdit: true,
|
|
|
|
channels: [],
|
|
|
|
categoryId: categoryItem.itemId,
|
|
|
|
categoryName: categoryItem.name
|
|
|
|
})
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
StatusMenuSeparator {
|
2023-06-14 16:00:41 +00:00
|
|
|
visible: root.isSectionAdmin
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusAction {
|
2022-08-16 19:39:32 +00:00
|
|
|
objectName: "deleteCategoryMenuItem"
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Delete Category")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon.name: "delete"
|
2022-12-01 16:58:37 +00:00
|
|
|
type: StatusAction.Type.Danger
|
2021-07-02 12:34:01 +00:00
|
|
|
onTriggered: {
|
2021-12-07 20:33:12 +00:00
|
|
|
Global.openPopup(deleteCategoryConfirmationDialogComponent, {
|
2023-09-28 10:09:47 +00:00
|
|
|
"headerSettings.title": qsTr("Delete '%1' category").arg(categoryItem.name),
|
|
|
|
confirmationText: qsTr("Are you sure you want to delete '%1' category? Channels inside the category won't be deleted.")
|
|
|
|
.arg(categoryItem.name),
|
|
|
|
categoryId: categoryItem.itemId
|
|
|
|
})
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
chatListPopupMenu: ChatContextMenuView {
|
2021-11-03 19:35:12 +00:00
|
|
|
id: chatContextMenuView
|
2024-04-08 11:27:19 +00:00
|
|
|
showDebugOptions: root.store.isDebugEnabled
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2023-02-08 22:58:14 +00:00
|
|
|
// TODO pass the chatModel in its entirety instead of fetching the JSOn using just the id
|
2021-07-02 12:34:01 +00:00
|
|
|
openHandler: function (id) {
|
2023-01-27 15:24:00 +00:00
|
|
|
try {
|
|
|
|
let jsonObj = root.communitySectionModule.getItemAsJson(id)
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.error) {
|
|
|
|
console.error("error parsing chat item json object, id: ", id, " error: ", obj.error)
|
|
|
|
close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
currentFleet = root.communitySectionModule.getCurrentFleet()
|
|
|
|
isCommunityChat = root.communitySectionModule.isCommunity()
|
2023-06-14 16:00:41 +00:00
|
|
|
amIChatAdmin = root.isSectionAdmin
|
2023-01-27 15:24:00 +00:00
|
|
|
chatId = obj.itemId
|
|
|
|
chatName = obj.name
|
|
|
|
chatDescription = obj.description
|
|
|
|
chatIcon = obj.icon
|
|
|
|
chatEmoji = obj.emoji
|
|
|
|
chatColor = obj.color
|
|
|
|
chatType = obj.type
|
|
|
|
chatMuted = obj.muted
|
|
|
|
channelPosition = obj.position
|
|
|
|
chatCategoryId = obj.categoryId
|
2024-03-13 19:13:41 +00:00
|
|
|
viewersCanPostReactions = obj.viewersCanPostReactions
|
2024-03-18 17:33:07 +00:00
|
|
|
hideIfPermissionsNotMet = obj.hideIfPermissionsNotMet
|
2023-01-27 15:24:00 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error("error parsing chat item json object, id: ", id, " error: ", e)
|
2021-12-09 12:53:40 +00:00
|
|
|
close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMuteChat: {
|
2023-05-26 12:54:10 +00:00
|
|
|
root.communitySectionModule.muteChat(chatId, interval)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onUnmuteChat: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.communitySectionModule.unmuteChat(chatId)
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
2021-12-08 11:10:34 +00:00
|
|
|
|
|
|
|
onMarkAllMessagesRead: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.communitySectionModule.markAllMessagesRead(chatId)
|
2021-12-08 11:10:34 +00:00
|
|
|
}
|
2021-12-08 13:06:31 +00:00
|
|
|
|
2023-11-29 09:55:03 +00:00
|
|
|
onRequestMoreMessages: {
|
|
|
|
root.communitySectionModule.requestMoreMessages(chatId)
|
|
|
|
}
|
|
|
|
|
2021-12-08 13:06:31 +00:00
|
|
|
onClearChatHistory: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.communitySectionModule.clearChatHistory(chatId)
|
|
|
|
}
|
|
|
|
|
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeaveChat: {
|
|
|
|
root.communitySectionModule.leaveChat(chatId)
|
|
|
|
}
|
|
|
|
|
2022-01-25 12:09:27 +00:00
|
|
|
onDeleteCommunityChat: root.store.removeCommunityChat(chatId)
|
2021-12-21 09:26:13 +00:00
|
|
|
|
|
|
|
onDownloadMessages: {
|
2022-06-22 07:43:30 +00:00
|
|
|
root.communitySectionModule.downloadMessages(chatId, file)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onDisplayProfilePopup: {
|
2022-01-05 15:50:03 +00:00
|
|
|
Global.openProfilePopup(publicKey)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2024-02-06 09:31:36 +00:00
|
|
|
onDisplayEditChannelPopup: {
|
|
|
|
Global.openPopup(createChannelPopup, {
|
|
|
|
isEdit: true,
|
|
|
|
channelName: chatName,
|
|
|
|
channelDescription: chatDescription,
|
|
|
|
channelEmoji: chatEmoji,
|
|
|
|
channelColor: chatColor,
|
|
|
|
categoryId: chatCategoryId,
|
|
|
|
chatId: chatContextMenuView.chatId,
|
|
|
|
channelPosition: channelPosition,
|
2024-03-13 19:13:41 +00:00
|
|
|
viewOnlyCanAddReaction: viewersCanPostReactions,
|
2024-03-18 17:33:07 +00:00
|
|
|
deleteChatConfirmationDialog: deleteChatConfirmationDialog,
|
|
|
|
hideIfPermissionsNotMet: hideIfPermissionsNotMet
|
2024-02-06 09:31:36 +00:00
|
|
|
});
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
2021-05-16 15:16:42 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 19:30:17 +00:00
|
|
|
Column {
|
|
|
|
id: bannerColumn
|
2022-07-14 11:03:36 +00:00
|
|
|
width: scrollView.availableWidth
|
2021-07-02 12:34:01 +00:00
|
|
|
anchors.top: communityChatListAndCategories.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.padding
|
|
|
|
spacing: Theme.bigPadding
|
2022-05-06 19:30:17 +00:00
|
|
|
|
|
|
|
Loader {
|
2023-06-14 16:00:41 +00:00
|
|
|
active: root.isSectionAdmin &&
|
2022-05-06 19:30:17 +00:00
|
|
|
(!localAccountSensitiveSettings.hiddenCommunityWelcomeBanners ||
|
2022-09-15 22:17:51 +00:00
|
|
|
!localAccountSensitiveSettings.hiddenCommunityWelcomeBanners.includes(communityData.id))
|
2022-05-06 19:30:17 +00:00
|
|
|
width: parent.width
|
2023-01-10 12:26:39 +00:00
|
|
|
height: item.height
|
2022-05-06 19:30:17 +00:00
|
|
|
sourceComponent: Component {
|
2023-06-26 11:48:45 +00:00
|
|
|
WelcomeBannerPanel {
|
2022-05-06 19:30:17 +00:00
|
|
|
activeCommunity: communityData
|
|
|
|
store: root.store
|
|
|
|
communitySectionModule: root.communitySectionModule
|
|
|
|
onManageCommunityClicked: root.manageButtonClicked()
|
|
|
|
}
|
2021-10-21 00:41:54 +00:00
|
|
|
}
|
2022-05-25 08:57:57 +00:00
|
|
|
} // Loader
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2022-05-06 19:30:17 +00:00
|
|
|
Loader {
|
2023-06-14 16:00:41 +00:00
|
|
|
active: root.isSectionAdmin &&
|
2022-05-06 19:30:17 +00:00
|
|
|
(!localAccountSensitiveSettings.hiddenCommunityChannelAndCategoriesBanners ||
|
2022-09-15 22:17:51 +00:00
|
|
|
!localAccountSensitiveSettings.hiddenCommunityChannelAndCategoriesBanners.includes(communityData.id))
|
2022-05-06 19:30:17 +00:00
|
|
|
width: parent.width
|
2023-01-10 12:26:39 +00:00
|
|
|
height: item.height
|
2022-05-06 19:30:17 +00:00
|
|
|
sourceComponent: Component {
|
2023-09-28 10:09:47 +00:00
|
|
|
ChannelsAndCategoriesBannerPanel {
|
|
|
|
id: channelsAndCategoriesBanner
|
|
|
|
communityId: communityData.id
|
|
|
|
onAddMembersClicked: {
|
|
|
|
Global.openPopup(createChannelPopup);
|
2022-05-06 19:30:17 +00:00
|
|
|
}
|
2023-09-28 10:09:47 +00:00
|
|
|
onAddCategoriesClicked: {
|
|
|
|
Global.openPopup(createCategoryPopup);
|
|
|
|
}
|
|
|
|
}
|
2022-05-06 19:30:17 +00:00
|
|
|
}
|
2022-05-25 08:57:57 +00:00
|
|
|
} // Loader
|
|
|
|
} // Column
|
2023-05-31 20:58:23 +00:00
|
|
|
|
|
|
|
background: Item {
|
|
|
|
TapHandler {
|
2023-06-14 16:00:41 +00:00
|
|
|
enabled: root.isSectionAdmin
|
2023-05-31 20:58:23 +00:00
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
onTapped: {
|
|
|
|
adminPopupMenu.showInviteButton = true
|
|
|
|
adminPopupMenu.x = eventPoint.position.x + 4
|
|
|
|
adminPopupMenu.y = eventPoint.position.y + 4
|
|
|
|
adminPopupMenu.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-25 08:57:57 +00:00
|
|
|
} // ScrollView
|
2021-07-02 12:34:01 +00:00
|
|
|
|
2022-05-13 15:27:26 +00:00
|
|
|
Loader {
|
|
|
|
id: createChatOrCommunity
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.bottom: parent.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.bottomMargin: active ? Theme.padding : 0
|
2023-06-14 16:00:41 +00:00
|
|
|
active: root.isSectionAdmin
|
2022-05-13 15:27:26 +00:00
|
|
|
sourceComponent: Component {
|
2023-10-16 11:19:34 +00:00
|
|
|
StatusLinkText {
|
2022-07-25 19:20:12 +00:00
|
|
|
id: createChannelOrCategoryBtn
|
2022-07-21 16:16:25 +00:00
|
|
|
objectName: "createChannelOrCategoryBtn"
|
2022-05-13 15:27:26 +00:00
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
text: qsTr("Create channel or category")
|
|
|
|
font.underline: true
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2022-07-25 19:20:12 +00:00
|
|
|
adminPopupMenu.showInviteButton = false
|
|
|
|
adminPopupMenu.popup()
|
2022-07-25 20:30:34 +00:00
|
|
|
adminPopupMenu.y = Qt.binding(() => root.height - adminPopupMenu.height
|
2023-09-28 10:09:47 +00:00
|
|
|
- createChannelOrCategoryBtn.height - 20)
|
2022-05-13 15:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
Component {
|
|
|
|
id: joinCommunityButton
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
anchors.top: communityHeader.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.halfPadding
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
2023-09-28 10:09:47 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
enabled: !root.communityData.amIBanned
|
2024-04-04 16:03:10 +00:00
|
|
|
loading: d.requestToJoinState === Constants.RequestToJoinState.InProgress
|
2023-09-28 10:09:47 +00:00
|
|
|
|
|
|
|
text: {
|
|
|
|
if (root.communityData.amIBanned) return qsTr("You were banned from community")
|
2024-04-04 16:03:10 +00:00
|
|
|
if (d.requestToJoinState === Constants.RequestToJoinState.Requested) return qsTr("Membership request pending...")
|
2023-09-28 10:09:47 +00:00
|
|
|
|
|
|
|
return root.communityData.access === Constants.communityChatOnRequestAccess ?
|
|
|
|
qsTr("Request to join") : qsTr("Join Community")
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
2024-03-27 12:48:17 +00:00
|
|
|
Global.communityIntroPopupRequested(communityData.id, communityData.name, communityData.introMessage,
|
|
|
|
communityData.image, d.invitationPending)
|
2023-09-28 10:09:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2024-04-04 16:03:10 +00:00
|
|
|
enabled: d.showJoinButton
|
2023-09-28 10:09:47 +00:00
|
|
|
target: root.store.communitiesModuleInst
|
2023-10-27 17:20:52 +00:00
|
|
|
|
|
|
|
function onCommunityAccessFailed(communityId: string, error: string) {
|
2024-03-27 12:48:17 +00:00
|
|
|
if (communityId === root.communityData.id) {
|
2023-09-28 10:09:47 +00:00
|
|
|
Global.displayToastMessage(qsTr("Request to join failed"),
|
|
|
|
qsTr("Please try again later"),
|
|
|
|
"",
|
|
|
|
false,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
"")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: finaliseCommunityOwnershipBtn
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
anchors.top: communityHeader.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.halfPadding
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
2023-09-28 10:09:47 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
text: communityData.joined ? qsTr("Finalise community ownership") : qsTr("To join, finalise community ownership")
|
|
|
|
|
2023-10-23 11:32:50 +00:00
|
|
|
onClicked: root.finaliseOwnershipClicked()
|
2023-09-28 10:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
Component {
|
|
|
|
id: createChannelPopup
|
|
|
|
CreateChannelPopup {
|
2023-09-01 07:58:48 +00:00
|
|
|
communitiesStore: root.communitiesStore
|
2024-02-06 09:31:36 +00:00
|
|
|
assetsModel: root.store.assetsModel
|
|
|
|
collectiblesModel: root.store.collectiblesModel
|
2024-07-19 18:45:40 +00:00
|
|
|
ensCommunityPermissionsEnabled: root.store.ensCommunityPermissionsEnabled
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
permissionsModel: {
|
2024-09-27 17:28:27 +00:00
|
|
|
root.store.prepareTokenModelForCommunityChat(communityData.id, chatId)
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
return root.store.permissionsModel
|
|
|
|
}
|
2024-02-06 09:31:36 +00:00
|
|
|
channelsModel: root.store.chatCommunitySectionModule.model
|
2022-03-07 14:56:05 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
2024-02-06 09:31:36 +00:00
|
|
|
activeCommunity: root.communityData
|
|
|
|
|
|
|
|
property int channelPosition: -1
|
|
|
|
property var deleteChatConfirmationDialog
|
2024-03-19 08:41:41 +00:00
|
|
|
|
2022-03-10 19:28:37 +00:00
|
|
|
onCreateCommunityChannel: function (chName, chDescription, chEmoji, chColor,
|
2024-05-31 10:28:09 +00:00
|
|
|
chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) {
|
2022-03-10 19:28:37 +00:00
|
|
|
root.store.createCommunityChannel(chName, chDescription, chEmoji, chColor,
|
2024-03-18 17:33:07 +00:00
|
|
|
chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet)
|
2024-02-06 09:31:36 +00:00
|
|
|
chatId = root.store.currentChatContentModule().chatDetails.id
|
|
|
|
}
|
|
|
|
onEditCommunityChannel: {
|
|
|
|
root.store.editCommunityChannel(chatId,
|
|
|
|
chName,
|
|
|
|
chDescription,
|
|
|
|
chEmoji,
|
|
|
|
chColor,
|
|
|
|
chCategoryId,
|
2024-03-13 19:13:41 +00:00
|
|
|
channelPosition,
|
2024-03-18 17:33:07 +00:00
|
|
|
viewOnlyCanAddReaction,
|
|
|
|
hideIfPermissionsNotMet);
|
2024-02-06 09:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onAddPermissions: function (permissions) {
|
|
|
|
for (var i = 0; i < permissions.length; i++) {
|
2024-03-19 08:41:41 +00:00
|
|
|
root.store.permissionsStore.createPermission(permissions[i].holdingsListModel,
|
2024-02-06 09:31:36 +00:00
|
|
|
permissions[i].permissionType,
|
|
|
|
permissions[i].isPrivate,
|
|
|
|
permissions[i].channelsListModel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onRemovePermissions: function (permissions) {
|
|
|
|
for (var i = 0; i < permissions.length; i++) {
|
|
|
|
root.store.permissionsStore.removePermission(permissions[i].id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onEditPermissions: function (permissions) {
|
|
|
|
for (var i = 0; i < permissions.length; i++) {
|
|
|
|
root.store.permissionsStore.editPermission(permissions[i].id,
|
|
|
|
permissions[i].holdingsListModel,
|
|
|
|
permissions[i].permissionType,
|
|
|
|
permissions[i].channelsListModel,
|
|
|
|
permissions[i].isPrivate)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onSetHideIfPermissionsNotMet: function (checked) {
|
|
|
|
root.store.permissionsStore.setHideIfPermissionsNotMet(chatId, checked)
|
|
|
|
}
|
|
|
|
onDeleteCommunityChannel: {
|
|
|
|
Global.openPopup(deleteChatConfirmationDialog);
|
|
|
|
close()
|
2022-01-05 15:11:26 +00:00
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: createCategoryPopup
|
|
|
|
CreateCategoryPopup {
|
2021-07-09 10:09:03 +00:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2021-07-02 12:34:01 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: deleteCategoryConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
|
|
|
property string categoryId
|
2022-08-16 19:39:32 +00:00
|
|
|
confirmButtonObjectName: "confirmDeleteCategoryButton"
|
2021-07-02 12:34:01 +00:00
|
|
|
showCancelButton: true
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
onCancelButtonClicked: {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
onConfirmButtonClicked: function(){
|
2022-02-01 00:32:53 +00:00
|
|
|
const error = root.store.deleteCommunityCategory(categoryId);
|
|
|
|
if (error) {
|
|
|
|
deleteError.text = error
|
|
|
|
return deleteError.open()
|
|
|
|
}
|
|
|
|
close();
|
2021-07-02 12:34:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: deleteError
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Error deleting the category")
|
2021-07-02 12:34:01 +00:00
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|