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
|
# TODO
|
||||||
|
|
||||||
- add account number binds
|
- add account number binds
|
||||||
|
- next room with unread/mention keybinds
|
||||||
- revise pane collapse mode
|
- revise pane collapse mode
|
||||||
|
|
||||||
- fix escape keybinds (filter rooms, message selection)
|
- fix escape keybinds (filter rooms, message selection)
|
||||||
|
|
|
@ -68,6 +68,9 @@ ListView {
|
||||||
property int lastCheckedDelegateIndex: 0
|
property int lastCheckedDelegateIndex: 0
|
||||||
property int selectedCount: Object.keys(checked).length
|
property int selectedCount: Object.keys(checked).length
|
||||||
|
|
||||||
|
readonly property var currentIndexModel:
|
||||||
|
currentIndex === -1 ? null : model.get(currentIndex)
|
||||||
|
|
||||||
|
|
||||||
function check(...indices) {
|
function check(...indices) {
|
||||||
for (const i of indices) {
|
for (const i of indices) {
|
||||||
|
|
|
@ -19,11 +19,9 @@ HListView {
|
||||||
width: roomList.width
|
width: roomList.width
|
||||||
filterActive: Boolean(filter)
|
filterActive: Boolean(filter)
|
||||||
isCurrent:
|
isCurrent:
|
||||||
currentIndex !== -1 &&
|
currentIndexModel &&
|
||||||
(
|
(currentIndexModel.for_account || currentIndexModel.id) ===
|
||||||
roomList.model.get(currentIndex).for_account ||
|
model.id
|
||||||
roomList.model.get(currentIndex).id
|
|
||||||
) === model.id
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +38,16 @@ HListView {
|
||||||
|
|
||||||
|
|
||||||
property string filter: ""
|
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: {
|
readonly property var accountIndice: {
|
||||||
const accounts = {}
|
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 {
|
Timer {
|
||||||
id: showItemLimiter
|
id: showItemLimiter
|
||||||
interval: 200
|
interval: 200
|
||||||
|
|
Loading…
Reference in New Issue
Block a user