mirror of
https://github.com/vale981/ement.el
synced 2025-03-04 17:01:39 -05:00
Fix: (ement-room-goto-fully-read-marker) For missing marker node
Not sure how this can happen, but sometimes it does. Not including in the changelog because it may be caused by changes in this pre-release version, and it would be difficult to describe to users, anyway.
This commit is contained in:
parent
397ee96777
commit
24c83355ff
1 changed files with 20 additions and 12 deletions
|
@ -2506,16 +2506,24 @@ To be called from timer stored in
|
||||||
(defun ement-room-goto-fully-read-marker ()
|
(defun ement-room-goto-fully-read-marker ()
|
||||||
"Move to the fully-read marker in the current room."
|
"Move to the fully-read marker in the current room."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((fully-read-pos (when ement-room-fully-read-marker
|
(if-let ((fully-read-pos (when ement-room-fully-read-marker
|
||||||
(ewoc-location ement-room-fully-read-marker))))
|
(ewoc-location ement-room-fully-read-marker))))
|
||||||
(if fully-read-pos
|
(setf (point) fully-read-pos (window-start) fully-read-pos)
|
||||||
(setf (point) fully-read-pos (window-start) fully-read-pos)
|
;; Unlike the fully-read marker, there doesn't seem to be a
|
||||||
;; Unlike the fully-read marker, there doesn't seem to be a
|
;; simple way to get the user's read-receipt marker. So if
|
||||||
;; simple way to get the user's read-receipt marker. So if
|
;; we haven't seen either marker in the retrieved events, we
|
||||||
;; we haven't seen either marker in the retrieved events, we
|
;; go back to the fully-read marker.
|
||||||
;; go back to the fully-read marker.
|
(if-let* ((fully-read-event (alist-get "m.fully_read" (ement-room-account-data ement-room) nil nil #'equal))
|
||||||
(if-let* ((fully-read-event (alist-get "m.fully_read" (ement-room-account-data ement-room) nil nil #'equal))
|
(fully-read-event-id (map-nested-elt fully-read-event '(content event_id))))
|
||||||
(fully-read-event-id (map-nested-elt fully-read-event '(content event_id))))
|
;; Fully-read account-data event is known.
|
||||||
|
(if (gethash fully-read-event-id (ement-session-events ement-session))
|
||||||
|
;; The fully-read event (i.e. the message event that was read, not the
|
||||||
|
;; account-data event) is already retrieved, but the marker is not present in
|
||||||
|
;; the buffer (this shouldn't happen, but somehow, it can): Reset the marker,
|
||||||
|
;; which should work around the problem.
|
||||||
|
(ement-room-mark-read ement-room ement-session
|
||||||
|
:fully-read-event (gethash fully-read-event-id (ement-session-events ement-session)))
|
||||||
|
;; Fully-read event not retrieved: search for it in room history.
|
||||||
(let ((buffer (current-buffer)))
|
(let ((buffer (current-buffer)))
|
||||||
(message "Searching for first unread event...")
|
(message "Searching for first unread event...")
|
||||||
(ement-room-retro-to ement-room ement-session fully-read-event-id
|
(ement-room-retro-to ement-room ement-session fully-read-event-id
|
||||||
|
@ -2523,8 +2531,8 @@ To be called from timer stored in
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
;; HACK: Should probably call this function elsewhere, in a hook or something.
|
;; HACK: Should probably call this function elsewhere, in a hook or something.
|
||||||
(ement-room-move-read-markers ement-room)
|
(ement-room-move-read-markers ement-room)
|
||||||
(ement-room-goto-fully-read-marker)))))
|
(ement-room-goto-fully-read-marker))))))
|
||||||
(error "Room has no fully-read event")))))
|
(error "Room has no fully-read event"))))
|
||||||
|
|
||||||
(cl-defun ement-room-mark-read (room session &key read-event fully-read-event)
|
(cl-defun ement-room-mark-read (room session &key read-event fully-read-event)
|
||||||
"Mark ROOM on SESSION as read on the server.
|
"Mark ROOM on SESSION as read on the server.
|
||||||
|
|
Loading…
Add table
Reference in a new issue