When room changes category, affect the Chat too

This commit is contained in:
miruka 2019-07-07 02:35:22 -04:00
parent be152c3acf
commit a47e6b5c07
5 changed files with 33 additions and 29 deletions

View File

@ -114,7 +114,6 @@ class MatrixClient(nio.AsyncClient):
return return
self.backend.pending_profile_requests.add(user_id) self.backend.pending_profile_requests.add(user_id)
print("Requesting user profile:", user_id)
response = await self.get_profile(user_id) response = await self.get_profile(user_id)
if isinstance(response, nio.ProfileGetError): if isinstance(response, nio.ProfileGetError):
@ -171,7 +170,6 @@ class MatrixClient(nio.AsyncClient):
) )
more_to_load = True more_to_load = True
print(len(response.chunk))
if self.backend.past_tokens[room_id] == response.end: if self.backend.past_tokens[room_id] == response.end:
self.backend.fully_loaded_rooms.add(room_id) self.backend.fully_loaded_rooms.add(room_id)

View File

@ -6,16 +6,14 @@ import "Timeline"
import "RoomSidePane" import "RoomSidePane"
HColumnLayout { HColumnLayout {
property string userId: "" property var roomInfo: null
property string category: ""
property string roomId: "" 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 senderInfo: users.getUser(userId)
readonly property var roomInfo: rooms.getWhere(
{"userId": userId, "roomId": roomId, "category": category}, 1
)[0]
readonly property bool hasUnknownDevices: false readonly property bool hasUnknownDevices: false
//category == "Rooms" ? //category == "Rooms" ?
//Backend.clients.get(userId).roomHasUnknownDevices(roomId) : false //Backend.clients.get(userId).roomHasUnknownDevices(roomId) : false
@ -23,14 +21,6 @@ HColumnLayout {
id: chatPage id: chatPage
onFocusChanged: sendBox.setFocus() onFocusChanged: sendBox.setFocus()
//Component.onCompleted: Backend.signals.roomCategoryChanged.connect(
//function(forUserId, forRoomId, previous, now) {
//if (chatPage && forUserId == userId && forRoomId == roomId) {
//chatPage.category = now
//}
//}
//)
RoomHeader { RoomHeader {
id: roomHeader id: roomHeader
displayName: roomInfo.displayName displayName: roomInfo.displayName

View File

@ -34,7 +34,7 @@ HRectangle {
// Keep x scroll pages cached, to limit images having to be // Keep x scroll pages cached, to limit images having to be
// reloaded from network. // reloaded from network.
cacheBuffer: height * 6 cacheBuffer: height * 4
// Declaring this as "alias" provides the on... signal // Declaring this as "alias" provides the on... signal
property real yPos: visibleArea.yPosition property real yPos: visibleArea.yPosition

View File

@ -32,17 +32,19 @@ function onRoomUpdated(
"name": category "name": category
}) })
function pop(for_category) { function find(for_category) {
rooms.popWhere( var found = rooms.getIndices(
{"userId": user_id, "roomId": room_id, "category": for_category}, 1 {"userId": user_id, "roomId": room_id, "category": for_category}, 1
) )
return found.length > 0 ? found[0] : null
} }
if (category == "Invites") { pop("Rooms"); pop("Left") } var replace = null
else if (category == "Rooms") { pop("Invites"); pop("Left") } if (category == "Invites") { replace = find("Rooms") || find("Left") }
else if (category == "Left") { pop("Invites"); pop("Rooms") } 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, "userId": user_id,
"category": category, "category": category,
"roomId": room_id, "roomId": room_id,
@ -51,7 +53,18 @@ function onRoomUpdated(
"topic": topic, "topic": topic,
"typingText": typingTextFor(typing_members, user_id), "typingText": typingTextFor(typing_members, user_id),
"inviterId": inviter_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)
}
} }

View File

@ -70,10 +70,13 @@ Item {
} }
function showRoom(userId, category, roomId) { function showRoom(userId, category, roomId) {
pageStack.replace( var info = rooms.getWhere({
"Chat/Chat.qml", "userId": userId,
{ userId: userId, category: category, roomId: roomId } "roomId": roomId,
) "category": category
}, 1)[0]
pageStack.replace("Chat/Chat.qml", {"roomInfo": info})
} }
Component.onCompleted: initialRoomTimer.start() Component.onCompleted: initialRoomTimer.start()