Lock position of the room that's focused in GUI

When the currently shown page is the chat of a certain room,
prevent that room from moving around in the left pane due to new
messages/activity or unread/highlight counters change.

When the user switches to another page/room, the previously held lock is
released and that room completes all the moves it would have done if it
wasn't locked.

This makes navigating a room list with lots of activity easier, and
prevent annoyances like clicking on a room with unread messages and
having it immediatly fly down the list (possibly out of scroll view).
This commit is contained in:
miruka
2021-03-02 08:53:50 -04:00
parent 3f88a2204e
commit 902f13ab68
4 changed files with 67 additions and 17 deletions

View File

@@ -14,7 +14,9 @@ HColumnPage {
id: chatPage
property string loadMembersFutureId: ""
property var lockedRoom: null // null or [userId, roomId]
readonly property var userRoomId: chat.userRoomId
readonly property alias roomHeader: roomHeader
readonly property alias eventList: eventList
readonly property alias typingMembers: typingMembers
@@ -30,11 +32,26 @@ HColumnPage {
anchors.fill: parent
}
function lockRoomPosition(lock) {
if (lock && lockedRoom) py.callClientCoro(
lockedRoom[0], "lock_room_position", [lockedRoom[1], false],
)
lockedRoom = lock ? [chat.userId, chat.roomId] : null
py.callClientCoro(
chat.userId, "lock_room_position", [chat.roomId, lock],
)
}
padding: 0
column.spacing: 0
Component.onDestruction:
onUserRoomIdChanged: lockRoomPosition(true)
Component.onDestruction: {
lockRoomPosition(false)
if (loadMembersFutureId) py.cancelCoro(loadMembersFutureId)
}
Timer {
interval: 200