From 0f692fbb742a61da0ce3d9532eaf33507f85d35f Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 27 Jul 2023 12:45:40 +0200 Subject: [PATCH] fix lavatar shows same letters for every contact not having a photo caused by wrongly falling back to the contact with contact_id equal to account_id of current user also fix TypeError if remote search does not return an array --- api/js/etemplate/Et2Avatar/Et2Avatar.ts | 8 ++++++-- api/js/etemplate/Et2Select/SearchMixin.ts | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Avatar/Et2Avatar.ts b/api/js/etemplate/Et2Avatar/Et2Avatar.ts index a7e7006b11..81a959b6be 100644 --- a/api/js/etemplate/Et2Avatar/Et2Avatar.ts +++ b/api/js/etemplate/Et2Avatar/Et2Avatar.ts @@ -179,7 +179,7 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe if (!_contactId) { - parsedId = this.egw().user('account_id'); + parsedId = null; } else if(_contactId.substr(0, 8) === 'account:') { @@ -200,7 +200,11 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe let oldContactId = this._contactId; this._contactId = _contactId; // if our image (incl. cache-buster) already includes the correct id, use that one - if(!this.image || !this.image.match("(&|\\?)" + id + "=" + encodeURIComponent(parsedId) + "(&|$)")) + if (!parsedId) + { + this.image = null; + } + else if(!this.image || !this.image.match("(&|\\?)" + id + "=" + encodeURIComponent(parsedId) + "(&|$)")) { params[id] = parsedId; this.image = egw.link('/api/avatar.php', params); diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 28eef8d431..a230fd58ea 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -1257,9 +1257,7 @@ export const Et2WithSearchMixin = >(superclass */ protected processRemoteResults(entries, totalResults = 0) { - let resultCount = entries.length; - - if(entries.length == 0) + if(!entries?.length) { return Promise.resolve(); } @@ -1288,6 +1286,7 @@ export const Et2WithSearchMixin = >(superclass */ let temp_target = document.createElement("div"); + let resultCount = entries.length; render(options, temp_target); return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render)))