Refactor and fix invitations
-Move invitation handling into RoomPage and delete InvitationPage -Open the new room after accepting the invitation
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import org.kde.kirigami 2.14 as Kirigami
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
property var room
|
||||
title: i18n("Invitation Received - %1", room.displayName)
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
anchors.centerIn: parent
|
||||
text: i18n("Accept this invitation?")
|
||||
RowLayout {
|
||||
Button {
|
||||
Layout.alignment : Qt.AlignHCenter
|
||||
text: i18n("Cancel")
|
||||
|
||||
onClicked: roomManager.getBack();
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.alignment : Qt.AlignHCenter
|
||||
text: i18n("Reject")
|
||||
|
||||
onClicked: {
|
||||
room.forget()
|
||||
roomManager.getBack();
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.alignment : Qt.AlignHCenter
|
||||
text: i18n("Accept")
|
||||
|
||||
onClicked: {
|
||||
room.acceptInvitation();
|
||||
roomManager.enterRoom(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,13 +96,9 @@ Kirigami.ScrollablePage {
|
||||
action: Kirigami.Action {
|
||||
id: enterRoomAction
|
||||
onTriggered: {
|
||||
if (category === RoomType.Invited) {
|
||||
roomManager.openInvitation(currentRoom);
|
||||
} else {
|
||||
var roomItem = roomManager.enterRoom(currentRoom)
|
||||
roomListItem.KeyNavigation.right = roomItem
|
||||
roomItem.focus = true;
|
||||
}
|
||||
var roomItem = roomManager.enterRoom(currentRoom)
|
||||
roomListItem.KeyNavigation.right = roomItem
|
||||
roomItem.focus = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,20 @@ Kirigami.ScrollablePage {
|
||||
|
||||
required property var currentRoom
|
||||
|
||||
title: currentRoom.displayName
|
||||
|
||||
signal switchRoomUp()
|
||||
signal switchRoomDown()
|
||||
|
||||
Connections {
|
||||
target: Controller.activeConnection
|
||||
function onJoinedRoom(room) {
|
||||
if(room.id === invitation.id) {
|
||||
roomManager.enterRoom(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: roomManager.actionsHandler
|
||||
onShowMessage: {
|
||||
@@ -49,7 +60,38 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
}
|
||||
|
||||
title: currentRoom.displayName
|
||||
Kirigami.PlaceholderMessage {
|
||||
id: invitation
|
||||
|
||||
property var id
|
||||
|
||||
visible: currentRoom.isInvite
|
||||
anchors.centerIn: parent
|
||||
text: i18n("Accept this invitation?")
|
||||
RowLayout {
|
||||
QQC2.Button {
|
||||
Layout.alignment : Qt.AlignHCenter
|
||||
text: i18n("Reject")
|
||||
|
||||
onClicked: {
|
||||
page.currentRoom.forget()
|
||||
roomManager.getBack();
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
Layout.alignment : Qt.AlignHCenter
|
||||
text: i18n("Accept")
|
||||
|
||||
onClicked: {
|
||||
currentRoom.acceptInvitation();
|
||||
invitation.id = currentRoom.id
|
||||
invitation.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
titleDelegate: Component {
|
||||
RowLayout {
|
||||
visible: !Kirigami.Settings.isMobile
|
||||
@@ -109,6 +151,8 @@ Kirigami.ScrollablePage {
|
||||
ListView {
|
||||
id: messageListView
|
||||
|
||||
visible: !invitation.visible
|
||||
|
||||
readonly property int largestVisibleIndex: count > 0 ? indexAt(contentX + (width / 2), contentY + height - 1) : -1
|
||||
readonly property bool noNeedMoreContent: !currentRoom || currentRoom.eventsHistoryJob || currentRoom.allHistoryLoaded
|
||||
readonly property bool isLoaded: page.width * page.height > 10
|
||||
@@ -577,6 +621,8 @@ Kirigami.ScrollablePage {
|
||||
|
||||
footer: ChatTextInput {
|
||||
id: chatTextInput
|
||||
|
||||
visible: !invitation.visible && !(messageListView.count === 0 && !currentRoom.allHistoryLoaded)
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user