Use homeserver URL field also as a filter field
This commit is contained in:
parent
16970d5e56
commit
ab390704eb
5
TODO.md
5
TODO.md
@ -1,10 +1,13 @@
|
||||
# TODO
|
||||
|
||||
- server list sorting method / explain what the % number is (stability)
|
||||
- server list: make it more obvious that it can be scrolled
|
||||
- server list: make current item highlight more visible
|
||||
- support (shift+)tab in filter fields
|
||||
- clicking cancel on SSO "waiting" box doesn't do anything the first time
|
||||
- spam alt+shift+a when starting app on server browser → segfault
|
||||
- remove items.Device
|
||||
- register tab for sso servers?
|
||||
- sever list
|
||||
- cursor shape in HBox/HTabbedBox pages over fields
|
||||
- login with account already added → infinite spinner in room list
|
||||
- verify onKeyboardAccept/Cancel things respect button enabled state
|
||||
|
@ -84,6 +84,8 @@ class Backend:
|
||||
- `("<user_id>", "<room_id>", "filtered_members")`:
|
||||
See `models.special_models.FilteredMembers` docstring
|
||||
|
||||
- `("filtered_homeservers")`:
|
||||
See `models.special_models.FilteredHomeservers` docstring
|
||||
|
||||
clients: A `{user_id: MatrixClient}` dict for the logged-in clients
|
||||
we managed. Every client is logged to one matrix account.
|
||||
|
@ -6,7 +6,9 @@ from typing import Dict
|
||||
|
||||
from . import SyncId
|
||||
from .model import Model
|
||||
from .special_models import AllRooms, FilteredMembers, MatchingAccounts
|
||||
from .special_models import (
|
||||
AllRooms, FilteredMembers, FilteredHomeservers, MatchingAccounts,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -36,6 +38,8 @@ class ModelStore(UserDict):
|
||||
model = AllRooms(self["accounts"])
|
||||
elif key == "matching_accounts":
|
||||
model = MatchingAccounts(self["all_rooms"])
|
||||
elif key == "filtered_homeservers":
|
||||
model = FilteredHomeservers()
|
||||
elif is_tuple and len(key) == 3 and key[2] == "filtered_members":
|
||||
model = FilteredMembers(user_id=key[0], room_id=key[1])
|
||||
else:
|
||||
|
@ -115,3 +115,14 @@ class FilteredMembers(FieldSubstringFilter):
|
||||
|
||||
def accept_source(self, source: Model) -> bool:
|
||||
return source.sync_id == (self.user_id, self.room_id, "members")
|
||||
|
||||
|
||||
class FilteredHomeservers(FieldSubstringFilter):
|
||||
"""Filtered list of public Matrix homeservers."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(sync_id="filtered_homeservers", fields=("id",))
|
||||
|
||||
|
||||
def accept_source(self, source: Model) -> bool:
|
||||
return source.sync_id == "homeservers"
|
||||
|
@ -86,13 +86,7 @@ HBox {
|
||||
|
||||
padding: 0
|
||||
implicitWidth: theme.controls.box.defaultWidth * 1.25
|
||||
contentHeight: Math.min(
|
||||
window.height,
|
||||
Math.max(
|
||||
serverList.contentHeight,
|
||||
// busyIndicatorLoader.height + theme.spacing * 2, TODO
|
||||
)
|
||||
)
|
||||
contentHeight: window.height
|
||||
|
||||
header: HLabel {
|
||||
text: qsTr(
|
||||
@ -138,8 +132,23 @@ HBox {
|
||||
)
|
||||
placeholderText: "example.org"
|
||||
|
||||
onTextEdited: py.callCoro(
|
||||
"set_substring_filter", ["filtered_homeservers", text],
|
||||
)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Keys.onBacktabPressed: ev => Keys.onUpPressed(ev)
|
||||
Keys.onTabPressed: ev => Keys.onDownPressed(ev)
|
||||
Keys.onUpPressed: {
|
||||
serverList.decrementCurrentIndex()
|
||||
serverList.setFieldText(serverList.currentIndex)
|
||||
}
|
||||
Keys.onDownPressed: {
|
||||
serverList.incrementCurrentIndex()
|
||||
serverList.setFieldText(serverList.currentIndex)
|
||||
}
|
||||
}
|
||||
|
||||
HButton {
|
||||
@ -177,7 +186,10 @@ HBox {
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: fetchServersFuture === null && serverList.count === 0
|
||||
running:
|
||||
fetchServersFuture === null &&
|
||||
ModelStore.get("homeservers").count === 0
|
||||
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: box.fetchServers()
|
||||
@ -197,16 +209,20 @@ HBox {
|
||||
|
||||
HListView {
|
||||
id: serverList
|
||||
|
||||
function setFieldText(fromItemIndex) {
|
||||
serverField.item.field.text =
|
||||
model.get(fromItemIndex).id.replace(/^https:\/\//, "")
|
||||
}
|
||||
|
||||
clip: true
|
||||
model: ModelStore.get("homeservers")
|
||||
model: ModelStore.get("filtered_homeservers")
|
||||
|
||||
delegate: ServerDelegate {
|
||||
width: serverList.width
|
||||
loadingIconStep: box.loadingIconStep
|
||||
onClicked: {
|
||||
serverField.item.field.text =
|
||||
model.id.replace(/^https:\/\//, "")
|
||||
|
||||
setFieldText(model.index)
|
||||
serverField.item.apply.clicked()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user