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