diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index e6e2bb5b..f672267c 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -114,7 +114,6 @@ class MatrixClient(nio.AsyncClient): return self.backend.pending_profile_requests.add(user_id) - print("Requesting user profile:", user_id) response = await self.get_profile(user_id) if isinstance(response, nio.ProfileGetError): @@ -171,7 +170,6 @@ class MatrixClient(nio.AsyncClient): ) more_to_load = True - print(len(response.chunk)) if self.backend.past_tokens[room_id] == response.end: self.backend.fully_loaded_rooms.add(room_id) diff --git a/src/qml/Chat/Chat.qml b/src/qml/Chat/Chat.qml index 2d180df8..9b394000 100644 --- a/src/qml/Chat/Chat.qml +++ b/src/qml/Chat/Chat.qml @@ -6,16 +6,14 @@ import "Timeline" import "RoomSidePane" HColumnLayout { - property string userId: "" - property string category: "" - property string roomId: "" + property var roomInfo: null + + readonly property string userId: roomInfo.userId + readonly property string category: roomInfo.category + readonly property string roomId: roomInfo.roomId readonly property var senderInfo: users.getUser(userId) - readonly property var roomInfo: rooms.getWhere( - {"userId": userId, "roomId": roomId, "category": category}, 1 - )[0] - readonly property bool hasUnknownDevices: false //category == "Rooms" ? //Backend.clients.get(userId).roomHasUnknownDevices(roomId) : false @@ -23,14 +21,6 @@ HColumnLayout { id: chatPage onFocusChanged: sendBox.setFocus() - //Component.onCompleted: Backend.signals.roomCategoryChanged.connect( - //function(forUserId, forRoomId, previous, now) { - //if (chatPage && forUserId == userId && forRoomId == roomId) { - //chatPage.category = now - //} - //} - //) - RoomHeader { id: roomHeader displayName: roomInfo.displayName diff --git a/src/qml/Chat/Timeline/EventList.qml b/src/qml/Chat/Timeline/EventList.qml index 8af24e92..f54c0978 100644 --- a/src/qml/Chat/Timeline/EventList.qml +++ b/src/qml/Chat/Timeline/EventList.qml @@ -34,7 +34,7 @@ HRectangle { // Keep x scroll pages cached, to limit images having to be // reloaded from network. - cacheBuffer: height * 6 + cacheBuffer: height * 4 // Declaring this as "alias" provides the on... signal property real yPos: visibleArea.yPosition diff --git a/src/qml/EventHandlers/rooms.js b/src/qml/EventHandlers/rooms.js index 9686084f..9a83848c 100644 --- a/src/qml/EventHandlers/rooms.js +++ b/src/qml/EventHandlers/rooms.js @@ -32,17 +32,19 @@ function onRoomUpdated( "name": category }) - function pop(for_category) { - rooms.popWhere( + function find(for_category) { + var found = rooms.getIndices( {"userId": user_id, "roomId": room_id, "category": for_category}, 1 ) + return found.length > 0 ? found[0] : null } - if (category == "Invites") { pop("Rooms"); pop("Left") } - else if (category == "Rooms") { pop("Invites"); pop("Left") } - else if (category == "Left") { pop("Invites"); pop("Rooms") } + var replace = null + if (category == "Invites") { replace = find("Rooms") || find("Left") } + else if (category == "Rooms") { replace = find("Invites") || find("Left") } + else if (category == "Left") { replace = find("Invites") || find("Rooms")} - rooms.upsert({"userId": user_id, "roomId": room_id, "category": category},{ + var item = { "userId": user_id, "category": category, "roomId": room_id, @@ -51,7 +53,18 @@ function onRoomUpdated( "topic": topic, "typingText": typingTextFor(typing_members, user_id), "inviterId": inviter_id - }) + } + + if (replace === null) { + rooms.upsert( + {"userId": user_id, "roomId": room_id, "category": category}, + item + ) + } else { + print("re", replace, display_name) + rooms.set(replace, item) + } + } diff --git a/src/qml/UI.qml b/src/qml/UI.qml index f177dc39..bae1f929 100644 --- a/src/qml/UI.qml +++ b/src/qml/UI.qml @@ -70,10 +70,13 @@ Item { } function showRoom(userId, category, roomId) { - pageStack.replace( - "Chat/Chat.qml", - { userId: userId, category: category, roomId: roomId } - ) + var info = rooms.getWhere({ + "userId": userId, + "roomId": roomId, + "category": category + }, 1)[0] + + pageStack.replace("Chat/Chat.qml", {"roomInfo": info}) } Component.onCompleted: initialRoomTimer.start()