From 81bb5c55daa5b3cecdc0108927dfda88223de906 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Mon, 15 Oct 2018 20:01:13 -0500 Subject: [PATCH] Fix: Don't return empty strings for room displaynames --- matrix-client-room.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/matrix-client-room.el b/matrix-client-room.el index b3038d1..69acec1 100644 --- a/matrix-client-room.el +++ b/matrix-client-room.el @@ -471,15 +471,21 @@ a different name is returned." ;; This macro allows short-circuiting the choice forms, only evaluating them when needed. `(or ,@(cl-loop for choice in choices collect `(--when-let ,choice + ;; NOTE: We check to see if strings are empty, + ;; because apparently it can happen that an + ;; mxid is something like "@:hostname", with + ;; an empty displayname. Sigh. (if (listp it) (cl-loop for this-choice in (-non-nil (-flatten it)) - unless (--when-let (get-buffer this-choice) - ;; Allow reusing current name of current buffer - (not (equal it (oref* room extra buffer)))) + unless (or (string-empty-p this-choice) + (--when-let (get-buffer this-choice) + ;; Allow reusing current name of current buffer + (not (equal it (oref* room extra buffer))))) return this-choice) - (unless (--when-let (get-buffer it) - ;; Allow reusing current name of current buffer - (not (equal it (oref* room extra buffer)))) + (unless (or (string-empty-p it) + (--when-let (get-buffer it) + ;; Allow reusing current name of current buffer + (not (equal it (oref* room extra buffer))))) it))))))) (pcase-let* (((eieio id name aliases members session) room) ((eieio (user self)) session))