fix(group-chats): fix context menu and pinned messages popup

This commit is contained in:
Jonathan Rainville 2022-04-12 14:54:01 -04:00 committed by Iuri Matias
parent 6828055087
commit c58a656a52
9 changed files with 62 additions and 45 deletions

View File

@ -298,8 +298,9 @@ proc addGroupMembers*(self: Controller, chatId: string, pubKeys: seq[string]) =
proc removeMemberFromGroupChat*(self: Controller, communityID: string, chatId: string, pubKey: string) =
self.chatService.removeMemberFromGroupChat(communityID, chatId, pubKey)
proc renameGroupChat*(self: Controller, communityID: string, chatId: string, newName: string) =
self.chatService.renameGroupChat(communityID, chatId, newName)
proc renameGroupChat*(self: Controller, chatId: string, newName: string) =
let communityId = if self.isCommunitySection: self.sectionId else: ""
self.chatService.renameGroupChat(communityId, chatId, newName)
proc makeAdmin*(self: Controller, communityID: string, chatId: string, pubKey: string) =
self.chatService.makeAdmin(communityID, chatId, pubKey)

View File

@ -200,7 +200,7 @@ method addGroupMembers*(self: AccessInterface, chatId: string, pubKeys: string)
method removeMemberFromGroupChat*(self: AccessInterface, communityID: string, chatId: string, pubKey: string) {.base.} =
raise newException(ValueError, "No implementation available")
method renameGroupChat*(self: AccessInterface, communityID: string, chatId: string, newName: string) {.base.} =
method renameGroupChat*(self: AccessInterface, chatId: string, newName: string) {.base.} =
raise newException(ValueError, "No implementation available")
method makeAdmin*(self: AccessInterface, communityID: string, chatId: string, pubKey: string) {.base.} =

View File

@ -679,8 +679,8 @@ method addGroupMembers*(self: Module, chatId: string, pubKeys: string) =
method removeMemberFromGroupChat*(self: Module, communityID: string, chatId: string, pubKey: string) =
self.controller.removeMemberFromGroupChat(communityID, chatId, pubKey)
method renameGroupChat*(self: Module, communityID: string, chatId: string, newName: string) =
self.controller.renameGroupChat(communityID, chatId, newName)
method renameGroupChat*(self: Module, chatId: string, newName: string) =
self.controller.renameGroupChat(chatId, newName)
method makeAdmin*(self: Module, communityID: string, chatId: string, pubKey: string) =
self.controller.makeAdmin(communityID, chatId, pubKey)

View File

@ -187,8 +187,8 @@ QtObject:
proc removeMemberFromGroupChat*(self: View, communityID: string, chatId: string, pubKey: string) {.slot.} =
self.delegate.removeMemberFromGroupChat(communityID, chatId, pubKey)
proc renameGroupChat*(self: View, communityID: string, chatId: string, newName: string) {.slot.} =
self.delegate.renameGroupChat(communityID, chatId, newName)
proc renameGroupChat*(self: View, chatId: string, newName: string) {.slot.} =
self.delegate.renameGroupChat(chatId, newName)
proc makeAdmin*(self: View, communityID: string, chatId: string, pubKey: string) {.slot.} =
self.delegate.makeAdmin(communityID, chatId, pubKey)

View File

