Highlight correct account/room on startup
This commit is contained in:
parent
eacee59f9e
commit
922f12e9f9
1
TODO.md
1
TODO.md
|
@ -1,6 +1,7 @@
|
|||
# TODO
|
||||
|
||||
- add account number binds
|
||||
- next room with unread/mention keybinds
|
||||
- revise pane collapse mode
|
||||
|
||||
- fix escape keybinds (filter rooms, message selection)
|
||||
|
|
|
@ -68,6 +68,9 @@ ListView {
|
|||
property int lastCheckedDelegateIndex: 0
|
||||
property int selectedCount: Object.keys(checked).length
|
||||
|
||||
readonly property var currentIndexModel:
|
||||
currentIndex === -1 ? null : model.get(currentIndex)
|
||||
|
||||
|
||||
function check(...indices) {
|
||||
for (const i of indices) {
|
||||
|
|
|
@ -19,11 +19,9 @@ HListView {
|
|||
width: roomList.width
|
||||
filterActive: Boolean(filter)
|
||||
isCurrent:
|
||||
currentIndex !== -1 &&
|
||||
(
|
||||
roomList.model.get(currentIndex).for_account ||
|
||||
roomList.model.get(currentIndex).id
|
||||
) === model.id
|
||||
currentIndexModel &&
|
||||
(currentIndexModel.for_account || currentIndexModel.id) ===
|
||||
model.id
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +38,16 @@ HListView {
|
|||
|
||||
|
||||
property string filter: ""
|
||||
|
||||
readonly property bool currentShouldBeAccount:
|
||||
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml"
|
||||
readonly property bool currentShouldBeRoom:
|
||||
window.uiState.page === "Pages/Chat/Chat.qml"
|
||||
readonly property string wantedUserId:
|
||||
window.uiState.pageProperties.userId || ""
|
||||
readonly property string wantedRoomId:
|
||||
window.uiState.pageProperties.roomId || ""
|
||||
|
||||
readonly property var accountIndice: {
|
||||
const accounts = {}
|
||||
|
||||
|
@ -95,6 +103,43 @@ HListView {
|
|||
}
|
||||
|
||||
|
||||
function setCorrectCurrentItem() {
|
||||
if (! currentShouldBeRoom && ! currentShouldBeAccount) {
|
||||
currentIndex = -1
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < model.count; i++) {
|
||||
const item = model.get(i)
|
||||
|
||||
if ((
|
||||
currentShouldBeRoom &&
|
||||
item.type === "Room" &&
|
||||
item.id === wantedRoomId &&
|
||||
item.for_account === wantedUserId
|
||||
) || (
|
||||
currentShouldBeAccount &&
|
||||
item.type === "Account" &&
|
||||
item.id === wantedRoomId &&
|
||||
item.for_account === wantedUserId
|
||||
)) {
|
||||
currentIndex = i
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
// On startup, the account/room takes an unknown amount of time to
|
||||
// arrive in the model, try to find it until then.
|
||||
interval: 200
|
||||
running: currentIndex === -1
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: setCorrectCurrentItem()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: showItemLimiter
|
||||
interval: 200
|
||||
|
|
Loading…
Reference in New Issue
Block a user