Fix: include public/avatars in backups and restoration, add graceful fallback for missing contact photos

This commit is contained in:
sorcier committed 2026-11-02 19:29:38 +01:00
1 parent 2bd1ae0777
commit 45011d8c59
4 files changed
+56 -13

No files matched your search

+9 -5
View File
@@ -5212,7 +5212,7 @@ function renderPhonebookTable() {
const initials = getInitials(c.display_name || '?');
const colorClass = getAvatarBgColor(c.display_name || '');
const avatarHtml = c.photo_url
? `<img src="${escapeHtml(c.photo_url)}" alt="${escapeHtml(c.display_name)}" class="w-8 h-8 rounded-full object-cover border border-anthracite-700 shadow">`
? `<img src="${escapeHtml(c.photo_url)}" alt="${escapeHtml(c.display_name)}" class="w-8 h-8 rounded-full object-cover border border-anthracite-700 shadow" onerror="this.style.display='none'; if(this.nextElementSibling) this.nextElementSibling.style.display='flex';"><div class="w-8 h-8 rounded-full ${colorClass} text-white items-center justify-center font-bold text-xs shadow-inner" style="display:none;">${escapeHtml(initials)}</div>`
: `<div class="w-8 h-8 rounded-full ${colorClass} text-white flex items-center justify-center font-bold text-xs shadow-inner">${escapeHtml(initials)}</div>`;
const typeBadge = c.is_internal
@@ -5409,13 +5409,17 @@ function updateAvatarPreview(photoUrl, name) {
const clearBtn = document.getElementById('phonebook-btn-clear-photo');
if (!preview) return;
const initials = getInitials(name || '?');
const colorClass = getAvatarBgColor(name || '');
if (photoUrl) {
preview.className = 'w-14 h-14 rounded-full overflow-hidden border border-teal-500/40 shrink-0 shadow';
preview.innerHTML = `<img src="${escapeHtml(photoUrl)}" class="w-full h-full object-cover">`;
preview.className = 'w-14 h-14 rounded-full overflow-hidden border border-teal-500/40 shrink-0 shadow relative flex items-center justify-center';
preview.innerHTML = `
<img src="${escapeHtml(photoUrl)}" class="w-full h-full object-cover" onerror="this.style.display='none'; if(this.nextElementSibling) this.nextElementSibling.style.display='flex';">
<div class="w-full h-full ${colorClass} text-white items-center justify-center font-bold text-lg shadow-inner" style="display:none;">${escapeHtml(initials)}</div>
`;
clearBtn?.classList.remove('hidden');
} else {
const initials = getInitials(name || '?');
const colorClass = getAvatarBgColor(name || '');
preview.className = `w-14 h-14 rounded-full ${colorClass} text-white flex items-center justify-center font-bold text-lg overflow-hidden shrink-0 shadow-inner`;
preview.textContent = initials;
clearBtn?.classList.add('hidden');