@ -25,6 +25,7 @@ StatusModal {
}
property var chatSectionModule
property var store
property var messageStore
property bool addMembers: false
property int currMemberCount: chatContentModule.usersModule.model.count
property int memberCount: 1
@ -170,16 +171,28 @@ StatusModal {
spacing: Style.current.padding
StatusSettingsLineButton {
// Not Refactored Yet
property int pinnedCount: 0 // popup.store.chatsModelInst.messageView.pinnedMessagesList.count
property int pinnedCount: popup.chatContentModule.pinnedMessagesModel.count
id: pinnedMessagesBtn
visible: pinnedCount > 0
//% "Pinned messages"
text: qsTrId("pinned-messages")
currentValue: pinnedCount
onClicked: Global.openPopup(pinnedMessagesPopupComponent, {store: popup.store})
onClicked: {
popup.store.messageStore.messageModule = popup.chatContentModule.messagesModule
popup.store.messageStore.chatSectionModule = popup.chatSectionModule
Global.openPopup(pinnedMessagesPopupComponent, {
store: popup.store,
messageStore: popup.store.messageStore,
pinnedMessagesModel: popup.chatContentModule.pinnedMessagesModel,
messageToPin: ""
})
}
iconSource: Style.svg("pin")
anchors.left: undefined
anchors.right: undefined
width: parent.width
}
Separator {
@ -187,23 +200,6 @@ StatusModal {
visible: pinnedMessagesBtn.visible
}
// Not Refactored Yet
// Connections {
// target: popup.store.chatsModelInst.channelView
// onActiveChannelChanged: {
// if (popup.channelType === GroupInfoPopup.ChannelType.ActiveChannel) {
// popup.channel = popup.store.chatsModelInst.channelView.activeChannel
// resetSelectedMembers()
// }
// }
// onContextChannelChanged: {
// if (popup.channelType === GroupInfoPopup.ChannelType.ContextChannel) {
// popup.channel = popup.store.chatsModelInst.channelView.contextChannel
// resetSelectedMembers()
// }
// }
// }
ListView {
id: memberList
Layout.fillWidth: true

View File

@ -271,6 +271,12 @@ ColumnLayout {
onLeaveGroup: {
chatContentModule.leaveChat();
}
onRenameGroupChat: {
root.rootStore.chatCommunitySectionModule.renameGroupChat(
chatId,
groupName
)
}
}
}

View File

@ -39,6 +39,7 @@ StatusPopupMenu {
signal deleteCommunityChat(string chatId)
signal leaveChat(string chatId)
signal leaveGroup(string chatId)
signal renameGroupChat(string chatId, string groupName)
signal createCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor)
signal editCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor, string newCategory)
@ -71,15 +72,18 @@ StatusPopupMenu {
}
}
StatusMenuItem {
text: qsTr("Add / remove from group")
icon.name: "notification"
enabled: (root.chatType === Constants.chatType.privateGroupChat &&
amIChatAdmin)
onTriggered: {
root.addRemoveGroupMember();
}
}
// TODO needs to be implemented
// This should open up the ad-hoc group chat creation view
// Design https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=417%3A243810
// StatusMenuItem {
// text: qsTr("Add / remove from group")
// icon.name: "notification"
// enabled: (root.chatType === Constants.chatType.privateGroupChat &&
// amIChatAdmin)
// onTriggered: {
// root.addRemoveGroupMember();
// }
// }
StatusMenuSeparator {
visible: viewProfileMenuItem.enabled
@ -99,20 +103,27 @@ StatusPopupMenu {
}
StatusMenuItem {
text: qsTr("Edit name and image")
text: qsTr("Edit name")
icon.name: "edit"
enabled: root.chatType === Constants.chatType.privateGroupChat
&& root.amIChatAdmin
onTriggered: {
Global.openPopup(editChannelPopup, {
isEdit: true,
channelName: root.chatName,
channelDescription: root.chatDescription,
categoryId: root.chatCategoryId
Global.openPopup(renameGroupPopupComponent, {
activeChannelName: root.chatName,
});
}
}
Component {
id: renameGroupPopupComponent
RenameGroupPopup {
onDoRename: {
root.renameGroupChat(root.chatId, groupName)
close()
}
}
}
StatusMenuItem {
text: root.chatMuted ?
//% "Unmute chat"

View File

@ -26,9 +26,6 @@ StatusAppThreePanelLayout {
property var contactsStore
property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0
// Not Refactored
property var messageStore
property RootStore rootStore
property Component pinnedMessagesListPopupComponent

View File

@ -250,6 +250,12 @@ Item {
chatDetails: chatContentModule.chatDetails
})
}
onRenameGroupChat: {
chatSectionModule.renameGroupChat(
chatId,
groupName
)
}
}
}