WIP: Only fill gaps after initial sync

This commit is contained in:
Adam Porter 2021-09-14 15:10:43 +00:00
parent ad8766ef10
commit d7e33f9bc1

View file

@ -614,16 +614,20 @@ To be called in `ement-sync-callback-hook'."
do (run-hook-with-args 'ement-event-hook event room session)
(when (ement--sync-messages-p session)
(ement-progress-update)))
(when (alist-get 'limited timeline)
;; Timeline was limited: start filling gap. We start the
;; gap-filling, retrieving up to the session's current
;; next-batch token (this function is not called when retrieving
;; older messages, so the session's next-batch token is only
;; evaluated once, when this chain begins, and then that token
;; is passed to repeated calls to `ement-room-retro-to-token'
;; until the gap is filled).
(ement-room-retro-to-token joined-room session (alist-get 'prev_batch timeline)
(ement-session-next-batch session)))))
(when (ement-session-has-synced-p session)
;; NOTE: We don't fill gaps in "limited" requests on initial
;; sync, only in subsequent syncs, e.g. after the system has
;; slept and awakened.
(when (alist-get 'limited timeline)
;; Timeline was limited: start filling gap. We start the
;; gap-filling, retrieving up to the session's current
;; next-batch token (this function is not called when retrieving
;; older messages, so the session's next-batch token is only
;; evaluated once, when this chain begins, and then that token
;; is passed to repeated calls to `ement-room-retro-to-token'
;; until the gap is filled).
(ement-room-retro-to-token room session (alist-get 'prev_batch timeline)
(ement-session-next-batch session))))))
(defun ement--make-event (event)
"Return `ement-event' struct for raw EVENT list.