Defer fetching user profiles for events

Previously, events for which the sender, target (state_key) or remover
was missing from the room members would have their profile fetched
from network when registering the event into models.

This could cause very slow past events loading times for rooms, since
the event registering function (which contained the profile retrieval
directives) is run sequentially event-by-event.

Missing profiles are now lazy-loaded when events come into the
user's view in the QML timeline.
This commit is contained in:
miruka
2020-05-20 03:42:40 -04:00
parent bc5549195b
commit 63af4be1e2
6 changed files with 87 additions and 32 deletions

View File

@@ -17,6 +17,8 @@ HColumnLayout {
property var hoveredMediaTypeUrl: []
property var fetchProfilesFuture: null
// Remember timeline goes from newest message at index 0 to oldest
readonly property var previousModel: eventList.model.get(model.index + 1)
readonly property var nextModel: eventList.model.get(model.index - 1)
@@ -64,6 +66,13 @@ HColumnLayout {
// HSelectableLabel's MouseArea hover events
onCursorShapeChanged: eventList.cursorShape = cursorShape
Component.onCompleted: if (model.fetch_profile) py.callClientCoro(
chat.userId, "get_event_profiles", [chat.roomId, model.id],
)
Component.onDestruction:
if (fetchProfilesFuture) fetchProfilesFuture.cancel()
function json() {
let event = ModelStore.get(chat.userId, chat.roomId, "events")