Enable member lazy-loading for /sync and /messages
This commit is contained in:
parent
48a5f54e54
commit
1adbddc063
|
@ -88,6 +88,23 @@ class MatrixClient(nio.AsyncClient):
|
|||
room_id_or_alias_regex = re.compile(r"^[#!].+:.+")
|
||||
http_s_url = re.compile(r"^https?://")
|
||||
|
||||
server_filter = {
|
||||
"room": {
|
||||
"ephemeral": {
|
||||
"lazy_load_members": True,
|
||||
},
|
||||
"state": {
|
||||
"lazy_load_members": True,
|
||||
},
|
||||
"timeline": {
|
||||
"lazy_load_members": True,
|
||||
},
|
||||
"account_data": {
|
||||
"lazy_load_members": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def __init__(self,
|
||||
backend,
|
||||
|
@ -281,9 +298,10 @@ class MatrixClient(nio.AsyncClient):
|
|||
|
||||
while True:
|
||||
try:
|
||||
self.sync_task = asyncio.ensure_future(
|
||||
self.sync_forever(timeout=10_000),
|
||||
)
|
||||
self.sync_task = asyncio.ensure_future(self.sync_forever(
|
||||
timeout = 10_000,
|
||||
sync_filter = self.server_filter,
|
||||
))
|
||||
await self.sync_task
|
||||
break # task cancelled
|
||||
except Exception as err:
|
||||
|
@ -712,6 +730,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
room_id = room_id,
|
||||
start = self.past_tokens[room_id],
|
||||
limit = 100 if room_id in self.loaded_once_rooms else 25,
|
||||
message_filter = self.server_filter,
|
||||
)
|
||||
|
||||
self.loaded_once_rooms.add(room_id)
|
||||
|
|
|
@ -50,13 +50,13 @@ QtObject {
|
|||
|
||||
|
||||
function onModelItemInserted(syncId, index, item) {
|
||||
// print("insert", syncId, index, item)
|
||||
print("insert", syncId, index, item)
|
||||
ModelStore.get(syncId).insert(index, item)
|
||||
}
|
||||
|
||||
|
||||
function onModelItemFieldChanged(syncId, oldIndex, newIndex, field, value){
|
||||
// print("change", syncId, oldIndex, newIndex, field, value)
|
||||
print("change", syncId, oldIndex, newIndex, field, value)
|
||||
const model = ModelStore.get(syncId)
|
||||
model.setProperty(oldIndex, field, value)
|
||||
|
||||
|
@ -65,7 +65,7 @@ QtObject {
|
|||
|
||||
|
||||
function onModelItemDeleted(syncId, index) {
|
||||
// print("del", syncId, index)
|
||||
print("del", syncId, index)
|
||||
ModelStore.get(syncId).remove(index)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user