status-desktop/ui/app/AppLayouts/Chat/components/AcceptRejectOptionsButtons.qml
Sale Djenic 102a385943 fix(@desktop/chat): app crash when you accept contact request
This issue is being happened randomly, no general rule, in my case it happens often when you accept
first contact from the list immediately after the app start, but the ticket says that it happens
when you click accept while context menu is opened.

Two places were threat for this crash and both are fixed here:
- getChannel proc, direct access by index to Chat element of the chats sequence,
- setChatItem proc, where we actually were setting chatItem and accessing its property without
  checking if it is an empty object.

Fixes: #2837
2021-07-13 16:33:08 -04:00

83 lines
2.3 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../../../../imports"
import "../../../../shared"
import "../../../../shared/status"
Row {
signal acceptClicked()
signal declineClicked()
signal blockClicked()
signal profileClicked()
id: root
height: acceptBtn.height
spacing: Style.current.halfPadding
StatusIconButton {
id: acceptBtn
icon.name: "check-circle"
onClicked: root.acceptClicked()
width: 32
height: 32
padding: 6
iconColor: Style.current.success
hoveredIconColor: Style.current.success
highlightedBackgroundColor: Utils.setColorAlpha(Style.current.success, 0.1)
anchors.verticalCenter: parent.verticalCenter
}
StatusIconButton {
id: declineBtn
icon.name: "close"
onClicked: root.declineClicked()
width: 32
height: 32
padding: 6
iconColor: Style.current.danger
hoveredIconColor: Style.current.danger
highlightedBackgroundColor: Utils.setColorAlpha(Style.current.danger, 0.1)
anchors.verticalCenter: parent.verticalCenter
}
StatusContextMenuButton {
property int iconSize: 14
id: menuButton
anchors.verticalCenter: parent.verticalCenter
MouseArea {
id: mouseArea
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
contactContextMenu.popup()
}
}
PopupMenu {
id: contactContextMenu
hasArrow: false
Action {
icon.source: "../../../img/profileActive.svg"
icon.width: menuButton.iconSize
icon.height: menuButton.iconSize
//% "View Profile"
text: qsTrId("view-profile")
onTriggered: root.profileClicked()
enabled: true
}
Separator {}
Action {
icon.source: "../../../img/block-icon.svg"
icon.width: menuButton.iconSize
icon.height: menuButton.iconSize
icon.color: Style.current.danger
text: qsTr("Decline and block")
onTriggered: root.blockClicked()
}
}
}
}