feat(calendar): show contact avatars on event cards

This commit is contained in:
Ruslan Bakiev
2026-02-26 12:18:14 +07:00
parent 5063dfdecf
commit 0a470d3922
2 changed files with 103 additions and 12 deletions

View File

@@ -960,6 +960,32 @@ function threadChannelLabel(thread: { id: string; channels: CommItem["channel"][
return "No channel";
}
const contactByName = computed(() => {
const map = new Map<string, Contact>();
for (const contact of contacts.value) {
const key = (contact.name ?? "").trim();
if (!key || map.has(key)) continue;
map.set(key, contact);
}
return map;
});
function avatarSrcForCalendarEvent(event: CalendarEvent) {
const contactName = String(event.contact ?? "").trim();
if (!contactName) return "";
const contact = contactByName.value.get(contactName);
if (!contact) return "";
return avatarSrcForThread({ id: contact.id, avatar: contact.avatar });
}
function markCalendarAvatarBroken(event: CalendarEvent) {
const contactName = String(event.contact ?? "").trim();
if (!contactName) return;
const contact = contactByName.value.get(contactName);
if (!contact) return;
markAvatarBroken(contact.id);
}
// ---------------------------------------------------------------------------
// Auth display
// ---------------------------------------------------------------------------
@@ -1437,6 +1463,9 @@ onBeforeUnmount(() => {
:focused-calendar-event="focusedCalendarEvent"
:format-day="formatDay"
:format-time="formatTime"
:avatar-src-for-calendar-event="avatarSrcForCalendarEvent"
:mark-calendar-avatar-broken="markCalendarAvatarBroken"
:contact-initials="contactInitials"
:set-calendar-content-wrap-ref="setCalendarContentWrapRef"
:shift-calendar="shiftCalendar"
:set-calendar-content-scroll-ref="setCalendarContentScrollRef"