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
This commit is contained in:
ralf 2023-07-27 12:45:40 +02:00
parent 322fefa62c
commit 0f692fbb74
2 changed files with 8 additions and 5 deletions

View File

@ -179,7 +179,7 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe
if (!_contactId) if (!_contactId)
{ {
parsedId = this.egw().user('account_id'); parsedId = null;
} }
else if(_contactId.substr(0, 8) === 'account:') 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; let oldContactId = this._contactId;
this._contactId = _contactId; this._contactId = _contactId;
// if our image (incl. cache-buster) already includes the correct id, use that one // 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; params[id] = parsedId;
this.image = egw.link('/api/avatar.php', params); this.image = egw.link('/api/avatar.php', params);

View File

@ -1257,9 +1257,7 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
*/ */
protected processRemoteResults(entries, totalResults = 0) protected processRemoteResults(entries, totalResults = 0)
{ {
let resultCount = entries.length; if(!entries?.length)
if(entries.length == 0)
{ {
return Promise.resolve(); return Promise.resolve();
} }
@ -1288,6 +1286,7 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
*/ */
let temp_target = document.createElement("div"); let temp_target = document.createElement("div");
let resultCount = entries.length;
render(options, temp_target); render(options, temp_target);
return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render))) return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render)))