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