Restore correct highlight when no more room filter

This commit is contained in:
miruka 2020-05-14 20:01:58 -04:00
parent e147b87d1b
commit f20853b7ad
2 changed files with 26 additions and 8 deletions

View File

@ -68,9 +68,6 @@ 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) {

View File

@ -21,10 +21,12 @@ HListView {
rightPadding: 0 // the right buttons have padding rightPadding: 0 // the right buttons have padding
filterActive: Boolean(filter) filterActive: Boolean(filter)
enableKeybinds: enableKeybinds: Boolean(
currentIndexModel && roomList.model.get(currentIndex) && (
(currentIndexModel.for_account || currentIndexModel.id) === roomList.model.get(currentIndex).for_account ||
model.id roomList.model.get(currentIndex).id
) === model.id
)
totalMessageIndicator.visible: false totalMessageIndicator.visible: false
@ -43,7 +45,25 @@ HListView {
} }
} }
onFilterChanged: py.callCoro("set_substring_filter", ["all_rooms", filter]) onFilterChanged: {
py.callCoro("set_substring_filter", ["all_rooms", filter])
const item = model.get(currentIndex)
if (
! filter &&
item && ((
currentShouldBeAccount &&
wantedUserId !== item.id
) || (
currentShouldBeRoom && (
wantedUserId !== item.for_account ||
wantedRoomId !== item.id
)
))
)
currentIndex = -1 // will trigger the correctTimer
}
property string filter: "" property string filter: ""
@ -172,6 +192,7 @@ HListView {
Timer { Timer {
// On startup, the account/room takes an unknown amount of time to // On startup, the account/room takes an unknown amount of time to
// arrive in the model, try to find it until then. // arrive in the model, try to find it until then.
id: correctTimer
interval: 200 interval: 200
running: currentIndex === -1 running: currentIndex === -1
repeat: true repeat: true