feature: add remove from group option to group chats
feature: add remove from group option to group chats refactor ProfileContextMenu to make it a functional component refactor ProfileContextMenu to make it a functional component This refactor ProfileContextMenu to make it a functional component by: refactored out direct calls to backend, and passing backend data structures and moved this logic to the callers, also refactored common calls between the callers common types of context menus have been extracted to their sub components which removes a lot of logic too and makes the behaviour very clear user verification workflow (which was already disabled) has been removed refactor: use signals and call singletons on the parent instead remove unused code for now from profile context menu refactor profile context menu into two components; add property to storybook extract blocked profile context menu and self profile context menu use profileType instead of individual bools refactor to pass trustStatus as an argument make contact type a parameter remove unnecessary method from RegularProfileContextMenu add ensVerified property to ProfileContextMenu components add onlineStatus property to ProfileContextMenu components move ProfileContextMenu storybook controls to the right sidebar move contactDetails logic up from the view add local nickname property to ProfileContextMenu components fix issue with missing signal; fix logs in storybook use constant for profileType instead of string refactor common code into a single method refactor getProfileContext remove references to contactDetails which are not longer needed remove unnecessary comments fix bridged constant refactor into a single ProfileContextMenu component refactor into a single ProfileContextMenu component refactor into a single ProfileContextMenu component simplify imports remove unused store field move methods from utils to contacts store remove onClosed signal remove unused param feature: add remove from group option to group chats feature: add remove from group option to group chats add isAdmin property move removeMemberFromGroupChat to root store hide remove from group option from message context menu
This commit is contained in:
parent
655918a279
commit
86fdc668e6
|
@ -62,6 +62,8 @@ SplitView {
|
||||||
ensVerified: ensVerifiedCheckBox.checked
|
ensVerified: ensVerifiedCheckBox.checked
|
||||||
onlineStatus: onlineStatusSelector.currentValue
|
onlineStatus: onlineStatusSelector.currentValue
|
||||||
hasLocalNickname: hasLocalNicknameCheckBox.checked
|
hasLocalNickname: hasLocalNicknameCheckBox.checked
|
||||||
|
chatType: chatTypeSelector.currentValue
|
||||||
|
isAdmin: isAdminCheckBox.checked
|
||||||
publicKey: publicKeyInput.text
|
publicKey: publicKeyInput.text
|
||||||
|
|
||||||
onOpenProfileClicked: () => {
|
onOpenProfileClicked: () => {
|
||||||
|
@ -97,6 +99,9 @@ SplitView {
|
||||||
onBlockContact: () => {
|
onBlockContact: () => {
|
||||||
logs.logEvent("Block contact:", profileContextMenu.publicKey)
|
logs.logEvent("Block contact:", profileContextMenu.publicKey)
|
||||||
}
|
}
|
||||||
|
onRemoveFromGroup: (publicKey) => {
|
||||||
|
logs.logEvent("Remove from group:", publicKey)
|
||||||
|
}
|
||||||
onClosed: {
|
onClosed: {
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
@ -115,6 +120,8 @@ SplitView {
|
||||||
ensVerified: ensVerifiedCheckBox.checked
|
ensVerified: ensVerifiedCheckBox.checked
|
||||||
onlineStatus: onlineStatusSelector.currentValue
|
onlineStatus: onlineStatusSelector.currentValue
|
||||||
hasLocalNickname: hasLocalNicknameCheckBox.checked
|
hasLocalNickname: hasLocalNicknameCheckBox.checked
|
||||||
|
chatType: chatTypeSelector.currentValue
|
||||||
|
isAdmin: isAdminCheckBox.checked
|
||||||
publicKey: publicKeyInput.text
|
publicKey: publicKeyInput.text
|
||||||
|
|
||||||
onOpenProfileClicked: () => {
|
onOpenProfileClicked: () => {
|
||||||
|
@ -150,7 +157,9 @@ SplitView {
|
||||||
onBlockContact: () => {
|
onBlockContact: () => {
|
||||||
logs.logEvent("Block contact:", profileContextMenu.publicKey)
|
logs.logEvent("Block contact:", profileContextMenu.publicKey)
|
||||||
}
|
}
|
||||||
|
onRemoveFromGroup: (publicKey) => {
|
||||||
|
logs.logEvent("Remove from group:", publicKey)
|
||||||
|
}
|
||||||
onClosed: {
|
onClosed: {
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
@ -273,6 +282,39 @@ SplitView {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "Has Local Nickname: " + (hasLocalNicknameCheckBox.checked ? "Yes" : "No")
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: isAdminCheckBox
|
||||||
|
text: "Is Admin"
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Is Admin: " + (isAdminCheckBox.checked ? "Yes" : "No")
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Chat type: " + chatTypeSelector.currentText
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,9 +128,11 @@ Item {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey, userProfile.pubKey)
|
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey, userProfile.pubKey)
|
||||||
|
const chatType = chatContentModule.chatDetails.type
|
||||||
|
const isAdmin = chatContentModule.amIChatAdmin()
|
||||||
|
|
||||||
Global.openMenu(profileContextMenuComponent, this, {
|
Global.openMenu(profileContextMenuComponent, this, {
|
||||||
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname,
|
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType, isAdmin,
|
||||||
publicKey: model.pubKey,
|
publicKey: model.pubKey,
|
||||||
displayName: nickName || userName,
|
displayName: nickName || userName,
|
||||||
userIcon: model.icon,
|
userIcon: model.icon,
|
||||||
|
@ -209,6 +211,9 @@ Item {
|
||||||
const contactDetails = profileContextMenu.publicKey === "" ? {} : Utils.getContactDetailsAsJson(profileContextMenu.publicKey, true, true)
|
const contactDetails = profileContextMenu.publicKey === "" ? {} : Utils.getContactDetailsAsJson(profileContextMenu.publicKey, true, true)
|
||||||
Global.blockContactRequested(profileContextMenu.publicKey, contactDetails)
|
Global.blockContactRequested(profileContextMenu.publicKey, contactDetails)
|
||||||
}
|
}
|
||||||
|
onRemoveFromGroup: {
|
||||||
|
root.store.removeMemberFromGroupChat(profileContextMenu.publicKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -761,4 +761,9 @@ QtObject {
|
||||||
function updatePermissionsModel(communityId, sharedAddresses) {
|
function updatePermissionsModel(communityId, sharedAddresses) {
|
||||||
communitiesModuleInst.checkPermissions(communityId, JSON.stringify(sharedAddresses))
|
communitiesModuleInst.checkPermissions(communityId, JSON.stringify(sharedAddresses))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeMemberFromGroupChat(publicKey) {
|
||||||
|
const chatId = chatCommunitySectionModule.activeItem.id
|
||||||
|
chatCommunitySectionModule.removeMemberFromGroupChat("", chatId, publicKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,8 +157,11 @@ Loader {
|
||||||
const publicKey = isReply ? quotedMessageFrom : root.senderId
|
const publicKey = isReply ? quotedMessageFrom : root.senderId
|
||||||
const isBridgedAccount = isReply ? (quotedMessageContentType === Constants.messageContentType.bridgeMessageType) : root.isBridgeMessage
|
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 { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, root.rootStore.contactsStore.myPublicKey, isBridgedAccount)
|
||||||
|
const chatType = chatContentModule.chatDetails.type
|
||||||
|
// set false for now, because the remove from group option is still available after member is removed
|
||||||
|
const isAdmin = false // chatContentModule.amIChatAdmin()
|
||||||
|
|
||||||
const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname,
|
const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType, isAdmin,
|
||||||
publicKey: isReply ? quotedMessageFrom : root.senderId,
|
publicKey: isReply ? quotedMessageFrom : root.senderId,
|
||||||
displayName: isReply ? quotedMessageAuthorDetailsDisplayName : root.senderDisplayName,
|
displayName: isReply ? quotedMessageAuthorDetailsDisplayName : root.senderDisplayName,
|
||||||
userIcon: isReply ? quotedMessageAuthorDetailsThumbnailImage : root.senderIcon,
|
userIcon: isReply ? quotedMessageAuthorDetailsThumbnailImage : root.senderIcon,
|
||||||
|
@ -1219,10 +1222,12 @@ Loader {
|
||||||
const contactDetails = profileContextMenu.publicKey === "" ? {} : Utils.getContactDetailsAsJson(profileContextMenu.publicKey, true, true)
|
const contactDetails = profileContextMenu.publicKey === "" ? {} : Utils.getContactDetailsAsJson(profileContextMenu.publicKey, true, true)
|
||||||
Global.blockContactRequested(profileContextMenu.publicKey, contactDetails)
|
Global.blockContactRequested(profileContextMenu.publicKey, contactDetails)
|
||||||
}
|
}
|
||||||
|
onRemoveFromGroup: () => {
|
||||||
|
root.store.removeMemberFromGroupChat(profileContextMenu.publicKey)
|
||||||
|
}
|
||||||
onOpened: root.setMessageActive(root.messageId, true)
|
onOpened: root.setMessageActive(root.messageId, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: messageContextMenuComponent
|
id: messageContextMenuComponent
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ StatusMenu {
|
||||||
property int profileType: Constants.profileType.regular
|
property int profileType: Constants.profileType.regular
|
||||||
property bool ensVerified: false
|
property bool ensVerified: false
|
||||||
property bool hasLocalNickname: false
|
property bool hasLocalNickname: false
|
||||||
|
property int chatType: Constants.chatType.unknown
|
||||||
|
property bool isAdmin: false
|
||||||
|
|
||||||
signal openProfileClicked
|
signal openProfileClicked
|
||||||
signal createOneToOneChat
|
signal createOneToOneChat
|
||||||
|
@ -33,6 +35,7 @@ StatusMenu {
|
||||||
signal removeTrustStatus
|
signal removeTrustStatus
|
||||||
signal removeContact
|
signal removeContact
|
||||||
signal blockContact
|
signal blockContact
|
||||||
|
signal removeFromGroup
|
||||||
|
|
||||||
ProfileHeader {
|
ProfileHeader {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -134,6 +137,15 @@ StatusMenu {
|
||||||
onTriggered: root.unblockContact()
|
onTriggered: root.unblockContact()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusAction {
|
||||||
|
text: qsTr("Remove from group")
|
||||||
|
objectName: "removeFromGroup_StatusItem"
|
||||||
|
icon.name: "remove-contact"
|
||||||
|
type: StatusAction.Type.Danger
|
||||||
|
enabled: root.isAdmin && root.profileType !== Constants.profileType.self && root.chatType === Constants.chatType.privateGroupChat
|
||||||
|
onTriggered: root.removeFromGroup()
|
||||||
|
}
|
||||||
|
|
||||||
// Mark as Untrusted
|
// Mark as Untrusted
|
||||||
StatusAction {
|
StatusAction {
|
||||||
id: markUntrustworthyMenuItem
|
id: markUntrustworthyMenuItem
|
||||||
|
|
Loading…
Reference in New Issue