atmo.rsvp
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

dont delete extra fields on editing

Florian 52fadc94 47d9aea4

+24 -4
+24 -4
src/lib/components/EventEditor.svelte
··· 487 487 try { 488 488 let media: Array<Record<string, unknown>> | undefined; 489 489 490 + // Start with existing media, excluding thumbnail role 491 + const existingMedia = (eventData?.media ?? []) as Array<Record<string, unknown>>; 492 + 490 493 if (isNew || thumbnailChanged) { 491 494 if (thumbnailFile) { 492 495 const compressed = await compressImage(thumbnailFile); 493 496 const result = await uploadBlob({ blob: compressed.blob }); 494 497 if (result) { 495 498 const { aspectRatio: _ar, ...blobRef } = result as Record<string, unknown> & { aspectRatio?: unknown }; 499 + // Keep all non-thumbnail media, add new thumbnail 496 500 media = [ 501 + ...existingMedia.filter((m) => m.role !== 'thumbnail'), 497 502 { 498 503 role: 'thumbnail', 499 504 content: blobRef, ··· 504 509 } 505 510 ]; 506 511 } 512 + } else { 513 + // Thumbnail removed — keep all non-thumbnail media 514 + const remaining = existingMedia.filter((m) => m.role !== 'thumbnail'); 515 + if (remaining.length > 0) media = remaining; 507 516 } 508 - // If changed/new but no thumbnailFile, media stays undefined (thumbnail removed/absent) 509 517 } else { 510 - // Thumbnail not changed — reuse original media from eventData 511 - if (eventData?.media && eventData.media.length > 0) { 512 - media = eventData.media as Array<Record<string, unknown>>; 518 + // Thumbnail not changed — keep all original media 519 + if (existingMedia.length > 0) { 520 + media = existingMedia; 513 521 } 514 522 } 515 523 ··· 517 525 ? new Date().toISOString() 518 526 : eventData?.createdAt || new Date().toISOString(); 519 527 528 + // Spread original record to preserve unspecced fields (e.g. additionalData) 520 529 const record: Record<string, unknown> = { 530 + ...(eventData ? { ...eventData } : {}), 521 531 $type: 'community.lexicon.calendar.event', 522 532 createdWith: 'https://atmo.rsvp', 523 533 name: name.trim(), ··· 526 536 startsAt: new Date(startsAt).toISOString(), 527 537 createdAt 528 538 }; 539 + // Remove flattened fields that aren't part of the actual record 540 + delete record.cid; 541 + delete record.did; 542 + delete record.rkey; 543 + delete record.uri; 544 + delete record.rsvps; 545 + delete record.rsvpsCount; 546 + delete record.rsvpsGoingCount; 547 + delete record.rsvpsInterestedCount; 548 + delete record.rsvpsNotgoingCount; 529 549 530 550 const trimmedDescription = description.trim(); 531 551 if (trimmedDescription) {