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"^[#!].+:.+")
|
room_id_or_alias_regex = re.compile(r"^[#!].+:.+")
|
||||||
http_s_url = re.compile(r"^https?://")
|
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,
|
def __init__(self,
|
||||||
backend,
|
backend,
|
||||||
|
@ -281,9 +298,10 @@ class MatrixClient(nio.AsyncClient):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.sync_task = asyncio.ensure_future(
|
self.sync_task = asyncio.ensure_future(self.sync_forever(
|
||||||
self.sync_forever(timeout=10_000),
|
timeout = 10_000,
|
||||||
)
|
sync_filter = self.server_filter,
|
||||||
|
))
|
||||||
await self.sync_task
|
await self.sync_task
|
||||||
break # task cancelled
|
break # task cancelled
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -712,6 +730,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
room_id = room_id,
|
room_id = room_id,
|
||||||
start = self.past_tokens[room_id],
|
start = self.past_tokens[room_id],
|
||||||
limit = 100 if room_id in self.loaded_once_rooms else 25,
|
limit = 100 if room_id in self.loaded_once_rooms else 25,
|
||||||
|
message_filter = self.server_filter,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.loaded_once_rooms.add(room_id)
|
self.loaded_once_rooms.add(room_id)
|
||||||
|
|
|
@ -50,13 +50,13 @@ QtObject {
|
||||||
|
|
||||||
|
|
||||||
function onModelItemInserted(syncId, index, item) {
|
function onModelItemInserted(syncId, index, item) {
|
||||||
// print("insert", syncId, index, item)
|
print("insert", syncId, index, item)
|
||||||
ModelStore.get(syncId).insert(index, item)
|
ModelStore.get(syncId).insert(index, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onModelItemFieldChanged(syncId, oldIndex, newIndex, field, value){
|
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)
|
const model = ModelStore.get(syncId)
|
||||||
model.setProperty(oldIndex, field, value)
|
model.setProperty(oldIndex, field, value)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ QtObject {
|
||||||
|
|
||||||
|
|
||||||
function onModelItemDeleted(syncId, index) {
|
function onModelItemDeleted(syncId, index) {
|
||||||
// print("del", syncId, index)
|
print("del", syncId, index)
|
||||||
ModelStore.get(syncId).remove(index)
|
ModelStore.get(syncId).remove(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user