973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1 | <script lang="ts"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2 | import MediaAttachmentView from './MediaAttachmentView.svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 3 | import MxcAvatar from './MxcAvatar.svelte'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 4 | import Emoji from './Emoji.svelte'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 5 | import EmojiText from './EmojiText.svelte'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 6 | import ReactionPicker from './ReactionPicker.svelte'; |
b8ab00377c20 | atagen | 2026-10-22 05:13 UTC | 7 | import LinkCard from './LinkCard.svelte'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 8 | import { mediaUrl } from './api'; |
b8ab00377c20 | atagen | 2026-10-22 05:13 UTC | 9 | import type { ImagePack, LinkPreview, QuickReaction, SendState, TimelineContent, TimelineEvent } from './types'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 10 | import { senderLabel } from './types'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 11 | import { formatClock, formatDay, initialsOf, senderHue } from './format'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 12 | import { findUrls } from './urls'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 13 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 14 | export let itemId: string; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 15 | export let event: TimelineEvent; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 16 | export let showSender: boolean; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 17 | export let reacting: boolean; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 18 | export let onReact: (eventId: string, key: string) => void; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 19 | export let senderAvatar: string | null = null; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 20 | export let quickReactions: QuickReaction[] = []; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 21 | export let packs: ImagePack[] = []; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 22 | export let onQuickChange: (list: QuickReaction[]) => void = () => {}; |
b8ab00377c20 | atagen | 2026-10-22 05:13 UTC | 23 | export let linkPreviews: Record<string, LinkPreview> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 24 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 25 | const PICKER_WIDTH = 320; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 26 | const PICKER_HEIGHT = 380; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 27 | const PICKER_MARGIN = 8; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 28 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 29 | let row: HTMLDivElement; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 30 | let pickerPop: HTMLDivElement | undefined; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 31 | let selected = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 32 | let pickerOpen = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 33 | let pickerStyle = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 34 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 35 | const MEMBERSHIP_LABELS: Record<string, string> = { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 36 | Joined: 'joined the room', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 37 | Left: 'left the room', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 38 | Banned: 'was banned', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 39 | Unbanned: 'was unbanned', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 40 | Kicked: 'was kicked', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 41 | KickedAndBanned: 'was kicked and banned', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 42 | Invited: 'was invited', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 43 | InvitationAccepted: 'accepted the invite', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 44 | InvitationRejected: 'rejected the invite', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 45 | InvitationRevoked: 'had the invite revoked', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 46 | Knocked: 'requested to join', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 47 | KnockAccepted: 'was let in', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 48 | KnockRetracted: 'withdrew the request to join', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 49 | KnockDenied: 'had the request to join denied' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 50 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 51 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 52 | $: name = senderLabel(event.sender); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 53 | $: displayName = event.sender.name_ambiguous ? `${name} (${event.sender.user_id})` : name; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 54 | $: interactive = event.content.kind === 'Message' || event.content.kind === 'Sticker' || event.content.kind === 'Poll'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 55 | $: previews = event.content.kind === 'Message' ? findUrls(event.content.message.body) : []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 56 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 57 | function sendLabel(state: SendState): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 58 | if (state.kind === 'Failed') return state.will_retry ? 'failed — will retry' : 'failed — not delivered'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 59 | if (state.kind === 'Sending') return 'sending…'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 60 | if (event.own && state.kind === 'Sent' && event.event_id) return '✓ sent'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 61 | return ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 62 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 63 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 64 | function toggleSelected(e: MouseEvent) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 65 | if (!interactive || (e.target as Element).closest('a, button, input, video, audio, .picker-pop')) return; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 66 | selected = !selected; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 67 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 68 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 69 | function deselectOutside(e: PointerEvent) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 70 | if (selected && !pickerOpen && !row.contains(e.target as Node)) selected = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 71 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 72 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 73 | function openPicker(e: MouseEvent) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 74 | if (pickerOpen) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 75 | pickerOpen = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 76 | return; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 77 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 78 | const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 79 | const height = Math.min(PICKER_HEIGHT, window.innerHeight - 2 * PICKER_MARGIN); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 80 | const below = window.innerHeight - rect.bottom - PICKER_MARGIN >= height; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 81 | const top = below ? rect.bottom + 4 : Math.max(PICKER_MARGIN, rect.top - height - 4); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 82 | const maxLeft = window.innerWidth - PICKER_WIDTH - PICKER_MARGIN; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 83 | const left = Math.max(PICKER_MARGIN, Math.min(rect.right - PICKER_WIDTH, maxLeft)); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 84 | pickerStyle = `top:${top}px;left:${left}px;height:${height}px`; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 85 | selected = true; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 86 | pickerOpen = true; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 87 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 88 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 89 | function closePicker() { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 90 | pickerOpen = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 91 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 92 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 93 | function pick(key: string) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 94 | pickerOpen = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 95 | onReact(event.event_id ?? '', key); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 96 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 97 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 98 | function closeOnScroll(e: Event) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 99 | if (pickerOpen && !pickerPop?.contains(e.target as Node)) pickerOpen = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 100 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 101 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 102 | function actorLabel(userId: string, name: string | null): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 103 | return name ?? userId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 104 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 105 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 106 | function replyPreview(content: TimelineContent): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 107 | if (content.kind === 'Message') return content.message.body; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 108 | if (content.kind === 'Sticker') return content.body || 'Sticker'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 109 | if (content.kind === 'Poll') return `Poll: ${content.question}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 110 | if (content.kind === 'Redacted') return 'Message deleted'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 111 | if (content.kind === 'UnableToDecrypt') return 'Unable to decrypt'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 112 | return systemLine(content); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 113 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 114 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 115 | function systemLine(content: TimelineContent): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 116 | switch (content.kind) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 117 | case 'Redacted': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 118 | return 'Message deleted'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 119 | case 'UnableToDecrypt': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 120 | return `Message from ${displayName} could not be decrypted`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 121 | case 'Membership': { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 122 | const who = actorLabel(content.user_id, content.display_name); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 123 | return `${who} ${MEMBERSHIP_LABELS[content.change] ?? 'updated their membership'}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 124 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 125 | case 'Profile': { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 126 | const who = actorLabel(content.user_id, null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 127 | const parts: string[] = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 128 | if (content.display_name) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 129 | parts.push( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 130 | content.display_name.new |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 131 | ? `changed their display name to "${content.display_name.new}"` |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 132 | : 'removed their display name' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 133 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 134 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 135 | if (content.avatar) parts.push('changed their avatar'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 136 | return `${who} ${parts.length > 0 ? parts.join(' and ') : 'updated their profile'}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 137 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 138 | case 'RoomName': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 139 | return content.name |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 140 | ? `${displayName} changed the room name to "${content.name}"` |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 141 | : `${displayName} removed the room name`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 142 | case 'RoomTopic': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 143 | return content.topic |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 144 | ? `${displayName} changed the topic to "${content.topic}"` |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 145 | : `${displayName} removed the topic`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 146 | case 'RoomAvatar': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 147 | return content.avatar ? `${displayName} changed the room avatar` : `${displayName} removed the room avatar`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 148 | case 'EncryptionEnabled': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 149 | return `${displayName} enabled encryption in this room`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 150 | case 'RoomCreated': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 151 | return `${displayName} created the room`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 152 | case 'RoomUpgraded': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 153 | return `${displayName} upgraded the room to a new version`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 154 | case 'OtherState': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 155 | return `${displayName} sent a state event (${content.event_type})`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 156 | case 'Other': |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 157 | return `${displayName} sent an event (${content.event_type})`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 158 | default: |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 159 | return displayName; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 160 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 161 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 162 | </script> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 163 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 164 | <svelte:window |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 165 | on:pointerdown={deselectOutside} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 166 | on:keydown={(e) => e.key === 'Escape' && (selected = false)} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 167 | on:scroll|capture={closeOnScroll} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 168 | on:resize={closePicker} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 169 | /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 170 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 171 | <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions --> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 172 | <div |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 173 | class="msg" |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 174 | class:own={event.own} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 175 | class:system={!interactive} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 176 | class:selected |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 177 | data-item={itemId} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 178 | bind:this={row} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 179 | on:click={toggleSelected} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 180 | > |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 181 | {#if interactive && event.event_id} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 182 | <div class="actions" role="toolbar" aria-label={`Actions for message from ${displayName}`}> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 183 | {#each quickReactions as r (r.key)} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 184 | {@const label = r.shortcode ? `:${r.shortcode}:` : r.key} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 185 | <button |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 186 | type="button" |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 187 | title={`React ${label}`} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 188 | aria-label={`React ${label} to message from ${displayName}`} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 189 | disabled={reacting} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 190 | on:click={() => onReact(event.event_id ?? '', r.key)} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 191 | > |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 192 | {#if r.key.startsWith('mxc://')} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 193 | <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 194 | {:else} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 195 | <Emoji emoji={r.key} size={18} /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 196 | {/if} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 197 | </button> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 198 | {/each} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 199 | <button |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 200 | type="button" |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 201 | title="Add reaction" |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 202 | aria-label={`Add reaction to message from ${displayName}`} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 203 | aria-haspopup="dialog" |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 204 | aria-expanded={pickerOpen} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 205 | on:pointerdown|stopPropagation |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 206 | on:click={openPicker} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 207 | > |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 208 | ☺+ |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 209 | </button> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 210 | </div> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 211 | {#if pickerOpen} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 212 | <div class="picker-pop" style={pickerStyle} bind:this={pickerPop}> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 213 | <ReactionPicker {packs} quick={quickReactions} onPick={(key) => pick(key)} {onQuickChange} onClose={closePicker} /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 214 | </div> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 215 | {/if} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 216 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 217 | {#if showSender} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 218 | {#if senderAvatar} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 219 | <MxcAvatar mxc={senderAvatar} label={name} size={34} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 220 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 221 | <div |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 222 | class="avatar" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 223 | aria-hidden="true" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 224 | style={`background:hsl(${senderHue(event.sender.user_id)} 35% 32%)`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 225 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 226 | {initialsOf(name)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 227 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 228 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 229 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 230 | <div class="avatar-spacer" aria-hidden="true"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 231 | <span class="hover-time">{formatClock(event.timestamp_ms)}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 232 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 233 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 234 | <div class="msg-body"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 235 | {#if showSender} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 236 | <div class="msg-head"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 237 | <span class="sender" style={`color:hsl(${senderHue(event.sender.user_id)} 70% 72%)`}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 238 | {displayName} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 239 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 240 | <time class="time" datetime={new Date(event.timestamp_ms).toISOString()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 241 | {formatDay(event.timestamp_ms)} {formatClock(event.timestamp_ms)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 242 | </time> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 243 | {#if event.content.kind === 'Message' && event.content.message.edited} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 244 | <span class="edited" title="Edited">(edited)</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 245 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 246 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 247 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 248 | {#if event.reply_to} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 249 | <div class="reply-quote"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 250 | {#if event.reply_to.details.kind === 'Ready'} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 251 | Replying to {senderLabel(event.reply_to.details.sender)}: <EmojiText text={replyPreview(event.reply_to.details.content)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 252 | {:else if event.reply_to.details.kind === 'Pending'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 253 | Loading reply… |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 254 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 255 | Reply unavailable |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 256 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 257 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 258 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 259 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 260 | {#if event.content.kind === 'Message'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 261 | {@const m = event.content.message} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 262 | <p class="text" class:emote={m.kind === 'Emote'} class:notice={m.kind === 'Notice' || m.kind === 'ServerNotice'}> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 263 | {#if m.kind === 'Emote'}* {displayName} {/if}<EmojiText text={m.body} jumbo={m.kind === 'Text'} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 264 | </p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 265 | {#if m.media} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 266 | <MediaAttachmentView attachment={m.media} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 267 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 268 | {#if previews.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 269 | <div class="link-previews"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 270 | {#each previews as preview (preview.href)} |
b8ab00377c20 | atagen | 2026-10-22 05:13 UTC | 271 | <LinkCard link={preview} preview={linkPreviews[preview.href] ?? null} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 272 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 273 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 274 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 275 | {:else if event.content.kind === 'Sticker'} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 276 | {#if event.content.body}<p class="text"><EmojiText text={event.content.body} /></p>{/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 277 | {#if event.content.media} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 278 | <MediaAttachmentView attachment={event.content.media} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 279 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 280 | {:else if event.content.kind === 'Poll'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 281 | <p class="text">📊 {event.content.question}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 282 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 283 | <p class="system-line">{systemLine(event.content)}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 284 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 285 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 286 | {#if interactive && event.reactions.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 287 | <div class="reactions" aria-label="Reactions"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 288 | {#each event.reactions as r (r.key)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 289 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 290 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 291 | class="reaction" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 292 | class:mine={r.own} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 293 | title={r.own ? 'You reacted — activate to remove' : `${r.count} reaction${r.count === 1 ? '' : 's'}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 294 | disabled={!event.event_id || reacting} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 295 | on:click={() => event.event_id && onReact(event.event_id, r.key)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 296 | > |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 297 | {#if r.key.startsWith('mxc://')} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 298 | <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 299 | {:else} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 300 | <Emoji emoji={r.key} size={16} /> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 301 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 302 | <span class="count">{r.count}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 303 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 304 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 305 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 306 | {/if} |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 307 | {#if interactive && (sendLabel(event.send_state) || event.read_by.length > 0)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 308 | <div class="msg-foot"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 309 | {#if sendLabel(event.send_state)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 310 | <span class="sendstate" class:failed={event.send_state.kind === 'Failed'}>{sendLabel(event.send_state)}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 311 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 312 | {#if event.read_by.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 313 | <span class="readby" title={event.read_by.join(', ')}>✓✓ {event.read_by.length}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 314 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 315 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 316 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 317 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 318 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 319 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 320 | <style> |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 321 | .msg { position: relative; display: flex; gap: 10px; padding: 3px 0; } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 322 | .msg:hover, .msg.selected { background: rgba(255, 255, 255, 0.018); } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 323 | .msg:hover .hover-time, .msg.selected .hover-time { opacity: 1; } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 324 | .msg-foot { display: flex; align-items: center; gap: 8px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 325 | .sendstate { font-size: 11px; color: var(--muted); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 326 | .sendstate.failed { color: var(--danger); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 327 | .link-previews { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 328 | .avatar { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 329 | flex: none; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 330 | width: 34px; height: 34px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 331 | border-radius: 50%; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 332 | display: grid; place-items: center; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 333 | font-size: 12px; font-weight: 700; color: #fff; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 334 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 335 | .avatar-spacer { flex: none; width: 34px; padding-top: 2px; text-align: center; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 336 | .hover-time { opacity: 0; font-size: 10.5px; color: var(--muted); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 337 | .msg-body { min-width: 0; flex: 1; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 338 | .msg-head { display: flex; align-items: baseline; gap: 8px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 339 | .sender { font-weight: 650; font-size: 13.5px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 340 | .time, .edited { color: var(--muted); font-size: 11.5px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 341 | .reply-quote { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 342 | border-left: 2px solid var(--accent); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 343 | padding: 2px 8px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 344 | margin: 2px 0 4px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 345 | color: var(--muted); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 346 | font-size: 12.5px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 347 | background: var(--bg-soft); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 348 | border-radius: 0 6px 6px 0; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 349 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 350 | .text { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 351 | margin: 1px 0 2px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 352 | font-size: 14px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 353 | line-height: 1.5; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 354 | white-space: pre-wrap; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 355 | overflow-wrap: anywhere; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 356 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 357 | .text.emote { font-style: italic; color: var(--muted); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 358 | .text.notice { color: var(--muted); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 359 | .system-line { color: var(--muted); font-size: 12.5px; font-style: italic; margin: 1px 0; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 360 | .msg.system { opacity: 0.85; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 361 | .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 362 | .reaction { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 363 | display: inline-flex; align-items: center; gap: 4px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 364 | background: var(--bg-soft); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 365 | border: 1px solid var(--border); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 366 | border-radius: 999px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 367 | padding: 1px 8px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 368 | font-size: 13px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 369 | color: var(--text); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 370 | cursor: pointer; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 371 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 372 | .reaction.mine { border-color: var(--accent); background: rgba(88, 101, 242, 0.16); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 373 | .reaction:disabled { cursor: default; opacity: 0.85; } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 374 | .readby { font-size: 11px; color: var(--muted); } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 375 | .actions { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 376 | position: absolute; top: -14px; right: 12px; z-index: 2; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 377 | display: flex; gap: 2px; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 378 | padding: 2px; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 379 | background: var(--bg-soft); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 380 | border: 1px solid var(--border); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 381 | border-radius: 8px; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 382 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 383 | opacity: 0; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 384 | pointer-events: none; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 385 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 386 | .msg:hover .actions, .msg:focus-within .actions, .msg.selected .actions { opacity: 1; pointer-events: auto; } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 387 | .actions button { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 388 | background: transparent; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 389 | border: 1px solid transparent; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 390 | border-radius: 6px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 391 | cursor: pointer; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 392 | font-size: 14px; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 393 | padding: 1px 5px; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 394 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 395 | .actions button:hover:not(:disabled) { border-color: var(--border); background: rgba(255, 255, 255, 0.06); } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 396 | .actions button:disabled { opacity: 0.4; cursor: default; } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 397 | .emote { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: middle; } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 398 | .picker-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 399 | </style> |