2022-03-23 15:38:23 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2023-03-16 14:10:58 +00:00
|
|
|
import shared.popups 1.0
|
2024-01-24 16:35:53 +00:00
|
|
|
import shared.stores 1.0
|
2023-11-28 19:16:18 +00:00
|
|
|
import shared.stores.send 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "views"
|
2023-09-28 10:09:47 +00:00
|
|
|
|
|
|
|
import AppLayouts.Communities.views 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.popups 1.0
|
2023-09-28 10:09:47 +00:00
|
|
|
import AppLayouts.Communities.helpers 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Communities.stores 1.0 as CommunitiesStores
|
2020-05-13 17:27:06 +00:00
|
|
|
|
2023-03-07 16:51:06 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Profile.stores 1.0
|
2023-07-04 15:11:41 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
2023-03-07 16:51:06 +00:00
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
StackLayout {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2020-05-27 17:10:50 +00:00
|
|
|
|
2023-02-09 21:49:36 +00:00
|
|
|
property RootStore rootStore
|
2024-05-22 08:13:39 +00:00
|
|
|
property CreateChatPropertiesStore createChatPropertiesStore
|
|
|
|
readonly property ContactsStore contactsStore: rootStore.contactsStore
|
|
|
|
readonly property PermissionsStore permissionsStore: rootStore.permissionsStore
|
|
|
|
property CommunitiesStores.CommunitiesStore communitiesStore
|
2023-11-22 13:50:07 +00:00
|
|
|
required property WalletStore.TokensStore tokensStore
|
2023-11-28 19:16:18 +00:00
|
|
|
required property TransactionStore transactionStore
|
2024-01-24 16:35:53 +00:00
|
|
|
required property WalletStore.WalletAssetsStore walletAssetsStore
|
|
|
|
required property CurrenciesStore currencyStore
|
2021-11-15 15:15:21 +00:00
|
|
|
|
2023-03-17 18:58:07 +00:00
|
|
|
property var sectionItemModel
|
2023-09-14 10:02:51 +00:00
|
|
|
property var sendModalPopup
|
2023-03-17 18:58:07 +00:00
|
|
|
|
2023-08-30 13:33:23 +00:00
|
|
|
readonly property bool isOwner: sectionItemModel.memberRole === Constants.memberRole.owner
|
|
|
|
readonly property bool isAdmin: sectionItemModel.memberRole === Constants.memberRole.admin
|
|
|
|
readonly property bool isTokenMasterOwner: sectionItemModel.memberRole === Constants.memberRole.tokenMaster
|
|
|
|
readonly property bool isControlNode: sectionItemModel.isControlNode
|
2023-08-28 19:56:03 +00:00
|
|
|
readonly property bool isPrivilegedUser: isControlNode || isOwner || isAdmin || isTokenMasterOwner
|
2024-04-04 16:03:10 +00:00
|
|
|
readonly property int isInvitationPending: root.rootStore.chatCommunitySectionModule.requestToJoinState !== Constants.RequestToJoinState.None
|
2023-08-28 19:56:03 +00:00
|
|
|
|
2023-07-24 11:31:31 +00:00
|
|
|
property bool communitySettingsDisabled
|
|
|
|
|
2024-09-17 11:34:24 +00:00
|
|
|
property bool sendViaPersonalChatEnabled
|
|
|
|
|
2023-03-07 16:34:36 +00:00
|
|
|
property var emojiPopup
|
|
|
|
property var stickersPopup
|
|
|
|
signal profileButtonClicked()
|
|
|
|
signal openAppSearch()
|
2020-09-23 07:28:20 +00:00
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
// Community transfer ownership related props/signals:
|
2023-10-23 11:32:50 +00:00
|
|
|
property bool isPendingOwnershipRequest: sectionItemModel.isPendingOwnershipRequest
|
2023-09-28 10:09:47 +00:00
|
|
|
|
2023-11-24 15:39:09 +00:00
|
|
|
onIsPrivilegedUserChanged: if (root.currentIndex === 1) root.currentIndex = 0
|
|
|
|
|
2022-11-21 15:46:41 +00:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
}
|
|
|
|
|
2023-03-07 16:51:06 +00:00
|
|
|
Loader {
|
2023-06-08 11:01:01 +00:00
|
|
|
id: mainViewLoader
|
2024-03-20 17:58:46 +00:00
|
|
|
readonly property var sectionItem: root.rootStore.chatCommunitySectionModule
|
2024-03-27 12:48:17 +00:00
|
|
|
readonly property int accessType: sectionItem.requiresTokenPermissionToJoin ? Constants.communityChatOnRequestAccess
|
|
|
|
: Constants.communityChatPublicAccess
|
2023-10-31 17:55:41 +00:00
|
|
|
|
|
|
|
sourceComponent: {
|
2024-03-20 17:58:46 +00:00
|
|
|
if (sectionItem.isCommunity() && !sectionItem.amIMember) {
|
2024-02-27 11:55:56 +00:00
|
|
|
if (sectionItemModel.amIBanned) {
|
|
|
|
return communityBanComponent
|
2024-03-20 17:58:46 +00:00
|
|
|
} else if (sectionItem.isWaitingOnNewCommunityOwnerToConfirmRequestToRejoin) {
|
2023-10-31 17:55:41 +00:00
|
|
|
return controlNodeOfflineComponent
|
2024-03-20 17:58:46 +00:00
|
|
|
} else if (sectionItem.requiresTokenPermissionToJoin) {
|
2023-10-31 17:55:41 +00:00
|
|
|
return joinCommunityViewComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return chatViewComponent
|
|
|
|
}
|
2023-03-07 16:51:06 +00:00
|
|
|
}
|
2022-05-10 16:04:25 +00:00
|
|
|
|
2024-03-12 11:25:05 +00:00
|
|
|
Connections {
|
|
|
|
target: root.rootStore
|
|
|
|
function onGoToMembershipRequestsPage() {
|
|
|
|
root.currentIndex = 1 // go to settings
|
|
|
|
if (communitySettingsLoader.item) {
|
|
|
|
communitySettingsLoader.item.goTo(Constants.CommunitySettingsSections.Members, Constants.CommunityMembershipSubSections.MembershipRequests)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-07 16:51:06 +00:00
|
|
|
Component {
|
|
|
|
id: joinCommunityViewComponent
|
|
|
|
JoinCommunityView {
|
|
|
|
id: joinCommunityView
|
2023-03-17 18:58:07 +00:00
|
|
|
readonly property var communityData: sectionItemModel
|
2023-06-08 11:01:01 +00:00
|
|
|
readonly property string communityId: communityData.id
|
2023-03-07 16:51:06 +00:00
|
|
|
name: communityData.name
|
2023-06-14 08:42:52 +00:00
|
|
|
introMessage: communityData.introMessage
|
2023-03-07 16:51:06 +00:00
|
|
|
communityDesc: communityData.description
|
|
|
|
color: communityData.color
|
|
|
|
image: communityData.image
|
|
|
|
membersCount: communityData.members.count
|
2024-03-27 12:48:17 +00:00
|
|
|
accessType: mainViewLoader.accessType
|
2023-03-07 16:51:06 +00:00
|
|
|
joinCommunity: true
|
2023-06-14 16:00:41 +00:00
|
|
|
amISectionAdmin: communityData.memberRole === Constants.memberRole.owner ||
|
2023-08-22 18:09:34 +00:00
|
|
|
communityData.memberRole === Constants.memberRole.admin ||
|
|
|
|
communityData.memberRole === Constants.memberRole.tokenMaster
|
2023-03-07 16:51:06 +00:00
|
|
|
communityItemsModel: root.rootStore.communityItemsModel
|
|
|
|
requirementsMet: root.permissionsStore.allTokenRequirementsMet
|
2023-08-04 13:14:06 +00:00
|
|
|
requirementsCheckPending: root.rootStore.permissionsCheckOngoing
|
2023-06-08 11:01:01 +00:00
|
|
|
requiresRequest: !communityData.amIMember
|
|
|
|
communityHoldingsModel: root.permissionsStore.becomeMemberPermissionsModel
|
|
|
|
viewOnlyHoldingsModel: root.permissionsStore.viewOnlyPermissionsModel
|
|
|
|
viewAndPostHoldingsModel: root.permissionsStore.viewAndPostPermissionsModel
|
2023-03-07 16:51:06 +00:00
|
|
|
assetsModel: root.rootStore.assetsModel
|
|
|
|
collectiblesModel: root.rootStore.collectiblesModel
|
2024-04-04 16:03:10 +00:00
|
|
|
requestToJoinState: root.rootStore.chatCommunitySectionModule.requestToJoinState
|
2023-03-21 10:54:47 +00:00
|
|
|
notificationCount: activityCenterStore.unreadNotificationsCount
|
|
|
|
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
|
|
|
|
openCreateChat: rootStore.openCreateChat
|
|
|
|
onNotificationButtonClicked: Global.openActivityCenterPopup()
|
|
|
|
onAdHocChatButtonClicked: rootStore.openCloseCreateChatView()
|
2024-03-27 07:37:28 +00:00
|
|
|
onRequestToJoinClicked: {
|
2024-04-04 16:03:10 +00:00
|
|
|
Global.communityIntroPopupRequested(joinCommunityView.communityId, communityData.name,
|
|
|
|
communityData.introMessage, communityData.image,
|
|
|
|
root.isInvitationPending)
|
2023-06-14 08:42:52 +00:00
|
|
|
}
|
2023-06-08 11:01:01 +00:00
|
|
|
onInvitationPendingClicked: {
|
2024-03-27 12:48:17 +00:00
|
|
|
Global.communityIntroPopupRequested(joinCommunityView.communityId, communityData.name, communityData.introMessage,
|
2024-04-04 16:03:10 +00:00
|
|
|
communityData.image, root.isInvitationPending)
|
2023-03-07 16:51:06 +00:00
|
|
|
}
|
2023-03-07 16:34:36 +00:00
|
|
|
}
|
2023-03-07 16:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: chatViewComponent
|
|
|
|
ChatView {
|
|
|
|
id: chatView
|
2023-06-08 11:01:01 +00:00
|
|
|
|
2024-03-20 17:58:46 +00:00
|
|
|
readonly property var sectionItem: root.rootStore.chatCommunitySectionModule
|
2023-06-08 11:01:01 +00:00
|
|
|
readonly property string communityId: root.sectionItemModel.id
|
|
|
|
|
2024-05-28 15:07:30 +00:00
|
|
|
objectName: "chatViewComponent"
|
|
|
|
|
2023-03-07 16:51:06 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
stickersPopup: root.stickersPopup
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
rootStore: root.rootStore
|
2023-11-28 19:16:18 +00:00
|
|
|
transactionStore: root.transactionStore
|
2023-05-04 18:36:35 +00:00
|
|
|
createChatPropertiesStore: root.createChatPropertiesStore
|
2023-09-01 07:58:48 +00:00
|
|
|
communitiesStore: root.communitiesStore
|
2024-01-24 16:35:53 +00:00
|
|
|
walletAssetsStore: root.walletAssetsStore
|
|
|
|
currencyStore: root.currencyStore
|
2023-03-17 18:58:07 +00:00
|
|
|
sectionItemModel: root.sectionItemModel
|
2024-03-20 17:58:46 +00:00
|
|
|
amIMember: sectionItem.amIMember
|
2023-06-08 11:01:01 +00:00
|
|
|
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
|
2023-08-22 18:09:34 +00:00
|
|
|
root.sectionItemModel.memberRole === Constants.memberRole.admin ||
|
|
|
|
root.sectionItemModel.memberRole === Constants.memberRole.tokenMaster
|
2023-06-08 11:01:01 +00:00
|
|
|
hasViewOnlyPermissions: root.permissionsStore.viewOnlyPermissionsModel.count > 0
|
2024-09-17 11:34:24 +00:00
|
|
|
sendViaPersonalChatEnabled: root.sendViaPersonalChatEnabled
|
2024-05-17 09:06:31 +00:00
|
|
|
|
|
|
|
hasUnrestrictedViewOnlyPermission: {
|
|
|
|
viewOnlyUnrestrictedPermissionHelper.revision
|
|
|
|
|
|
|
|
const model = root.permissionsStore.viewOnlyPermissionsModel
|
|
|
|
const count = model.rowCount()
|
|
|
|
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
const holdings = ModelUtils.get(model, i, "holdingsListModel")
|
|
|
|
|
|
|
|
if (holdings.rowCount() === 0)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
Instantiator {
|
|
|
|
id: viewOnlyUnrestrictedPermissionHelper
|
|
|
|
|
|
|
|
model: root.permissionsStore.viewOnlyPermissionsModel
|
|
|
|
|
|
|
|
property int revision: 0
|
|
|
|
|
|
|
|
delegate: QObject {
|
|
|
|
ModelChangeTracker {
|
|
|
|
model: model.holdingsListModel
|
|
|
|
|
|
|
|
onRevisionChanged: viewOnlyUnrestrictedPermissionHelper.revision++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ModelChangeTracker {
|
|
|
|
model: root.permissionsStore.viewOnlyPermissionsModel
|
|
|
|
onRevisionChanged: viewOnlyUnrestrictedPermissionHelper.revision++
|
|
|
|
}
|
|
|
|
|
2023-06-08 11:01:01 +00:00
|
|
|
hasViewAndPostPermissions: root.permissionsStore.viewAndPostPermissionsModel.count > 0
|
|
|
|
viewOnlyPermissionsModel: root.permissionsStore.viewOnlyPermissionsModel
|
|
|
|
viewAndPostPermissionsModel: root.permissionsStore.viewAndPostPermissionsModel
|
|
|
|
assetsModel: root.rootStore.assetsModel
|
|
|
|
collectiblesModel: root.rootStore.collectiblesModel
|
2024-04-04 16:03:10 +00:00
|
|
|
requestToJoinState: sectionItem.requestToJoinState
|
2023-03-07 16:51:06 +00:00
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
isPendingOwnershipRequest: root.isPendingOwnershipRequest
|
|
|
|
|
2023-10-23 11:32:50 +00:00
|
|
|
onFinaliseOwnershipClicked: Global.openFinaliseOwnershipPopup(communityId)
|
2023-03-07 16:51:06 +00:00
|
|
|
onCommunityInfoButtonClicked: root.currentIndex = 1
|
|
|
|
onCommunityManageButtonClicked: root.currentIndex = 1
|
|
|
|
|
|
|
|
onProfileButtonClicked: {
|
|
|
|
root.profileButtonClicked()
|
|
|
|
}
|
|
|
|
onOpenAppSearch: {
|
|
|
|
root.openAppSearch()
|
|
|
|
}
|
2024-03-27 07:37:28 +00:00
|
|
|
onRequestToJoinClicked: {
|
2024-03-27 12:48:17 +00:00
|
|
|
Global.communityIntroPopupRequested(communityId, root.sectionItemModel.name, root.sectionItemModel.introMessage,
|
2024-04-04 16:03:10 +00:00
|
|
|
root.sectionItemModel.image, root.isInvitationPending)
|
2023-06-08 11:01:01 +00:00
|
|
|
}
|
|
|
|
onInvitationPendingClicked: {
|
2024-03-27 12:48:17 +00:00
|
|
|
Global.communityIntroPopupRequested(communityId, root.sectionItemModel.name, root.sectionItemModel.introMessage,
|
2024-04-04 16:03:10 +00:00
|
|
|
root.sectionItemModel.image, root.isInvitationPending)
|
2023-06-08 11:01:01 +00:00
|
|
|
}
|
2023-03-07 16:34:36 +00:00
|
|
|
}
|
2021-11-30 14:49:45 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
Loader {
|
2023-04-06 11:11:57 +00:00
|
|
|
id: communitySettingsLoader
|
2024-03-19 08:41:41 +00:00
|
|
|
active: root.rootStore.chatCommunitySectionModule.isCommunity() &&
|
|
|
|
root.isPrivilegedUser &&
|
2024-03-12 11:25:05 +00:00
|
|
|
(root.currentIndex === 1 || !!communitySettingsLoader.item) // lazy load and preserve state after loading
|
|
|
|
asynchronous: false // It's false on purpose. We want to load the component synchronously
|
2022-03-23 15:38:23 +00:00
|
|
|
sourceComponent: CommunitySettingsView {
|
2023-04-06 11:11:57 +00:00
|
|
|
id: communitySettingsView
|
2022-03-09 10:27:32 +00:00
|
|
|
rootStore: root.rootStore
|
2023-08-29 15:28:41 +00:00
|
|
|
walletAccountsModel: WalletStore.RootStore.nonWatchAccounts
|
2024-07-22 13:52:44 +00:00
|
|
|
enabledChainIds: WalletStore.RootStore.networkFilters
|
|
|
|
onEnableNetwork: WalletStore.RootStore.enableNetwork(chainId)
|
2023-11-22 13:50:07 +00:00
|
|
|
tokensStore: root.tokensStore
|
2023-09-14 10:02:51 +00:00
|
|
|
sendModalPopup: root.sendModalPopup
|
2023-11-28 19:16:18 +00:00
|
|
|
transactionStore: root.transactionStore
|
2023-02-22 17:51:49 +00:00
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
isPendingOwnershipRequest: root.isPendingOwnershipRequest
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
|
2023-03-17 18:58:07 +00:00
|
|
|
community: sectionItemModel
|
2023-07-24 11:31:31 +00:00
|
|
|
communitySettingsDisabled: root.communitySettingsDisabled
|
|
|
|
onCommunitySettingsDisabledChanged: if (communitySettingsDisabled) goTo(Constants.CommunitySettingsSections.Overview)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-02-07 14:21:32 +00:00
|
|
|
onBackToCommunityClicked: root.currentIndex = 0
|
2023-10-23 11:32:50 +00:00
|
|
|
onFinaliseOwnershipClicked: Global.openFinaliseOwnershipPopup(community.id)
|
2021-12-14 14:19:55 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-08 11:01:01 +00:00
|
|
|
|
2023-11-27 09:53:37 +00:00
|
|
|
Component {
|
|
|
|
id: controlNodeOfflineComponent
|
|
|
|
ControlNodeOfflineCommunityView {
|
|
|
|
id: controlNodeOfflineView
|
|
|
|
readonly property var communityData: sectionItemModel
|
2024-02-27 11:55:56 +00:00
|
|
|
name: communityData.name
|
|
|
|
communityDesc: communityData.description
|
|
|
|
color: communityData.color
|
|
|
|
image: communityData.image
|
|
|
|
membersCount: communityData.members.count
|
|
|
|
communityItemsModel: root.rootStore.communityItemsModel
|
|
|
|
notificationCount: activityCenterStore.unreadNotificationsCount
|
|
|
|
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
|
|
|
|
onNotificationButtonClicked: Global.openActivityCenterPopup()
|
|
|
|
onAdHocChatButtonClicked: rootStore.openCloseCreateChatView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityBanComponent
|
|
|
|
BannedMemberCommunityView {
|
|
|
|
id: communityBanView
|
|
|
|
readonly property var communityData: sectionItemModel
|
2023-11-27 09:53:37 +00:00
|
|
|
name: communityData.name
|
|
|
|
communityDesc: communityData.description
|
|
|
|
color: communityData.color
|
|
|
|
image: communityData.image
|
|
|
|
membersCount: communityData.members.count
|
|
|
|
communityItemsModel: root.rootStore.communityItemsModel
|
|
|
|
notificationCount: activityCenterStore.unreadNotificationsCount
|
|
|
|
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
|
|
|
|
onNotificationButtonClicked: Global.openActivityCenterPopup()
|
|
|
|
onAdHocChatButtonClicked: rootStore.openCloseCreateChatView()
|
|
|
|
}
|
|
|
|
}
|
2020-05-13 17:27:06 +00:00
|
|
|
}
|