From 44580a8a252836c1675bb51b0674a543b75f5beb Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 25 Mar 2022 21:10:20 -0500 Subject: [PATCH] Fix: (ement-room--format-m.image) Handle missing URLs Not sure why this can happen, but occasionally it does (maybe only while debugging or when other bugs cause incomplete event insertion). --- ement-room.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ement-room.el b/ement-room.el index 5d85403..2a98bfd 100644 --- a/ement-room.el +++ b/ement-room.el @@ -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) @@ -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))))))