fix: attach calendar color to created/updated events for cache + frontend

Events created or updated via the API were missing the calendar's
backgroundColor, causing them to render without their provider color.

v1.72.1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-25 02:10:11 +01:00
parent 08959c6ddb
commit e1190a8fe6
2 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "name": "my-weekly-todo-list",
"version": "1.72.0", "version": "1.72.1",
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -76,6 +76,14 @@ export async function POST(request: NextRequest) {
attachments, attachments,
} as any); } as any);
// Attach calendar color from connection metadata for cache + frontend
if (!event.backgroundColor && connection.calendars) {
const cal = (connection.calendars as any[]).find((c: any) => c.id === calendarId);
if (cal?.backgroundColor || cal?.color) {
event.backgroundColor = cal.backgroundColor || cal.color;
}
}
// Update cache - await to ensure it's ready before client refreshes // Update cache - await to ensure it's ready before client refreshes
try { try {
await upsertCachedEvent(userId, connection.id, connection.provider, event); await upsertCachedEvent(userId, connection.id, connection.provider, event);
@ -144,6 +152,14 @@ export async function PATCH(request: NextRequest) {
attachments, attachments,
} as any); } as any);
// Attach calendar color from connection metadata for cache + frontend
if (!event.backgroundColor && connection.calendars) {
const cal = (connection.calendars as any[]).find((c: any) => c.id === calendarId);
if (cal?.backgroundColor || cal?.color) {
event.backgroundColor = cal.backgroundColor || cal.color;
}
}
// Update cache - await to ensure it's ready before client refreshes // Update cache - await to ensure it's ready before client refreshes
try { try {
await upsertCachedEvent(userId, connection.id, connection.provider, event); await upsertCachedEvent(userId, connection.id, connection.provider, event);