status-desktop/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml

213 lines
8.5 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
2020-05-27 21:59:34 +00:00
import "../../../../shared"
import "../../../../shared/status"
2020-05-27 21:59:34 +00:00
import "../../../../imports"
import "../components"
2020-05-27 21:59:34 +00:00
Item {
2020-08-14 12:08:09 +00:00
property int iconSize: 16
2020-05-27 21:59:34 +00:00
id: chatTopBarContent
height: 56
Loader {
property bool isGroupChatOrOneToOne: (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat ||
chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne)
2021-06-11 17:59:03 +00:00
anchors.left: parent.left
anchors.leftMargin: this.isGroupChatOrOneToOne ? Style.current.padding : Style.current.padding + 4
anchors.top: parent.top
anchors.topMargin: 4
sourceComponent: this.isGroupChatOrOneToOne ? chatInfoButton : chatInfo
2020-05-27 21:59:34 +00:00
}
Component {
id: chatInfoButton
StatusChatInfoButton {
chatId: chatsModel.channelView.activeChannel.id
chatName: {
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
return chatsModel.channelView.activeChannel.name
}
chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id)
}
chatType: chatsModel.channelView.activeChannel.chatType
identicon: chatsModel.channelView.activeChannel.identicon
muted: chatsModel.channelView.activeChannel.muted
identiconSize: 36
onClicked: {
switch (chatsModel.channelView.activeChannel.chatType) {
2021-06-11 17:59:03 +00:00
case Constants.chatTypePrivateGroupChat:
openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel})
break;
case Constants.chatTypeOneToOne:
const profileImage = appMain.getProfileImage(chatsModel.channelView.activeChannel.id)
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id),
chatsModel.channelView.activeChannel.id, profileImage || chatsModel.channelView.activeChannel.identicon,
"", chatsModel.channelView.activeChannel.nickname)
2021-06-11 17:59:03 +00:00
break;
}
}
}
2020-05-27 21:59:34 +00:00
}
Component {
id: chatInfo
StatusChatInfo {
identiconSize: 36
chatId: chatsModel.channelView.activeChannel.id
chatName: chatsModel.channelView.activeChannel.name
chatType: chatsModel.channelView.activeChannel.chatType
identicon: chatsModel.channelView.activeChannel.identicon
muted: chatsModel.channelView.activeChannel.muted
}
2020-05-27 21:59:34 +00:00
}
2021-06-11 17:59:03 +00:00
Row {
height: parent.height
2020-05-27 21:59:34 +00:00
anchors.right: parent.right
2020-07-09 17:56:31 +00:00
anchors.rightMargin: Style.current.smallPadding
2021-06-11 17:59:03 +00:00
spacing: 12
2020-07-09 17:56:31 +00:00
2021-06-30 18:46:26 +00:00
StatusIconButton {
id: showUsersBtn
anchors.verticalCenter: parent.verticalCenter
icon.name: "channel-icon-group"
iconColor: showUsers ? Style.current.contextMenuButtonForegroundColor : Style.current.contextMenuButtonBackgroundHoverColor
hoveredIconColor: Style.current.contextMenuButtonForegroundColor
highlightedBackgroundColor: Style.current.contextMenuButtonBackgroundHoverColor
onClicked: {
showUsers = !showUsers
}
visible: appSettings.showOnlineUsers && chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
}
2021-06-11 17:59:03 +00:00
StatusContextMenuButton {
id: moreActionsBtn
anchors.verticalCenter: parent.verticalCenter
2021-06-11 17:59:03 +00:00
onClicked: {
var menu = chatContextMenu;
var isPrivateGroupChat = chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat
2021-06-11 17:59:03 +00:00
if(isPrivateGroupChat){
menu = groupContextMenu
}
2020-06-10 19:41:03 +00:00
2021-06-11 17:59:03 +00:00
if (menu.opened) {
return menu.close()
}
if (isPrivateGroupChat) {
menu.popup(moreActionsBtn.x, moreActionsBtn.height)
} else {
menu.openMenu(chatsModel.channelView.activeChannel, chatsModel.channelView.getActiveChannelIdx(),
2021-06-11 17:59:03 +00:00
moreActionsBtn.x - chatContextMenu.width + moreActionsBtn.width + 4,
moreActionsBtn.height - 4)
}
}
2021-06-11 17:59:03 +00:00
ChannelContextMenu {
id: chatContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
}
2021-06-11 17:59:03 +00:00
PopupMenu {
id: groupContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Action {
icon.source: "../../../img/group_chat.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Group Information"
text: qsTrId("group-information")
fix: kick and re-invite user to group chat Fixes: #2601. Kicking a user and re-inviting them now correctly redisplays the join/decline options. Other combinations of User B leaving or declining an invitation are not handled. Please see the notes below for clarification. Additionally, the group invite popup (that shows the list of members belonging to the group) correctly shows when a user is kicked or when a user leaves the group in real time. Previously, the popup needed to be reopened to display this. fix: decline invitation crash Declining a group invitation was crashing the app. This has been fixed. ### NOTES 1. In the case where User A invites User B to a group, but User B declines (or User B joins, then leaves), then from a status-go standpoint, User B is still part of the group, but the chat is marked as `active: false` for User B. This creates a situation where User B cannot re-join the group once s/he has declined the invitation. @cammellos mentioned there possibly will need to be a refactor of https://github.com/status-im/status-go/blob/cab6281dc520c24912de5b5226b42a2f8415aa40/protocol/messenger.go#L1710 (which, by retaining User B as a member, effectively prevents the re-invitation) once “swipe to delete” is implemented on mobile. There is an activity center notification received for User B that is meant to allow re-joining of the group when the notification is accepted. The activity center notification received from status-go looks like the following: ```json "activityCenterNotifications": [ { "id": "0x0e342d33", "chatId": "e342d33f-dd05-4d7b-b14e-b5335e1a3ee9-0x043bf46aa874c377a34946eab67a32cf36c15907b328216dfce375d169fed7d81c21cada3229db1fd37c762d2c02702111a646657feca6621e2e948febcf378fb4", "name": "test-22", "type": 2, "lastMessage": null, "message": null, "timestamp": 1623305612000, "read": false, "dismissed": false, "accepted": false } ] ```
2021-06-10 07:29:05 +00:00
onTriggered: openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel })
2021-06-11 17:59:03 +00:00
}
Action {
icon.source: "../../../img/close.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Clear History"
text: qsTrId("clear-history")
onTriggered: chatsModel.channelView.clearChatHistory(chatsModel.channelView.activeChannel.id)
2021-06-11 17:59:03 +00:00
}
Action {
icon.source: "../../../img/leave_chat.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Leave group"
2021-06-11 17:59:03 +00:00
text: qsTrId("leave-group")
onTriggered: {
//% "Leave group"
deleteChatConfirmationDialog.title = qsTrId("leave-group")
//% "Leave group"
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group")
//% "Are you sure you want to leave this chat?"
deleteChatConfirmationDialog.confirmationText = qsTrId("are-you-sure-you-want-to-leave-this-chat-")
deleteChatConfirmationDialog.open()
}
}
2020-05-27 21:59:34 +00:00
}
}
2020-05-27 21:59:34 +00:00
Rectangle {
2021-06-11 17:59:03 +00:00
id: separator
visible: activityCenterBtn.visible
2021-06-11 17:59:03 +00:00
width: 1
height: 24
color: Style.current.separator
anchors.verticalCenter: parent.verticalCenter
}
StatusIconButton {
id: activityCenterBtn
visible: appSettings.isActivityCenterEnabled
icon.name: "bell"
iconColor: Style.current.contextMenuButtonForegroundColor
hoveredIconColor: Style.current.contextMenuButtonForegroundColor
highlightedBackgroundColor: Style.current.contextMenuButtonBackgroundHoverColor
anchors.verticalCenter: parent.verticalCenter
onClicked: activityCenter.open()
Rectangle {
property int nbUnseenNotifs: chatsModel.activityNotificationList.unreadCount
id: badge
visible: nbUnseenNotifs > 0
anchors.top: parent.top
anchors.topMargin: -2
anchors.left: parent.right
anchors.leftMargin: -17
radius: height / 2
color: Style.current.blue
border.color: activityCenterBtn.hovered ? Style.current.secondaryBackground : Style.current.background
border.width: 2
width: badge.nbUnseenNotifs < 10 ? 18 : badgeText.width + 14
height: 18
Text {
id: badgeText
font.pixelSize: 12
color: Style.current.white
anchors.centerIn: parent
text: badge.nbUnseenNotifs
}
}
}
}
ActivityCenter {
id: activityCenter
}
ConfirmationDialog {
id: deleteChatConfirmationDialog
btnType: "warn"
onConfirmButtonClicked: {
chatsModel.channelView.leaveActiveChat()
deleteChatConfirmationDialog.close()
}
}
}