668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 1 | <script lang="ts"> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 2 | import { onDestroy, onMount, tick } from 'svelte'; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 3 | import { closeEventContext, eventContext, eventContextAfter, eventContextBefore } from './api'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 4 | import EmojiText from './EmojiText.svelte'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 5 | import MessageRow from './MessageRow.svelte'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 6 | import { formatDay } from './format'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 7 | import { TimelineViewport } from './timeline-viewport'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 8 | import type { EventContext, TimelineEvent, TimelineItem } from './types'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 9 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 10 | export let context: EventContext; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 11 | export let roomId: string; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 12 | export let eventId: string; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 13 | export let roomName: string; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 14 | export let self: string | null = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 15 | export let canPaginate = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 16 | export let onClose: () => void; |
4f91f89d99fa | atagen | 2026-10-25 10:47 UTC | 17 | export let onLive: (roomId: string, eventId: string, threadRoot: string | null) => void; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 18 | export let closeLabel = 'Back to mentions'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 19 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 20 | let rows: TimelineItem[] = []; |
4f91f89d99fa | atagen | 2026-10-25 10:47 UTC | 21 | $: targetThread = rows.reduce<string | null>((found, item) => found ?? (item.kind === 'event' && item.event.event_id === eventId ? item.event.thread_root : null), null); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 22 | let beforeToken: string | null = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 23 | let afterToken: string | null = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 24 | let beforeEnded = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 25 | let afterEnded = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 26 | let beforeExtended = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 27 | let afterExtended = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 28 | let beforeBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 29 | let afterBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 30 | let error = ''; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 31 | let list: HTMLDivElement; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 32 | let contentNode: HTMLDivElement; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 33 | let backButton: HTMLButtonElement; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 34 | let viewport: TimelineViewport | null = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 35 | let observer: ResizeObserver | null = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 36 | let generation = 0; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 37 | let mounted = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 38 | let alive = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 39 | let identity = ''; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 40 | let centered = false; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 41 | let contextId: string | null = null; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 42 | let contextFor = ''; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 43 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 44 | const stable = (event: TimelineEvent) => event.event_id || event.item_id; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 45 | const key = (item: TimelineItem) => item.kind === 'event' |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 46 | ? `event-${stable(item.event)}` |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 47 | : item.kind === 'day' ? `day-${item.timestamp_ms}` : item.kind; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 48 | function normalize(items: TimelineItem[]): TimelineItem[] { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 49 | const seen = new Set<string>(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 50 | const result: TimelineItem[] = []; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 51 | for (const item of items) { |
43c2cc753052 | atagen | 2026-10-25 07:50 UTC | 52 | if (item.kind === 'readMarker' || item.kind === 'start' || item.kind === 'unknown' || item.kind === 'historyGap') continue; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 53 | if (item.kind === 'event') { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 54 | const eventKey = stable(item.event); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 55 | if (seen.has(eventKey)) continue; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 56 | seen.add(eventKey); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 57 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 58 | result.push(item); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 59 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 60 | return result; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 61 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 62 | function merge(base: TimelineItem[], incoming: TimelineItem[]): TimelineItem[] { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 63 | const events = new Map<string, TimelineItem>(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 64 | const days = new Map<number, TimelineItem>(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 65 | for (const item of [...base, ...incoming]) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 66 | if (item.kind === 'event') events.set(stable(item.event), item); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 67 | else if (item.kind === 'day') days.set(item.timestamp_ms, item); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 68 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 69 | return [...events.values(), ...days.values()].sort((a, b) => timestamp(a) - timestamp(b)); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 70 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 71 | function timestamp(item: TimelineItem): number { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 72 | if (item.kind === 'event') return item.event.timestamp_ms; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 73 | if (item.kind === 'day') return item.timestamp_ms; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 74 | return 0; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 75 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 76 | function refresh(next: EventContext): void { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 77 | const nextIdentity = `${roomId}\u0000${eventId}`; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 78 | if (identity !== nextIdentity) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 79 | generation++; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 80 | identity = nextIdentity; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 81 | closeSession(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 82 | rows = []; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 83 | beforeToken = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 84 | afterToken = null; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 85 | beforeEnded = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 86 | afterEnded = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 87 | beforeExtended = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 88 | afterExtended = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 89 | beforeBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 90 | afterBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 91 | error = ''; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 92 | centered = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 93 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 94 | const request = generation; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 95 | viewport?.capture(); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 96 | const initial = normalize([...next.events_before, next.event, ...next.events_after]); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 97 | rows = rows.length ? merge(rows, initial) : initial; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 98 | if (!beforeExtended) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 99 | beforeToken = next.start_token; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 100 | beforeEnded = !beforeToken; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 101 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 102 | if (!afterExtended) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 103 | afterToken = next.end_token; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 104 | afterEnded = !afterToken; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 105 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 106 | tick().then(() => { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 107 | if (!alive || request !== generation) return; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 108 | viewport?.restore(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 109 | }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 110 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 111 | $: if (context) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 112 | roomId; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 113 | eventId; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 114 | refresh(context); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 115 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 116 | $: if (mounted && list) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 117 | context; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 118 | const anchorRoom = roomId; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 119 | const anchorEvent = eventId; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 120 | tick().then(() => { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 121 | if (!alive || anchorRoom !== roomId || anchorEvent !== eventId || !context) return; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 122 | if (!centered) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 123 | const target = list.querySelector<HTMLElement>('[data-target="true"]'); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 124 | target?.scrollIntoView({ block: 'center', behavior: 'auto' }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 125 | centered = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 126 | viewport?.capture(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 127 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 128 | }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 129 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 130 | |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 131 | function closeSession(): void { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 132 | if (contextId) void closeEventContext(contextId).catch(() => undefined); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 133 | contextId = null; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 134 | } |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 135 | |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 136 | /** The saved capture has no session, so paging opens one on demand and takes over its tokens. */ |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 137 | async function openSession(): Promise<string | null> { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 138 | if (contextId && contextFor === identity) return contextId; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 139 | const forIdentity = identity; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 140 | const opened = await eventContext(roomId, eventId, 20); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 141 | if (!alive || forIdentity !== identity) { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 142 | void closeEventContext(opened.context_id).catch(() => undefined); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 143 | return null; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 144 | } |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 145 | closeSession(); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 146 | contextId = opened.context_id; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 147 | contextFor = forIdentity; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 148 | rows = merge(rows, normalize([...opened.context.events_before, opened.context.event, ...opened.context.events_after])); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 149 | if (!beforeExtended) beforeToken = opened.context.start_token; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 150 | if (!afterExtended) afterToken = opened.context.end_token; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 151 | return contextId; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 152 | } |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 153 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 154 | async function load(direction: 'before' | 'after'): Promise<void> { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 155 | const token = direction === 'before' ? beforeToken : afterToken; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 156 | if (!token || !canPaginate || (direction === 'before' ? beforeBusy : afterBusy)) return; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 157 | const request = generation; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 158 | if (direction === 'before') beforeBusy = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 159 | else afterBusy = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 160 | error = ''; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 161 | try { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 162 | const session = await openSession(); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 163 | if (!session || !alive || request !== generation) return; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 164 | const from = direction === 'before' ? beforeToken : afterToken; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 165 | if (!from) { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 166 | if (direction === 'before') beforeEnded = true; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 167 | else afterEnded = true; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 168 | return; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 169 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 170 | const page = direction === 'before' |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 171 | ? await eventContextBefore(session, from, 20) |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 172 | : await eventContextAfter(session, from, 20); |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 173 | if (!alive || request !== generation) return; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 174 | viewport?.capture(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 175 | rows = merge(rows, page.events); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 176 | if (direction === 'before') { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 177 | beforeExtended = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 178 | beforeToken = page.next_token; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 179 | beforeEnded = !page.next_token; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 180 | } else { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 181 | afterExtended = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 182 | afterToken = page.next_token; |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 183 | afterEnded = !page.next_token; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 184 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 185 | await tick(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 186 | if (alive && request === generation) viewport?.restore(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 187 | } catch (cause) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 188 | if (alive && request === generation) error = cause instanceof Error ? cause.message : 'Could not load messages'; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 189 | } finally { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 190 | if (alive && request === generation) { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 191 | if (direction === 'before') beforeBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 192 | else afterBusy = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 193 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 194 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 195 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 196 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 197 | function handleScroll(): void { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 198 | if (!viewport?.consumeScroll()) viewport?.capture(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 199 | } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 200 | onDestroy(() => { |
249e439c27e5 | atagen | 2026-10-25 13:26 UTC | 201 | closeSession(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 202 | alive = false; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 203 | generation++; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 204 | observer?.disconnect(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 205 | viewport?.releaseScroll(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 206 | }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 207 | onMount(() => { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 208 | mounted = true; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 209 | tick().then(() => { |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 210 | if (!alive || !list) return; |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 211 | viewport = new TimelineViewport(list, roomId); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 212 | observer = new ResizeObserver(() => viewport?.restore()); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 213 | if (contentNode) observer.observe(contentNode); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 214 | backButton?.focus(); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 215 | }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 216 | }); |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 217 | </script> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 218 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 219 | <section class="context-timeline"> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 220 | <header> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 221 | <button bind:this={backButton} onclick={onClose}><EmojiText text={closeLabel} /></button> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 222 | <strong><EmojiText text={roomName} /></strong> |
4f91f89d99fa | atagen | 2026-10-25 10:47 UTC | 223 | <button disabled={!canPaginate} onclick={() => onLive(roomId, eventId, targetThread)}>Go to current messages</button> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 224 | </header> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 225 | {#if error}<div class="error" role="alert"><EmojiText text={error} /></div>{/if} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 226 | <button class="page-control" disabled={!beforeToken || beforeEnded || beforeBusy || !canPaginate} onclick={() => load('before')}> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 227 | {beforeBusy ? 'Loading…' : 'Load earlier messages'} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 228 | </button> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 229 | <div class="messages" bind:this={list} onscroll={handleScroll}> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 230 | <div class="content" bind:this={contentNode}> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 231 | {#each rows as item (key(item))} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 232 | {#if item.kind === 'day'} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 233 | <div class="day"><span><EmojiText text={formatDay(item.timestamp_ms)} /></span></div> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 234 | {:else if item.kind === 'event'} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 235 | <div class:mentioned={item.event.event_id === eventId} aria-label={item.event.event_id === eventId ? 'Mentioned message' : undefined} data-target={item.event.event_id === eventId ? 'true' : undefined}> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 236 | <MessageRow itemId={stable(item.event)} event={item.event} showSender={true} reacting={false} onReact={() => {}} readOnly={true} showSent={false} {self} senderAvatar={item.event.sender.avatar} /> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 237 | </div> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 238 | {/if} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 239 | {/each} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 240 | </div> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 241 | </div> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 242 | <button class="page-control" disabled={!afterToken || afterEnded || afterBusy || !canPaginate} onclick={() => load('after')}> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 243 | {afterBusy ? 'Loading…' : 'Load later messages'} |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 244 | </button> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 245 | </section> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 246 | |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 247 | <style> |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 248 | .context-timeline { display:flex; flex-direction:column; min-width:0; min-height:0; height:100%; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 249 | header { display:flex; align-items:center; gap:.6rem; padding:.5rem; border-bottom:1px solid var(--border); flex-wrap:wrap; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 250 | header strong { flex:1; min-width:0; overflow-wrap:anywhere; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 251 | button { color:var(--text); background:var(--panel); border:1px solid var(--border); border-radius:.4rem; padding:.4rem .65rem; cursor:pointer; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 252 | button:disabled { opacity:.55; cursor:default; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 253 | .messages { flex:1; min-height:0; overflow:auto; overflow-anchor:none; padding:.5rem; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 254 | .content { min-width:0; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 255 | .mentioned { outline:2px solid var(--accent); border-radius:.5rem; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 256 | .day { display:flex; align-items:center; gap:.6rem; color:var(--muted); font-size:.8rem; margin:.75rem 0; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 257 | .day::before,.day::after { content:''; height:1px; background:var(--border); flex:1; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 258 | .page-control { align-self:center; margin:.4rem; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 259 | .error { color:var(--danger); padding:.5rem; overflow-wrap:anywhere; } |
668ab5c30531 | atagen | 2026-10-25 03:13 UTC | 260 | </style> |