fix(communities): Cannot leave community, invite, mute from Settings/Communities

This commit is contained in:
Michał Cieślak 2022-07-25 17:39:09 +02:00 committed by Michał
parent 168aae40da
commit 2fbc313e5a
3 changed files with 29 additions and 6 deletions

View File

@ -15,7 +15,9 @@ StatusListView {
property bool hasAddedContacts: false
signal inviteFriends(var communityData)
signal leaveCommunityClicked(var communityId)
signal leaveCommunityClicked(string communityId)
signal setCommunityMutedClicked(string communityId, bool muted)
signal setActiveCommunityClicked(string communityId)
interactive: false
implicitHeight: contentItem.childrenRect.height
@ -36,6 +38,10 @@ StatusListView {
sensor.hoverEnabled: false
onClicked: {
setActiveCommunityClicked(model.id)
}
components: [
StatusFlatButton {
size: StatusBaseButton.Size.Small
@ -55,7 +61,7 @@ StatusListView {
height: 44
icon.source: model.muted ? Style.svg("communities/notifications-muted")
: Style.svg("communities/notifications")
onClicked: root.communityProfileModule.setCommunityMuted(model.id, !model.muted)
onClicked: root.setCommunityMutedClicked(model.id, !model.muted)
},
StatusFlatRoundButton {
@ -70,8 +76,10 @@ StatusListView {
property Component leaveCommunityPopup: StatusModal {
id: leavePopup
property string community: ""
property var communityId
property string communityId: ""
anchors.centerIn: parent
header.title: qsTr("Leave %1").arg(community)
contentItem: Item {

View File

@ -55,14 +55,24 @@ SettingsContentBase {
CommunitiesListPanel {
width: parent.width
model: root.profileSectionStore.communitiesList
onLeaveCommunityClicked: {
root.profileSectionStore.communitiesProfileModule.leaveCommunity(leavePopup.communityId)
root.profileSectionStore.communitiesProfileModule.leaveCommunity(communityId)
}
onSetCommunityMutedClicked: {
root.profileSectionStore.communitiesProfileModule.setCommunityMuted(communityId, muted)
}
onSetActiveCommunityClicked: {
rootStore.setActiveCommunity(communityId)
}
onInviteFriends: {
Global.openPopup(inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.contactStore.myContactsModel.count > 0,
communitySectionModule: communityProfileModule
communitySectionModule: root.profileSectionStore.communitiesProfileModule
})
}
}
@ -87,7 +97,8 @@ SettingsContentBase {
}
onSendInvites: {
const error = communitySectionModule.inviteUsersToCommunity(communty.id, JSON.stringify(pubKeys))
const error = root.profileSectionStore.communitiesProfileModule.inviteUsersToCommunity(
community.id, JSON.stringify(pubKeys))
processInviteResult(error)
}
}

View File

@ -166,4 +166,8 @@ QtObject {
mainModuleInst.setCurrentUserStatus(newStatus)
}
}
function setActiveCommunity(communityId) {
mainModule.setActiveSectionById(communityId);
}
}