feat: render server display_title for group events (consistent across clients)

CalEvent parses display_title; decorateGroup uses it (group icon + owner prefix
from the server) instead of the hardcoded glyph, with a fallback for older
servers. Raw title kept for editing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Guido Schmit
2026-06-01 17:54:23 +02:00
parent 7a9bdba557
commit 87fc8df146
2 changed files with 8 additions and 0 deletions

View File

@@ -31,6 +31,9 @@ data class CalEvent(
val owner: EventPerson? = null,
val isGroupEvent: Boolean = false,
val displayColor: String? = null,
// Server-decorated title for the group combined view (group icon / owner
// prefix); rendered in group mode while `title` stays raw for editing.
val displayTitle: String? = null,
) {
/**
* Group view supplies a server-resolved colour (display_color); otherwise
@@ -117,6 +120,7 @@ data class CalEvent(
owner = personFrom(json, "owner"),
isGroupEvent = json.optBoolean("is_group_event", false),
displayColor = json.strOrNull("display_color"),
displayTitle = json.strOrNull("display_title"),
)
}
}

View File

@@ -215,6 +215,10 @@ class CalendarViewModel @Inject constructor(
private fun decorateGroup(events: List<CalEvent>): List<CalEvent> {
val me = currentUserId
return events.map { ev ->
// Prefer the server-decorated title (group icon + owner prefix) so
// web, iOS and Android render identically; fall back for old servers.
val serverTitle = ev.displayTitle?.takeIf { it.isNotEmpty() }
if (serverTitle != null) return@map ev.copy(title = serverTitle)
val prefix = when {
ev.isGroupEvent && ev.creator != null && ev.creator.id != me -> "👥 ${firstName(ev.creator.displayName)}: "
ev.isGroupEvent -> "👥 "