Skip to content

Commit

Permalink
Fix: (ement-room--format-m.image) Handle missing URLs
Browse files Browse the repository at this point in the history
Not sure why this can happen, but occasionally it does (maybe only
while debugging or when other bugs cause incomplete event insertion).
  • Loading branch information
alphapapa committed Mar 26, 2022
1 parent 9d1baf6 commit 44580a8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -3132,12 +3132,13 @@ show it in the buffer."
((cl-struct ement-room local) ement-room)
((map buffer) local)
;; TODO: Thumbnail support.
((map url info ;; (thumbnail_url thumbnail-url)
((map ('url mxc) info ;; ('thumbnail_url thumbnail-url)
) content)
((map thumbnail_info) info)
((map ('h _thumbnail-height) ('w _thumbnail-width)) thumbnail_info)
((map image) event-local)
(url (ement--mxc-to-url url ement-session))
(url (when mxc
(ement--mxc-to-url mxc ement-session)))
;; (thumbnail-url (ement--mxc-to-url thumbnail-url ement-session))
)
(if (and ement-room-images image)
Expand Down Expand Up @@ -3177,12 +3178,12 @@ show it in the buffer."
;; Image not downloaded: insert URL as button, and download if enabled.
(prog1
(with-temp-buffer
(insert-text-button url
(insert-text-button (or url "[no URL for image]")
'face 'link
'follow-link t)
(buffer-string))
(when ement-room-images
;; Images enabled: download it.
(when (and ement-room-images url)
;; Images enabled and URL present: download it.
(plz 'get url :as 'binary
:then (apply-partially #'ement-room--m.image-callback event ement-room)
:noquery t))))))
Expand Down

0 comments on commit 44580a8

Please sign in to comment.