Don't recreate RoomPage each time and add a small loading indicator

This commit is contained in:
Carl Schwan
2020-12-17 08:59:11 +00:00
parent 2b84c5dd02
commit bd41dcc986
2 changed files with 16 additions and 7 deletions

View File

@@ -121,6 +121,14 @@ Kirigami.ScrollablePage {
room: currentRoom room: currentRoom
} }
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
visible: messageListView.count === 0 && !currentRoom.allHistoryLoaded
QQC2.BusyIndicator {
running: true
}
}
QQC2.Popup { QQC2.Popup {
anchors.centerIn: parent anchors.centerIn: parent

View File

@@ -41,6 +41,7 @@ Kirigami.ApplicationWindow {
property alias pageStack: root.pageStack property alias pageStack: root.pageStack
property bool invitationOpen: false property bool invitationOpen: false
property var roomList: null property var roomList: null
property Item roomItem: null
readonly property bool hasOpenRoom: currentRoom !== null readonly property bool hasOpenRoom: currentRoom !== null
@@ -51,8 +52,8 @@ Kirigami.ApplicationWindow {
if (Config.openRoom) { if (Config.openRoom) {
const room = Controller.activeConnection.room(Config.openRoom); const room = Controller.activeConnection.room(Config.openRoom);
currentRoom = room; currentRoom = room;
let item = pageStack.push(roomPage, { 'currentRoom': room, }); roomItem = pageStack.push(roomPage, { 'currentRoom': room, });
connectRoomToSignal(item); connectRoomToSignal(roomItem);
} else { } else {
// TODO create welcome page // TODO create welcome page
} }
@@ -61,16 +62,16 @@ Kirigami.ApplicationWindow {
function enterRoom(room) { function enterRoom(room) {
let item = null; let item = null;
if (currentRoom != null || invitationOpen) { if (currentRoom != null || invitationOpen) {
currentRoom = null; roomItem.currentRoom = room;
item = pageStack.replace(roomPage, { 'currentRoom': room, }); //item = pageStack.replace(roomPage, { 'currentRoom': room, });
} else { } else {
item = pageStack.push(roomPage, { 'currentRoom': room, }); roomItem = pageStack.push(roomPage, { 'currentRoom': room, });
} }
currentRoom = room; currentRoom = room;
Config.openRoom = room.id; Config.openRoom = room.id;
Config.save(); Config.save();
connectRoomToSignal(item); connectRoomToSignal(roomItem);
return item; return roomItem;
} }
function openInvitation(room) { function openInvitation(room) {