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:
Tobias Fella
2021-02-02 01:52:09 +01:00
parent 465334e23f
commit 72907a1f18
7 changed files with 66 additions and 71 deletions

View File

@@ -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
}