Files
Convivo/apps/convivo/src/lib/agendaBlocks.ts
T
84691de6ee feat: sync GridSmart agendas and use event-relative demo time
Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
2026-10-11 08:39:15 +02:00

24 lines
1.2 KiB
TypeScript

import type { Session, Slot } from './types';
type AgendaBlock = { slot: Slot; sessions: Session[] };
export function mergeAgendaPlaceholders(slots: AgendaBlock[]): AgendaBlock[] {
const blocks = slots.map(block => ({ slot: block.slot, sessions: [...block.sessions] }));
const merged = new Set<number>();
for (const block of blocks) {
if (block.slot.type !== 'service_session') continue;
const target = blocks.find(candidate => candidate.slot.type === 'session'
&& candidate.slot.slot_date === block.slot.slot_date
&& candidate.slot.start_time === block.slot.start_time
&& candidate.slot.end_time === block.slot.end_time);
if (!target) continue;
const placeholders = block.sessions.filter(session => session.slot_type === 'service_session'
&& session.title.trim().toLowerCase() === 'placeholder');
if (!placeholders.length) continue;
target.sessions.push(...placeholders);
const transferred = new Set(placeholders.map(session => session.id));
block.sessions = block.sessions.filter(session => !transferred.has(session.id));
if (!block.sessions.length) merged.add(block.slot.id);
}
return blocks.filter(block => !merged.has(block.slot.id));
}