Skip to content

Commit

Permalink
feature: add remove from group option to group chats
Browse files Browse the repository at this point in the history
  • Loading branch information
iurimatias committed Sep 18, 2024
1 parent 93f17b2 commit 6a687d2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
29 changes: 29 additions & 0 deletions storybook/pages/MessageContextMenuPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ SplitView {
ensVerified: ensVerifiedCheckBox.checked
onlineStatus: onlineStatusSelector.currentValue
hasLocalNickname: hasLocalNicknameCheckBox.checked
chatType: chatTypeSelector.currentValue // Add this line

onOpenProfileClicked: (publicKey) => {
logs.logEvent("Open profile clicked for:", publicKey)
Expand Down Expand Up @@ -126,6 +127,9 @@ SplitView {
onBlockContact: (publicKey) => {
logs.logEvent("Block contact:", publicKey)
}
onRemoveFromGroup: (publicKey) => {
logs.logEvent("Remove from group:", publicKey)
}
onClosed: {
destroy()
}
Expand All @@ -143,6 +147,7 @@ SplitView {
ensVerified: ensVerifiedCheckBox.checked
onlineStatus: onlineStatusSelector.currentValue
hasLocalNickname: hasLocalNicknameCheckBox.checked
chatType: chatTypeSelector.currentValue // Add this line

onOpenProfileClicked: (publicKey) => {
logs.logEvent("Open profile clicked for:", publicKey)
Expand Down Expand Up @@ -177,6 +182,9 @@ SplitView {
onBlockContact: (publicKey) => {
logs.logEvent("Block contact:", publicKey)
}
onRemoveFromGroup: (publicKey) => {
logs.logEvent("Remove from group:", publicKey)
}

onClosed: {
destroy()
Expand Down Expand Up @@ -290,6 +298,27 @@ SplitView {
text: "Has Local Nickname: " + (hasLocalNicknameCheckBox.checked ? "Yes" : "No")
}

ComboBox {
id: chatTypeSelector
textRole: "text"
valueRole: "value"
model: [
{ text: "Unknown", value: Constants.chatType.unknown },
{ text: "Category", value: Constants.chatType.category },
{ text: "One-to-One", value: Constants.chatType.oneToOne },
{ text: "Public Chat", value: Constants.chatType.publicChat },
{ text: "Private Group Chat", value: Constants.chatType.privateGroupChat },
{ text: "Profile", value: Constants.chatType.profile },
{ text: "Community Chat", value: Constants.chatType.communityChat }
]
currentIndex: 0
}

Label {
Layout.fillWidth: true
text: "Chat type: " + chatTypeSelector.currentText
}

}
}

Expand Down
7 changes: 6 additions & 1 deletion ui/app/AppLayouts/Chat/panels/UserListPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ Item {
onClicked: {
if (mouse.button === Qt.RightButton) {
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey, userProfile.pubKey)
const chatType = chatContentModule.chatDetails.type

Global.openMenu(profileContextMenuComponent, this, {
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname,
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType,
selectedUserPublicKey: model.pubKey,
selectedUserDisplayName: nickName || userName,
selectedUserIcon: model.icon,
Expand Down Expand Up @@ -212,6 +213,10 @@ Item {
const contactDetails = publicKey === "" ? {} : Utils.getContactDetailsAsJson(publicKey, true, true)
Global.blockContactRequested(publicKey, contactDetails)
}
onRemoveFromGroup: (publicKey) => {
const chatId = root.store.chatCommunitySectionModule.activeItem.id
root.store.chatCommunitySectionModule.removeMemberFromGroupChat("", chatId, publicKey)
}
}
}
}
7 changes: 6 additions & 1 deletion ui/imports/shared/views/chat/MessageView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ Loader {
const publicKey = isReply ? quotedMessageFrom : root.senderId
const isBridgedAccount = isReply ? (quotedMessageContentType === Constants.messageContentType.bridgeMessageType) : root.isBridgeMessage
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, root.rootStore.contactsStore.myPublicKey, isBridgedAccount)
const chatType = chatContentModule.chatDetails.type

const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname,
const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType,
selectedUserPublicKey: isReply ? quotedMessageFrom : root.senderId,
selectedUserDisplayName: isReply ? quotedMessageAuthorDetailsDisplayName : root.senderDisplayName,
selectedUserIcon: isReply ? quotedMessageAuthorDetailsThumbnailImage : root.senderIcon,
Expand Down Expand Up @@ -1214,6 +1215,10 @@ Loader {
const contactDetails = publicKey === "" ? {} : Utils.getContactDetailsAsJson(publicKey, true, true)
Global.blockContactRequested(publicKey, contactDetails)
}
onRemoveFromGroup: (publicKey) => {
const chatId = root.rootStore.chatCommunitySectionModule.activeItem.id
root.rootStore.chatCommunitySectionModule.removeMemberFromGroupChat("", chatId, publicKey)
}
onOpened: {
root.setMessageActive(root.messageId, true)
}
Expand Down
12 changes: 12 additions & 0 deletions ui/imports/shared/views/chat/ProfileContextMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ StatusMenu {
property int onlineStatus: Constants.onlineStatus.unknown
property bool hasLocalNickname: false
property int profileType: Constants.profileType.regular
property int chatType: Constants.chatType.unknown

signal openProfileClicked(string publicKey)
signal createOneToOneChat(string communityId, string chatId, string ensName)
Expand All @@ -33,6 +34,7 @@ StatusMenu {
signal removeTrustStatus(string publicKey)
signal removeContact(string publicKey)
signal blockContact(string publicKey)
signal removeFromGroup(string publicKey)

ProfileHeader {
width: parent.width
Expand Down Expand Up @@ -128,6 +130,16 @@ StatusMenu {
onTriggered: root.sendContactRequest(root.selectedUserPublicKey)
}

// Remove from Group
StatusAction {
text: qsTr("Remove from group")
objectName: "removeFromGroup_StatusItem"
icon.name: "remove-contact"
type: StatusAction.Type.Danger
enabled: root.profileType !== Constants.profileType.self && root.chatType === Constants.chatType.privateGroupChat
onTriggered: root.removeFromGroup(root.selectedUserPublicKey)
}

// Mark as Untrusted
StatusAction {
id: markUntrustworthyMenuItem
Expand Down

0 comments on commit 6a687d2

Please sign in to comment.