Autosearch

Make the user search automatically. This includes a timer to ensure that we aren't constantly pinging the server as the user types, the search is started 0.5s after the user stops typing. The `PublicRoomListModel` is upgraded to work in the same manner as it was architected slightly differently.
This commit is contained in:
James Graham
2024-01-21 11:24:40 +00:00
parent 538cfbee8d
commit f48c2a21d9
5 changed files with 63 additions and 23 deletions

View File

@@ -110,6 +110,7 @@ Kirigami.ScrollablePage {
Keys.onEnterPressed: searchButton.clicked()
Keys.onReturnPressed: searchButton.clicked()
onTextChanged: {
searchTimer.restart()
if (model) {
model.searchText = text;
}
@@ -124,6 +125,14 @@ Kirigami.ScrollablePage {
}
}
}
Timer {
id: searchTimer
interval: 500
running: true
onTriggered: if (typeof model.search === 'function') {
model.search()
}
}
}
}
@@ -149,7 +158,7 @@ Kirigami.ScrollablePage {
Kirigami.LoadingPlaceholder {
anchors.centerIn: parent
visible: root.model.searching
visible: searchField.text.length > 0 && listView.count === 0 && root.model.searching
}
}
}