973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1 | <script lang="ts"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2 | import { onMount, tick } from 'svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 3 | import LoginPanel from './lib/LoginPanel.svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 4 | import MessageRow from './lib/MessageRow.svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 5 | import MxcAvatar from './lib/MxcAvatar.svelte'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 6 | import ImageLightbox from './lib/ImageLightbox.svelte'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 7 | import { lightbox } from './lib/lightbox'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 8 | import SecurityPanel from './lib/SecurityPanel.svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 9 | import { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 10 | closeRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 11 | createRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 12 | getEncryption, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 13 | getMembers, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 14 | getProfile, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 15 | getRooms, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 16 | getSession, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 17 | getSpaceChildren, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 18 | joinRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 19 | leaveRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 20 | logout, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 21 | markRead, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 22 | openRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 23 | paginateRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 24 | reactToMessage, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 25 | uploadAttachment, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 26 | editMessage |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 27 | } from './lib/api'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 28 | import { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 29 | banners, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 30 | blocked, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 31 | connectEvents, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 32 | connection, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 33 | disconnectEvents, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 34 | dismissBanner, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 35 | encryption, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 36 | membersByRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 37 | membersLoading, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 38 | pushBanner, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 39 | imagePacks, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 40 | resetClientState, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 41 | rooms, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 42 | selectedRoomId, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 43 | sessionUser, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 44 | softLogout, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 45 | timelines, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 46 | verification |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 47 | } from './lib/store'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 48 | import { discardPending, pendingByRoom, queueSend, resetPending, retryPending } from './lib/pending'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 49 | import type { PendingMessage } from './lib/pending'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 50 | import { mentionQueryAt, mentionsFromHtml, rankPeople, resolveMentions } from './lib/mentions'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 51 | import type { Mention, MentionQuery } from './lib/mentions'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 52 | import { loadQuickReactions, quickReactions, saveQuickReactions } from './lib/quick-reactions'; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 53 | import { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 54 | linkPreviews, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 55 | loadUrlPreviewSettings, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 56 | requestLinkPreview, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 57 | saveUrlPreviewSettings, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 58 | urlPreviewSettings |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 59 | } from './lib/link-previews'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 60 | import { notifyTyping, stopTyping } from './lib/typing'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 61 | import { formatDay } from './lib/format'; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 62 | import { lastSpaceRooms, lineHeight, messageSpacing, navFolded } from './lib/appearance'; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 63 | import SettingsPanel from './lib/SettingsPanel.svelte'; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 64 | import { packsForRoom, parseEncryptionState, parseOwnProfile, parseVerificationState, contentPreview, senderLabel } from './lib/types'; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 65 | import type { MemberSummary, OwnProfile, Person, QuickReaction, ReplyReference, RoomSummary, SendState, TimelineEvent, TimelineItem } from './lib/types'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 66 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 67 | let roomsLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 68 | let booted = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 69 | let wasOnline = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 70 | let search = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 71 | let sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 72 | let membersOpen = false; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 73 | let replyingTo: ReplyReference | null = null; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 74 | let dialog: 'join' | 'create' | 'security' | 'settings' | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 75 | let joinTarget = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 76 | let joinBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 77 | let createName = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 78 | let createTopic = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 79 | let createBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 80 | let leaveBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 81 | let paginateBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 82 | let reacting = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 83 | let composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 84 | let drafts: Record<string, string> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 85 | let stickToBottom = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 86 | let timelineEl: HTMLElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 87 | let composerEl: HTMLTextAreaElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 88 | let fileInput: HTMLInputElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 89 | let uploadBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 90 | let uploadName: string | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 91 | interface StagedAttachment { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 92 | id: number; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 93 | file: File; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 94 | previewUrl: string | null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 95 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 96 | let staged: Record<string, StagedAttachment[]> = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 97 | let editing: { roomId: string; eventId: string; original: string; stash: string } | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 98 | /** Everyone picked from the finder per room; only those whose name is still in the text get linked on send. */ |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 99 | let pickedMentions: Record<string, Mention[]> = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 100 | let mentionQuery: MentionQuery | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 101 | let mentionIndex = 0; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 102 | let nextStagedId = 1; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 103 | const WARM_ROOM_LIMIT = 8; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 104 | /** Rooms left open after switching away so coming back is instant, least recently viewed first. */ |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 105 | let warmRooms: string[] = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 106 | let openReady: Record<string, boolean> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 107 | let openFailed: Record<string, string> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 108 | let membersFor: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 109 | let lastReadKey = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 110 | let readTimer: number | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 111 | let profile: OwnProfile | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 112 | let profileMxc: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 113 | let selectedSpaceId: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 114 | let spaceChildIds: string[] | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 115 | let spaceChildrenLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 116 | let spaceChildrenError: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 117 | let avatarByUser: Record<string, string | null> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 118 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 119 | // account data is read from the local cache, which is empty on a fresh device until the first sync lands |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 120 | $: { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 121 | const online = $connection === 'online'; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 122 | if (online && !wasOnline) { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 123 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 124 | void loadUrlPreviewSettings(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 125 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 126 | wasOnline = online; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 127 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 128 | $: selectedRoom = $rooms.find((r) => r.room_id === $selectedRoomId) ?? null; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 129 | $: roomPacks = packsForRoom($imagePacks, $selectedRoomId); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 130 | $: previewsAllowed = selectedRoom !== null && (!selectedRoom.encrypted || $urlPreviewSettings.encrypted_rooms); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 131 | $: loadPreview = previewsAllowed && $selectedRoomId ? previewLoader($selectedRoomId) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 132 | $: spaceRooms = $rooms.filter((r) => r.space); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 133 | $: spaceParents = parentSpaceMap(spaceRooms); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 134 | $: railSpaces = spaceRooms.filter((s) => !spaceParents.has(s.room_id)); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 135 | $: railSelected = selectedSpaceId ? topSpaceOf(selectedSpaceId, spaceParents) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 136 | $: invites = $rooms.filter((r) => r.membership === 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 137 | $: query = search.trim().toLowerCase(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 138 | $: selectedSpace = selectedSpaceId ? ($rooms.find((r) => r.room_id === selectedSpaceId) ?? null) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 139 | // While a space's children load (or fail), show no channels rather than the |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 140 | // full list — listing everything would falsely imply it belongs to the space. |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 141 | $: baseRooms = selectedSpaceId ? (spaceChildIds ? $rooms.filter((r) => spaceChildIds?.includes(r.room_id)) : []) : $rooms; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 142 | $: visibleRooms = query |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 143 | ? baseRooms.filter( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 144 | (r) => |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 145 | r.name.toLowerCase().includes(query) || r.room_id.toLowerCase().includes(query) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 146 | ) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 147 | : baseRooms; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 148 | $: directRooms = visibleRooms.filter((r) => r.direct && !r.space && r.membership !== 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 149 | $: groupRooms = visibleRooms.filter( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 150 | (r) => !r.direct && !r.space && r.membership !== 'Invited' |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 151 | ); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 152 | $: spaceList = visibleRooms.filter((r) => r.space && r.membership !== 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 153 | $: channelRooms = baseRooms.filter((r) => !r.space && r.membership !== 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 154 | $: recoveryBanner = $encryption && ($encryption.recovery === 'Disabled' || $encryption.recovery === 'Incomplete') ? $encryption : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 155 | $: verificationBanner = $verification && $verification.kind !== 'Done' ? $verification : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 156 | $: items = $selectedRoomId ? ($timelines[$selectedRoomId] ?? []) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 157 | $: currentStaged = $selectedRoomId ? (staged[$selectedRoomId] ?? []) : []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 158 | $: members = $selectedRoomId ? ($membersByRoom[$selectedRoomId] ?? []) : []; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 159 | $: people = peopleIn(items, members); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 160 | $: mentionCandidates = mentionQuery ? rankPeople(Object.values(people), mentionQuery.query, $sessionUser ?? null) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 161 | $: if (mentionIndex >= mentionCandidates.length) mentionIndex = 0; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 162 | $: hasStart = items.some((i) => i.kind === 'start'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 163 | $: grouped = buildGroups(items); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 164 | $: lastSentId = lastOwnSent(items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 165 | $: pendingItems = $selectedRoomId ? ($pendingByRoom[$selectedRoomId] ?? []) : []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 166 | $: lastRealOwn = lastSenderIsOwn(items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 167 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 168 | function lastSenderIsOwn(list: TimelineItem[]): boolean { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 169 | for (let i = list.length - 1; i >= 0; i -= 1) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 170 | const it = list[i]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 171 | if (it.kind === 'event') return it.event.sender.user_id === $sessionUser; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 172 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 173 | return false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 174 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 175 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 176 | function pendingShowSender(index: number): boolean { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 177 | return index === 0 ? !lastRealOwn : false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 178 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 179 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 180 | function pendingToEvent(p: PendingMessage): TimelineEvent { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 181 | const state: SendState = p.status === 'failed' ? { kind: 'Failed', will_retry: false } : { kind: 'Sending' }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 182 | return { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 183 | item_id: `pending-${p.id}`, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 184 | event_id: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 185 | transaction_id: p.id, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 186 | sender: { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 187 | user_id: $sessionUser ?? '', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 188 | display_name: profile?.display_name ?? null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 189 | avatar: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 190 | name_ambiguous: false |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 191 | }, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 192 | timestamp_ms: p.createdAt, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 193 | own: true, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 194 | send_state: state, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 195 | content: { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 196 | kind: 'Message', |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 197 | message: { kind: 'Text', body: p.body, geo_uri: null, formatted_body: null, edited: false, media: null, link_previews: [] } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 198 | }, |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 199 | reply_to: p.replyTo, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 200 | thread_root: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 201 | thread_summary: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 202 | reactions: [], |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 203 | read_by: [], |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 204 | editable: false |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 205 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 206 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 207 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 208 | interface Group { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 209 | key: string; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 210 | item: TimelineItem; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 211 | showSender: boolean; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 212 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 213 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 214 | function lastOwnSent(list: TimelineItem[]): string | null { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 215 | for (let i = list.length - 1; i >= 0; i--) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 216 | const item = list[i]; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 217 | if (item.kind === 'event' && item.event.own && item.event.send_state.kind === 'Sent') return item.event.item_id; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 218 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 219 | return null; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 220 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 221 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 222 | function buildGroups(list: TimelineItem[]): Group[] { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 223 | const out: Group[] = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 224 | let prevSender: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 225 | let prevTs = 0; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 226 | list.forEach((item, index) => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 227 | let showSender = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 228 | if (item.kind === 'event') { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 229 | const e = item.event; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 230 | showSender = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 231 | prevSender !== e.sender.user_id || Math.abs(e.timestamp_ms - prevTs) > 5 * 60 * 1000; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 232 | prevSender = e.sender.user_id; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 233 | prevTs = e.timestamp_ms; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 234 | out.push({ key: e.item_id || e.event_id || `m-${index}`, item, showSender }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 235 | } else { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 236 | prevSender = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 237 | out.push({ key: `${item.kind}-${index}`, item, showSender }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 238 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 239 | }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 240 | return out; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 241 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 242 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 243 | function roomUnread(r: RoomSummary): number { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 244 | return r.unread_messages + r.unread_mentions; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 245 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 246 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 247 | onMount(() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 248 | void boot(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 249 | return () => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 250 | disconnectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 251 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 252 | if (readTimer !== null) window.clearTimeout(readTimer); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 253 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 254 | }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 255 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 256 | async function boot(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 257 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 258 | const session = await getSession(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 259 | blocked.set(session.blocked ?? false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 260 | sessionUser.set(session.user_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 261 | if (session.user_id) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 262 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 263 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 264 | connectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 265 | void loadProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 266 | void loadEncryption(); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 267 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 268 | void loadUrlPreviewSettings(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 269 | } else { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 270 | softLogout.set(session.soft_logout ?? null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 271 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 272 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 273 | pushBanner(e instanceof Error ? `Session check failed: ${e.message}` : 'Session check failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 274 | sessionUser.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 275 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 276 | booted = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 277 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 278 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 279 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 280 | async function refreshRooms(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 281 | roomsLoading = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 282 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 283 | const res = await getRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 284 | rooms.set(res.rooms); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 285 | pruneSpaceFilter(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 286 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 287 | pushBanner(e instanceof Error ? e.message : 'Could not load rooms'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 288 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 289 | roomsLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 290 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 291 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 292 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 293 | async function loadProfile(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 294 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 295 | const raw = await getProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 296 | profile = parseOwnProfile(raw); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 297 | profileMxc = profile.avatar_url; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 298 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 299 | profile = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 300 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 301 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 302 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 303 | async function loadEncryption(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 304 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 305 | const res = await getEncryption(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 306 | const state = parseEncryptionState(res.state); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 307 | if (state) encryption.set(state); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 308 | const verificationState = parseVerificationState(res.verification); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 309 | if (verificationState) verification.set(verificationState); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 310 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 311 | // Encryption status also arrives over SSE; a failed first fetch is not fatal. |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 312 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 313 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 314 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 315 | function afterLogin(userId: string): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 316 | sessionUser.set(userId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 317 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 318 | blocked.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 319 | void refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 320 | connectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 321 | void loadProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 322 | void loadEncryption(); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 323 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 324 | void loadUrlPreviewSettings(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 325 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 326 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 327 | async function doLogout(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 328 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 329 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 330 | await logout(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 331 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 332 | pushBanner(e instanceof Error ? e.message : 'Logout failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 333 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 334 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 335 | disconnectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 336 | resetClientState(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 337 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 338 | blocked.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 339 | sessionUser.set(null); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 340 | lightbox.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 341 | composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 342 | drafts = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 343 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 344 | membersOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 345 | sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 346 | profile = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 347 | profileMxc = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 348 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 349 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 350 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 351 | openReady = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 352 | openFailed = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 353 | warmRooms = []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 354 | pickedMentions = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 355 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 356 | clearAllStaged(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 357 | avatarByUser = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 358 | resetPending(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 359 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 360 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 361 | /** Joined spaces that sit inside another joined space, keyed to one such parent. Either side of the link counts. */ |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 362 | function parentSpaceMap(spaces: RoomSummary[]): Map<string, string> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 363 | const ids = new Set(spaces.map((s) => s.room_id)); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 364 | const parents = new Map<string, string>(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 365 | for (const space of spaces) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 366 | for (const child of space.children) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 367 | if (child !== space.room_id && ids.has(child) && !parents.has(child)) parents.set(child, space.room_id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 368 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 369 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 370 | for (const space of spaces) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 371 | const parent = space.parent_spaces.find((id) => id !== space.room_id && ids.has(id)); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 372 | if (parent && !parents.has(space.room_id)) parents.set(space.room_id, parent); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 373 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 374 | for (const id of [...parents.keys()]) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 375 | const seen = new Set<string>([id]); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 376 | let at = parents.get(id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 377 | while (at && !seen.has(at)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 378 | seen.add(at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 379 | at = parents.get(at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 380 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 381 | if (at) parents.delete(id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 382 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 383 | return parents; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 384 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 385 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 386 | function topSpaceOf(id: string, parents: Map<string, string>): string { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 387 | let at = id; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 388 | while (parents.has(at)) at = parents.get(at)!; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 389 | return at; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 390 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 391 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 392 | function pruneSpaceFilter(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 393 | if (!selectedSpaceId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 394 | if (!$rooms.some((r) => r.room_id === selectedSpaceId)) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 395 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 396 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 397 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 398 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 399 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 400 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 401 | async function selectHome(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 402 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 403 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 404 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 405 | sidebarOpen = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 406 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 407 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 408 | async function selectSpace(spaceId: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 409 | if ($selectedRoomId && composer.trim()) drafts[$selectedRoomId] = composer; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 410 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 411 | selectedSpaceId = spaceId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 412 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 413 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 414 | spaceChildrenLoading = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 415 | sidebarOpen = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 416 | // A space is navigation, not a message timeline. |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 417 | selectedRoomId.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 418 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 419 | const res = await getSpaceChildren(spaceId); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 420 | if (selectedSpaceId === spaceId) { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 421 | spaceChildIds = res.room_ids ?? []; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 422 | const last = $lastSpaceRooms[spaceId]; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 423 | if (last && spaceChildIds.includes(last) && $rooms.some((r) => r.room_id === last && !r.space)) { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 424 | void selectRoom(last); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 425 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 426 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 427 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 428 | if (selectedSpaceId === spaceId) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 429 | spaceChildrenError = e instanceof Error ? e.message : 'Could not load rooms in this space'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 430 | spaceChildIds = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 431 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 432 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 433 | if (selectedSpaceId === spaceId) spaceChildrenLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 434 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 435 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 436 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 437 | async function selectRoom(roomId: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 438 | if ($selectedRoomId && composer.trim()) drafts[$selectedRoomId] = composer; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 439 | if (roomId === $selectedRoomId && openReady[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 440 | sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 441 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 442 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 443 | stopTyping(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 444 | const spaceId = selectedSpaceId; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 445 | if (spaceId) lastSpaceRooms.update((all) => ({ ...all, [spaceId]: roomId })); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 446 | selectedRoomId.set(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 447 | composer = drafts[roomId] ?? ''; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 448 | replyingTo = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 449 | editing = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 450 | mentionQuery = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 451 | stickToBottom = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 452 | lastReadKey = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 453 | sidebarOpen = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 454 | touchWarmRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 455 | if (openReady[roomId]) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 456 | if (membersOpen) void loadMembers(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 457 | await tick(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 458 | scrollToBottom(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 459 | queueReadReceipt(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 460 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 461 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 462 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 463 | if (openFailed[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 464 | const nextFailed = { ...openFailed }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 465 | delete nextFailed[roomId]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 466 | openFailed = nextFailed; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 467 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 468 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 469 | await openRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 470 | if (warmRooms.includes(roomId)) openReady = { ...openReady, [roomId]: true }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 471 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 472 | const message = e instanceof Error ? e.message : `Could not open room ${roomId}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 473 | openFailed = { ...openFailed, [roomId]: message }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 474 | pushBanner(message); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 475 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 476 | if (membersOpen) void loadMembers(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 477 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 478 | scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 479 | queueReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 480 | composerEl?.focus(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 481 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 482 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 483 | function touchWarmRoom(roomId: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 484 | warmRooms = [...warmRooms.filter((id) => id !== roomId), roomId]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 485 | while (warmRooms.length > WARM_ROOM_LIMIT) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 486 | const evicted = warmRooms[0]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 487 | warmRooms = warmRooms.slice(1); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 488 | forgetOpenRoom(evicted); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 489 | closeRoom(evicted).catch(() => undefined); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 490 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 491 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 492 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 493 | function forgetOpenRoom(roomId: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 494 | warmRooms = warmRooms.filter((id) => id !== roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 495 | const nextReady = { ...openReady }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 496 | delete nextReady[roomId]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 497 | openReady = nextReady; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 498 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 499 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 500 | function scrollToBottom(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 501 | if (timelineEl) timelineEl.scrollTop = timelineEl.scrollHeight; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 502 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 503 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 504 | let userScrollUntil = 0; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 505 | let draggingScrollbar = false; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 506 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 507 | function noteUserScroll(): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 508 | userScrollUntil = performance.now() + 300; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 509 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 510 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 511 | function onTimelineKey(e: KeyboardEvent): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 512 | if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(e.key)) noteUserScroll(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 513 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 514 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 515 | function onTimelinePointer(e: PointerEvent): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 516 | if (e.target === timelineEl) draggingScrollbar = true; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 517 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 518 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 519 | function onTimelineScroll(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 520 | if (!timelineEl) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 521 | const gap = timelineEl.scrollHeight - timelineEl.scrollTop - timelineEl.clientHeight; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 522 | if (gap < 80) stickToBottom = true; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 523 | else if (draggingScrollbar || performance.now() < userScrollUntil) stickToBottom = false; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 524 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 525 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 526 | function pinTimeline(node: HTMLElement) { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 527 | const observer = new ResizeObserver(() => { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 528 | if (stickToBottom) scrollToBottom(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 529 | }); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 530 | observer.observe(node); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 531 | if (node.parentElement) observer.observe(node.parentElement); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 532 | return { destroy: () => observer.disconnect() }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 533 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 534 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 535 | $: void trackTimeline($selectedRoomId, items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 536 | async function trackTimeline(roomId: string | null, list: TimelineItem[]): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 537 | if (!roomId || list.length === 0) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 538 | if (roomId !== $selectedRoomId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 539 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 540 | if (stickToBottom) scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 541 | queueReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 542 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 543 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 544 | function queueReadReceipt(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 545 | if (readTimer !== null) window.clearTimeout(readTimer); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 546 | readTimer = window.setTimeout(() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 547 | readTimer = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 548 | void sendReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 549 | }, 800); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 550 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 551 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 552 | async function sendReadReceipt(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 553 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 554 | if (!roomId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 555 | const list = $timelines[roomId] ?? []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 556 | for (let i = list.length - 1; i >= 0; i -= 1) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 557 | const entry = list[i]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 558 | if (entry.kind === 'event' && entry.event.event_id) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 559 | const key = `${roomId}:${entry.event.event_id}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 560 | if (key === lastReadKey) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 561 | lastReadKey = key; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 562 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 563 | await markRead(roomId, entry.event.event_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 564 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 565 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 566 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 567 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 568 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 569 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 570 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 571 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 572 | function send(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 573 | if (editing) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 574 | submitEdit(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 575 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 576 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 577 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 578 | const body = composer.trim(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 579 | const attachments = roomId ? (staged[roomId] ?? []) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 580 | if (!roomId || (!body && attachments.length === 0)) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 581 | if (!openReady[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 582 | pushBanner('Still opening this room — sending is disabled until the room is ready.'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 583 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 584 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 585 | if (attachments.length > 0 && uploadBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 586 | composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 587 | if (roomId in drafts) delete drafts[roomId]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 588 | stickToBottom = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 589 | const reply = replyingTo; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 590 | replyingTo = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 591 | const mentions = resolveMentions(body, pickedMentions[roomId] ?? []); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 592 | pickedMentions = { ...pickedMentions, [roomId]: [] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 593 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 594 | if (attachments.length === 0) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 595 | queueSend(roomId, body, reply, mentions); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 596 | } else { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 597 | const { [roomId]: _sent, ...rest } = staged; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 598 | staged = rest; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 599 | void sendAttachments(roomId, body, reply, mentions, attachments); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 600 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 601 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 602 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 603 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 604 | async function sendAttachments( |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 605 | roomId: string, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 606 | body: string, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 607 | reply: ReplyReference | null, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 608 | mentions: Mention[], |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 609 | attachments: StagedAttachment[] |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 610 | ): Promise<void> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 611 | let first = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 612 | uploadBusy = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 613 | try { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 614 | for (const attachment of attachments) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 615 | uploadName = attachment.file.name || 'attachment'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 616 | try { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 617 | if (first) await uploadAttachment(roomId, attachment.file, body || null, reply?.event_id ?? null, mentions); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 618 | else await uploadAttachment(roomId, attachment.file); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 619 | first = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 620 | } catch (e) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 621 | pushBanner(e instanceof Error ? e.message : 'Upload failed'); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 622 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 623 | if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 624 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 625 | } finally { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 626 | uploadBusy = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 627 | uploadName = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 628 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 629 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 630 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 631 | function stageFiles(files: File[]): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 632 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 633 | if (!roomId || !openReady[roomId]) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 634 | const accepted: StagedAttachment[] = []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 635 | for (const file of files) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 636 | if (file.size === 0 || file.size > 20 * 1024 * 1024) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 637 | pushBanner(`${file.name || 'File'} must be between 1 byte and 20 MiB.`); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 638 | continue; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 639 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 640 | const previewUrl = file.type.startsWith('image/') ? URL.createObjectURL(file) : null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 641 | accepted.push({ id: nextStagedId++, file, previewUrl }); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 642 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 643 | if (accepted.length === 0) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 644 | staged = { ...staged, [roomId]: [...(staged[roomId] ?? []), ...accepted] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 645 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 646 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 647 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 648 | function unstage(roomId: string, id: number): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 649 | const list = staged[roomId] ?? []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 650 | const removed = list.find((a) => a.id === id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 651 | if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 652 | staged = { ...staged, [roomId]: list.filter((a) => a.id !== id) }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 653 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 654 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 655 | function clearAllStaged(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 656 | for (const list of Object.values(staged)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 657 | for (const attachment of list) if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 658 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 659 | staged = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 660 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 661 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 662 | function startEdit(eventId: string, body: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 663 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 664 | if (!roomId) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 665 | const stash = editing ? editing.stash : composer; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 666 | editing = { roomId, eventId, original: body, stash }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 667 | const entry = items.find((i) => i.kind === 'event' && i.event.event_id === eventId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 668 | if (entry?.kind === 'event' && entry.event.content.kind === 'Message') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 669 | const existing = mentionsFromHtml(entry.event.content.message.formatted_body); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 670 | pickedMentions = { ...pickedMentions, [roomId]: [...(pickedMentions[roomId] ?? []), ...existing] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 671 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 672 | composer = body; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 673 | replyingTo = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 674 | composerEl?.focus(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 675 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 676 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 677 | function cancelEdit(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 678 | if (!editing) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 679 | composer = editing.stash; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 680 | editing = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 681 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 682 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 683 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 684 | function submitEdit(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 685 | if (!editing) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 686 | const { roomId, eventId, original } = editing; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 687 | const body = composer.trim(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 688 | cancelEdit(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 689 | if (!body || body === original.trim()) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 690 | editMessage(roomId, eventId, body, resolveMentions(body, pickedMentions[roomId] ?? [])).catch((e) => pushBanner(e instanceof Error ? e.message : 'Edit failed')); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 691 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 692 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 693 | function editLastOwn(): boolean { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 694 | for (let i = items.length - 1; i >= 0; i -= 1) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 695 | const entry = items[i]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 696 | if (entry.kind !== 'event' || !entry.event.own) continue; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 697 | const ev = entry.event; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 698 | if (!ev.editable || !ev.event_id || ev.content.kind !== 'Message' || ev.content.message.kind !== 'Text') return false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 699 | startEdit(ev.event_id, ev.content.message.body); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 700 | return true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 701 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 702 | return false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 703 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 704 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 705 | function startReply(target: ReplyReference): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 706 | if (editing) cancelEdit(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 707 | replyingTo = target; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 708 | composerEl?.focus(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 709 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 710 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 711 | function jumpTo(eventId: string): void { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 712 | const el = timelineEl?.querySelector<HTMLElement>(`[data-event="${CSS.escape(eventId)}"]`); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 713 | if (!el) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 714 | pushBanner('The original message is not loaded. Scroll up to load older messages.'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 715 | return; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 716 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 717 | stickToBottom = false; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 718 | el.scrollIntoView({ block: 'center', behavior: 'smooth' }); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 719 | el.classList.remove('flash'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 720 | void el.offsetWidth; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 721 | el.classList.add('flash'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 722 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 723 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 724 | let typedText = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 725 | let typedRoom: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 726 | $: trackTypingInput(composer, $selectedRoomId, openReady); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 727 | function trackTypingInput(text: string, roomId: string | null, ready: Record<string, boolean>): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 728 | const edited = roomId === typedRoom && text !== typedText; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 729 | typedText = text; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 730 | typedRoom = roomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 731 | if (!roomId || !ready[roomId] || !text.trim()) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 732 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 733 | } else if (edited) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 734 | notifyTyping(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 735 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 736 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 737 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 738 | $: void trackPending($selectedRoomId, pendingItems); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 739 | async function trackPending(roomId: string | null, list: PendingMessage[]): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 740 | if (!roomId || list.length === 0) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 741 | if (roomId !== $selectedRoomId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 742 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 743 | if (stickToBottom) scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 744 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 745 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 746 | function updateMentionQuery(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 747 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 748 | const next = composerEl && roomId ? mentionQueryAt(composerEl.value, composerEl.selectionStart ?? composerEl.value.length) : null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 749 | if (next && !mentionQuery && roomId && !$membersByRoom[roomId]) void loadMembers(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 750 | if (next?.start !== mentionQuery?.start) mentionIndex = 0; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 751 | mentionQuery = next; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 752 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 753 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 754 | async function pickMention(person: Person): Promise<void> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 755 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 756 | if (!mentionQuery || !roomId || !composerEl) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 757 | const caret = composerEl.selectionStart ?? composer.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 758 | const inserted = `${person.name} `; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 759 | composer = composer.slice(0, mentionQuery.start) + inserted + composer.slice(caret); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 760 | const at = mentionQuery.start + inserted.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 761 | pickedMentions = { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 762 | ...pickedMentions, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 763 | [roomId]: [...(pickedMentions[roomId] ?? []), { user_id: person.user_id, text: person.name }] |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 764 | }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 765 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 766 | await tick(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 767 | composerEl.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 768 | composerEl.setSelectionRange(at, at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 769 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 770 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 771 | function onComposerKey(ev: KeyboardEvent): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 772 | if (mentionQuery && mentionCandidates.length > 0) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 773 | if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 774 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 775 | const step = ev.key === 'ArrowDown' ? 1 : -1; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 776 | mentionIndex = (mentionIndex + step + mentionCandidates.length) % mentionCandidates.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 777 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 778 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 779 | if ((ev.key === 'Enter' && !ev.shiftKey) || ev.key === 'Tab') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 780 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 781 | void pickMention(mentionCandidates[mentionIndex]); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 782 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 783 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 784 | if (ev.key === 'Escape') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 785 | ev.stopPropagation(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 786 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 787 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 788 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 789 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 790 | if (ev.key === 'Enter' && !ev.shiftKey) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 791 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 792 | send(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 793 | } else if (ev.key === 'Escape' && editing) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 794 | ev.stopPropagation(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 795 | cancelEdit(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 796 | } else if (ev.key === 'Escape' && replyingTo) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 797 | ev.stopPropagation(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 798 | replyingTo = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 799 | } else if (ev.key === 'ArrowUp' && !composer && !editing && editLastOwn()) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 800 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 801 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 802 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 803 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 804 | function pickFiles(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 805 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 806 | if (!roomId || !openReady[roomId]) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 807 | fileInput?.click(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 808 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 809 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 810 | function onFileChosen(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 811 | stageFiles(Array.from(fileInput?.files ?? [])); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 812 | if (fileInput) fileInput.value = ''; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 813 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 814 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 815 | function onComposerPaste(ev: ClipboardEvent): void { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 816 | const data = ev.clipboardData; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 817 | // Office apps put a rendered image next to the copied text, so only take the image when there is no plain text. |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 818 | if (!data || data.types.includes('text/plain')) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 819 | const images = Array.from(data.files).filter((f) => f.type.startsWith('image/')); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 820 | if (images.length === 0) return; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 821 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 822 | stageFiles(images); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 823 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 824 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 825 | async function react(eventId: string, key: string, shortcode?: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 826 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 827 | if (!roomId || !eventId || reacting) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 828 | reacting = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 829 | try { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 830 | await reactToMessage(roomId, eventId, key, shortcode); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 831 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 832 | pushBanner(e instanceof Error ? e.message : 'Reaction failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 833 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 834 | reacting = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 835 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 836 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 837 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 838 | function previewLoader(roomId: string): (url: string) => void { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 839 | return (url) => requestLinkPreview(roomId, url); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 840 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 841 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 842 | async function changeEncryptedPreviews(enabled: boolean): Promise<void> { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 843 | try { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 844 | await saveUrlPreviewSettings({ encrypted_rooms: enabled }); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 845 | } catch (e) { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 846 | pushBanner(e instanceof Error ? e.message : 'Could not save link preview setting'); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 847 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 848 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 849 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 850 | async function changeQuickReactions(list: QuickReaction[]): Promise<void> { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 851 | try { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 852 | await saveQuickReactions(list); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 853 | } catch (e) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 854 | pushBanner(e instanceof Error ? e.message : 'Could not save quick reactions'); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 855 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 856 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 857 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 858 | async function paginate(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 859 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 860 | if (!roomId || paginateBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 861 | paginateBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 862 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 863 | await paginateRoom(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 864 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 865 | pushBanner(e instanceof Error ? e.message : 'Loading older messages failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 866 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 867 | paginateBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 868 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 869 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 870 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 871 | async function loadMembers(roomId: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 872 | if (membersFor === roomId && $membersLoading) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 873 | membersFor = roomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 874 | membersLoading.set(true); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 875 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 876 | const res = await getMembers(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 877 | membersByRoom.update((all) => ({ ...all, [roomId]: res.members })); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 878 | avatarByUser = { ...avatarByUser, ...avatarMap(res.members) }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 879 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 880 | pushBanner(e instanceof Error ? e.message : 'Could not load members'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 881 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 882 | if (membersFor === roomId) membersLoading.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 883 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 884 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 885 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 886 | function avatarMap(list: MemberSummary[]): Record<string, string | null> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 887 | const next: Record<string, string | null> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 888 | for (const member of list) next[member.user_id] = member.avatar; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 889 | return next; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 890 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 891 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 892 | function peopleIn(list: TimelineItem[], roster: MemberSummary[]): Record<string, Person> { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 893 | const out: Record<string, Person> = {}; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 894 | for (const item of list) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 895 | if (item.kind !== 'event') continue; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 896 | const s = item.event.sender; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 897 | out[s.user_id] = { user_id: s.user_id, name: senderLabel(s), avatar: s.avatar }; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 898 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 899 | for (const m of roster) out[m.user_id] = { user_id: m.user_id, name: m.name, avatar: m.avatar }; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 900 | return out; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 901 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 902 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 903 | function senderAvatarFor(userId: string): string | null { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 904 | return avatarByUser[userId] ?? null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 905 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 906 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 907 | function toggleMembers(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 908 | membersOpen = !membersOpen; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 909 | if (membersOpen && $selectedRoomId) void loadMembers($selectedRoomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 910 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 911 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 912 | async function join(target: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 913 | const room = target.trim(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 914 | if (!room || joinBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 915 | joinBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 916 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 917 | const res = await joinRoom(room); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 918 | joinTarget = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 919 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 920 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 921 | await selectRoom(res.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 922 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 923 | pushBanner(e instanceof Error ? e.message : 'Join failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 924 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 925 | joinBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 926 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 927 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 928 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 929 | async function create(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 930 | const name = createName.trim(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 931 | if (!name || createBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 932 | createBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 933 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 934 | const res = await createRoom(name, createTopic.trim() || undefined); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 935 | createName = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 936 | createTopic = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 937 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 938 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 939 | await selectRoom(res.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 940 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 941 | pushBanner(e instanceof Error ? e.message : 'Create room failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 942 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 943 | createBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 944 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 945 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 946 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 947 | async function leave(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 948 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 949 | if (!roomId || leaveBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 950 | leaveBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 951 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 952 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 953 | await leaveRoom(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 954 | if ($selectedRoomId === roomId) selectedRoomId.set(null); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 955 | if (warmRooms.includes(roomId)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 956 | forgetOpenRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 957 | closeRoom(roomId).catch(() => undefined); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 958 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 959 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 960 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 961 | pushBanner(e instanceof Error ? e.message : 'Leave failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 962 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 963 | leaveBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 964 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 965 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 966 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 967 | function connectionClass(state: string): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 968 | if (state === 'online') return 'dot-online'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 969 | if (state === 'connecting' || state === 'reconnecting') return 'dot-busy'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 970 | return 'dot-off'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 971 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 972 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 973 | function onKeydown(ev: KeyboardEvent): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 974 | if (ev.key === 'Escape') { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 975 | if (dialog) dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 976 | else if (membersOpen && window.innerWidth < 1100) membersOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 977 | else if (sidebarOpen) sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 978 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 979 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 980 | </script> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 981 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 982 | <svelte:window on:keydown={onKeydown} on:pointerup={() => (draggingScrollbar = false)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 983 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 984 | {#if !booted} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 985 | <div class="splash" role="status" aria-label="Loading Malice"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 986 | <div class="splash-mark" aria-hidden="true">M</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 987 | <p>Loading Malice…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 988 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 989 | {:else if $blocked} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 990 | <div class="splash" role="status" aria-label="Malice is open in another tab"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 991 | <div class="splash-mark" aria-hidden="true">M</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 992 | <p>Malice is open in another tab. Close this tab or use that one instead.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 993 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 994 | {:else if $sessionUser == null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 995 | <LoginPanel softLogout={$softLogout} on:done={(ev) => afterLogin(ev.detail)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 996 | {:else} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 997 | <div class="app" class:nav-folded={$navFolded && selectedRoom} style:--msg-gap={`${$messageSpacing}px`} style:--msg-line-height={$lineHeight}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 998 | <nav class="rail" aria-label="Servers and spaces"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 999 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1000 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1001 | class="rail-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1002 | class:active={selectedSpaceId === null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1003 | title="Home — all channels" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1004 | aria-label="Home — all channels" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1005 | aria-pressed={selectedSpaceId === null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1006 | on:click={() => void selectHome()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1007 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1008 | <span aria-hidden="true">⌂</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1009 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1010 | <div class="rail-sep" aria-hidden="true"></div> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1011 | {#each railSpaces as space (space.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1012 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1013 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1014 | class="rail-btn rail-space" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1015 | class:active={railSelected === space.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1016 | title={space.name} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1017 | aria-label={`Show channels in space ${space.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1018 | aria-pressed={selectedSpaceId === space.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1019 | on:click={() => void selectSpace(space.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1020 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1021 | <MxcAvatar mxc={space.avatar} label={space.name} size={44} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1022 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1023 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1024 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1025 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1026 | class="rail-btn rail-add" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1027 | aria-label="Join or create a room" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1028 | on:click={() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1029 | dialog = 'join'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1030 | }} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1031 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1032 | <span aria-hidden="true">+</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1033 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1034 | </nav> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1035 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1036 | <aside class="sidebar" class:open={sidebarOpen} aria-label="Rooms"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1037 | <div class="side-search"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1038 | <label class="visually-hidden" for="room-search">Search rooms</label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1039 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1040 | id="room-search" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1041 | type="search" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1042 | placeholder="Search rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1043 | bind:value={search} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1044 | autocomplete="off" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1045 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1046 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1047 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1048 | class="icon-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1049 | title="Refresh rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1050 | aria-label="Refresh rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1051 | disabled={roomsLoading} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1052 | on:click={() => void refreshRooms()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1053 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1054 | <span aria-hidden="true">⟳</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1055 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1056 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1057 | <div class="side-scroll"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1058 | {#if selectedSpace} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1059 | <div class="space-context"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1060 | <MxcAvatar mxc={selectedSpace.avatar} label={selectedSpace.name} size={28} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1061 | <div class="space-context-text"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1062 | <strong>{selectedSpace.name}</strong> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1063 | </div> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1064 | {#if spaceParents.has(selectedSpace.room_id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1065 | {@const parentId = spaceParents.get(selectedSpace.room_id) ?? ''} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1066 | <button |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1067 | type="button" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1068 | class="icon-btn" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1069 | title="Up to the parent space" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1070 | aria-label="Up to the parent space" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1071 | on:click={() => void selectSpace(parentId)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1072 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1073 | <span aria-hidden="true">↑</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1074 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1075 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1076 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1077 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1078 | <div class="space-context"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1079 | <div class="space-context-text"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1080 | <strong>Home</strong> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1081 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1082 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1083 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1084 | {#if roomsLoading && $rooms.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1085 | <p class="side-note">Loading rooms…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1086 | {:else if $rooms.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1087 | <p class="side-note">No rooms yet</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1088 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1089 | <button type="button" on:click={() => (dialog = 'join')}>Join a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1090 | <button type="button" on:click={() => (dialog = 'create')}>Create one</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1091 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1092 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1093 | {#if selectedSpaceId && spaceChildrenLoading} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1094 | <p class="side-note">Loading channels…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1095 | {:else if selectedSpaceId && spaceChildrenError} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1096 | <p class="side-note" role="alert">{spaceChildrenError}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1097 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1098 | <button type="button" on:click={() => selectedSpaceId && void selectSpace(selectedSpaceId)}>Retry</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1099 | <button type="button" on:click={() => void selectHome()}>Back to Home</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1100 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1101 | {:else if selectedSpaceId && spaceChildIds && channelRooms.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1102 | <p class="side-note">No channels</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1103 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1104 | <button type="button" on:click={() => void selectHome()}>Back to Home</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1105 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1106 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1107 | {#if invites.length > 0 && !selectedSpaceId} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1108 | <h2 class="side-h">Invites</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1109 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1110 | {#each invites as room (room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1111 | <li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1112 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1113 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1114 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1115 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1116 | on:click={() => void selectRoom(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1117 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1118 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1119 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1120 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1121 | class="invite-join" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1122 | role="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1123 | tabindex="0" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1124 | aria-label={`Join ${room.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1125 | on:click|stopPropagation={() => void join(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1126 | on:keydown|stopPropagation={(ev) => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1127 | if (ev.key === 'Enter' || ev.key === ' ') { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1128 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1129 | void join(room.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1130 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1131 | }} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1132 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1133 | Join |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1134 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1135 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1136 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1137 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1138 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1139 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1140 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1141 | {#if directRooms.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1142 | <h2 class="side-h">Direct messages</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1143 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1144 | {#each directRooms as room (room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1145 | <li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1146 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1147 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1148 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1149 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1150 | aria-current={$selectedRoomId === room.room_id ? 'true' : undefined} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1151 | on:click={() => void selectRoom(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1152 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1153 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1154 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1155 | {#if roomUnread(room) > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1156 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1157 | class="badge" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1158 | class:mention={room.unread_mentions > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1159 | aria-label={`${roomUnread(room)} unread`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1160 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1161 | {roomUnread(room) > 99 ? '99+' : roomUnread(room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1162 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1163 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1164 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1165 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1166 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1167 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1168 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1169 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1170 | {#if groupRooms.length > 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1171 | <h2 class="side-h">{selectedSpace ? 'Channels' : 'Rooms'}</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1172 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1173 | {#each groupRooms as room (room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1174 | <li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1175 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1176 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1177 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1178 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1179 | aria-current={$selectedRoomId === room.room_id ? 'true' : undefined} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1180 | on:click={() => void selectRoom(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1181 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1182 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1183 | <span class="room-hash" aria-hidden="true">#</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1184 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1185 | {#if roomUnread(room) > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1186 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1187 | class="badge" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1188 | class:mention={room.unread_mentions > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1189 | aria-label={`${roomUnread(room)} unread`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1190 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1191 | {roomUnread(room) > 99 ? '99+' : roomUnread(room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1192 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1193 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1194 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1195 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1196 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1197 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1198 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1199 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1200 | {#if spaceList.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1201 | <h2 class="side-h">{selectedSpace ? 'Subspaces' : 'Spaces'}</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1202 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1203 | {#each spaceList as room (room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1204 | <li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1205 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1206 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1207 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1208 | class:active={selectedSpaceId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1209 | aria-label={`Show channels in space ${room.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1210 | on:click={() => void selectSpace(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1211 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1212 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1213 | <span class="room-hash" aria-hidden="true">◇</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1214 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1215 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1216 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1217 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1218 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1219 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1220 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1221 | {#if query && visibleRooms.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1222 | <p class="side-note">No rooms match “{search.trim()}”.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1223 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1224 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1225 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1226 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1227 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1228 | <div class="side-footer"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1229 | <div class="me" title={$sessionUser}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1230 | {#if profileMxc} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1231 | <MxcAvatar mxc={profileMxc} label={profile?.display_name ?? $sessionUser} size={30} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1232 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1233 | <span class="me-avatar" aria-hidden="true">{$sessionUser.slice(1, 2).toUpperCase()}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1234 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1235 | <span class="me-id">{profile?.display_name && profile.display_name !== $sessionUser ? `${profile.display_name} (${$sessionUser})` : $sessionUser}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1236 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1237 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1238 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1239 | class="icon-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1240 | title="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1241 | aria-label="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1242 | on:click={() => (dialog = 'security')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1243 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1244 | <span aria-hidden="true">🛡</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1245 | </button> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1246 | <button |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1247 | type="button" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1248 | class="icon-btn" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1249 | title="Settings" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1250 | aria-label="Settings" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1251 | on:click={() => (dialog = 'settings')} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1252 | > |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1253 | <span aria-hidden="true">⚙</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1254 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1255 | <button type="button" class="icon-btn" title="Log out" aria-label="Log out" on:click={() => void doLogout()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1256 | <span aria-hidden="true">⏻</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1257 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1258 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1259 | </aside> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1260 | {#if sidebarOpen} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1261 | <button type="button" class="scrim" aria-label="Close room list" on:click={() => (sidebarOpen = false)}></button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1262 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1263 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1264 | <main class="chat"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1265 | {#if $banners.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1266 | <div class="banners" aria-live="polite"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1267 | {#each $banners as banner (banner.id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1268 | <div class="banner" role="alert"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1269 | <span>{banner.message}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1270 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1271 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1272 | aria-label="Dismiss error" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1273 | on:click={() => dismissBanner(banner.id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1274 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1275 | ✕ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1276 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1277 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1278 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1279 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1280 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1281 | {#if !selectedRoom} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1282 | <div class="empty"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1283 | <div class="empty-mark" aria-hidden="true">◈</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1284 | {#if selectedSpace} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1285 | <h1>{selectedSpace.name}</h1> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1286 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1287 | <h1>Welcome to Malice</h1> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1288 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1289 | <div class="empty-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1290 | <button type="button" class="primary-btn" on:click={() => (dialog = 'join')}>Join a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1291 | <button type="button" class="ghost-btn" on:click={() => (dialog = 'create')}>Create a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1292 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1293 | <p class="conn-line"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1294 | <span class="dot {connectionClass($connection)}" aria-hidden="true"></span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1295 | {$connection} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1296 | </p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1297 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1298 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1299 | <header class="chat-head"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1300 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1301 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1302 | class="icon-btn only-mobile" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1303 | aria-label="Open room list" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1304 | on:click={() => (sidebarOpen = true)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1305 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1306 | <span aria-hidden="true">☰</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1307 | </button> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1308 | <button |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1309 | type="button" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1310 | class="icon-btn only-desktop" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1311 | aria-pressed={!$navFolded} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1312 | aria-label={$navFolded ? 'Show spaces and rooms' : 'Hide spaces and rooms'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1313 | title={$navFolded ? 'Show spaces and rooms' : 'Hide spaces and rooms'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1314 | on:click={() => navFolded.update((v) => !v)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1315 | > |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1316 | <span aria-hidden="true">{$navFolded ? '»' : '«'}</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1317 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1318 | <div class="head-title"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1319 | <div class="head-room"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1320 | <MxcAvatar mxc={selectedRoom.avatar} label={selectedRoom.name} size={36} shape={selectedRoom.space ? 'rounded' : 'circle'} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1321 | <div class="head-room-text"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1322 | <h1>{selectedRoom.name}</h1> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1323 | <div class="head-meta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1324 | {#if selectedRoom.space} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1325 | <span class="pill">space</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1326 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1327 | {#if selectedRoom.encrypted} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1328 | <span class="pill" title="End-to-end encrypted">🔒 encrypted</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1329 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1330 | {#if selectedRoom.direct} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1331 | <span class="pill">direct</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1332 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1333 | <span class="conn" title={`Sync state: ${$connection}`}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1334 | <span class="dot {connectionClass($connection)}" aria-hidden="true"></span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1335 | {$connection} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1336 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1337 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1338 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1339 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1340 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1341 | <div class="head-actions"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1342 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1343 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1344 | class="ghost-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1345 | aria-label="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1346 | title="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1347 | on:click={() => (dialog = 'security')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1348 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1349 | 🛡 Security |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1350 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1351 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1352 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1353 | class="ghost-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1354 | aria-pressed={membersOpen} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1355 | aria-label={membersOpen ? 'Hide members' : 'Show members'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1356 | on:click={toggleMembers} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1357 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1358 | Members |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1359 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1360 | {#if selectedRoom.membership === 'Joined'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1361 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1362 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1363 | class="ghost-btn danger" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1364 | disabled={leaveBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1365 | on:click={() => void leave()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1366 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1367 | {leaveBusy ? 'Leaving…' : 'Leave'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1368 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1369 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1370 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1371 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1372 | class="primary-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1373 | disabled={joinBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1374 | on:click={() => void join(selectedRoom.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1375 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1376 | {joinBusy ? 'Joining…' : 'Join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1377 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1378 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1379 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1380 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1381 | class="icon-btn only-mobile" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1382 | aria-label="Toggle members" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1383 | on:click={toggleMembers} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1384 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1385 | <span aria-hidden="true">ⓘ</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1386 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1387 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1388 | </header> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1389 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1390 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1391 | {#if recoveryBanner} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1392 | <div class="sec-banner warn" role="status"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1393 | <span>Message history is locked</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1394 | <button type="button" on:click={() => (dialog = 'security')}>Recover</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1395 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1396 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1397 | {#if verificationBanner} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1398 | <div class="sec-banner" role="status"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1399 | {#if verificationBanner.kind === 'Incoming'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1400 | <span>A device wants to verify this session</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1401 | <button type="button" on:click={() => (dialog = 'security')}>Review request</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1402 | {:else if verificationBanner.kind === 'Comparison'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1403 | <span>Verification codes ready</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1404 | <button type="button" on:click={() => (dialog = 'security')}>Compare codes</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1405 | {:else if verificationBanner.kind === 'Waiting'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1406 | <span>Verification started</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1407 | <button type="button" on:click={() => (dialog = 'security')}>Open verification</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1408 | {:else if verificationBanner.kind === 'Failed'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1409 | <span>Verification failed: {verificationBanner.message}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1410 | <button type="button" on:click={() => (dialog = 'security')}>Try again</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1411 | {:else if verificationBanner.kind === 'Cancelled'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1412 | <span>Verification cancelled: {verificationBanner.reason}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1413 | <button type="button" on:click={() => (dialog = 'security')}>Open security</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1414 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1415 | <span>Verification in progress</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1416 | <button type="button" on:click={() => (dialog = 'security')}>Open security</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1417 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1418 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1419 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1420 | {#if $selectedRoomId && openFailed[$selectedRoomId]} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1421 | <p class="conn-banner error" role="alert">{openFailed[$selectedRoomId]}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1422 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1423 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1424 | <!-- svelte-ignore a11y_no_static_element_interactions --> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1425 | <div |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1426 | class="timeline" |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1427 | bind:this={timelineEl} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1428 | on:scroll={onTimelineScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1429 | on:wheel={noteUserScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1430 | on:touchmove={noteUserScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1431 | on:keydown={onTimelineKey} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1432 | on:pointerdown={onTimelinePointer} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1433 | aria-label={`Messages in ${selectedRoom.name}`} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1434 | > |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1435 | <div class="timeline-inner" use:pinTimeline> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1436 | <div class="timeline-top"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1437 | {#if hasStart} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1438 | <p class="start-note">Beginning of history</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1439 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1440 | <button type="button" class="ghost-btn" disabled={paginateBusy} on:click={() => void paginate()}> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1441 | {paginateBusy ? 'Loading…' : 'Load older messages'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1442 | </button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1443 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1444 | </div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1445 | {#if grouped.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1446 | <p class="side-note timeline-empty">No messages yet</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1447 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1448 | {#each grouped as g (g.key)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1449 | {#if g.item.kind === 'day'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1450 | <div class="day-row"><span>{formatDay(g.item.timestamp_ms)}</span></div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1451 | {:else if g.item.kind === 'readMarker'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1452 | <div class="new-row"><span>New</span></div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1453 | {:else if g.item.kind === 'start'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1454 | <p class="start-note">Beginning of history</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1455 | {:else if g.item.kind === 'unknown'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1456 | <p class="unknown-note">Unsupported event ({g.item.label})</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1457 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1458 | <MessageRow |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1459 | itemId={g.key} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1460 | event={g.item.event} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1461 | showSender={g.showSender} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1462 | senderAvatar={senderAvatarFor(g.item.event.sender.user_id)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1463 | {reacting} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1464 | onReact={(eventId, key, shortcode) => void react(eventId, key, shortcode)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1465 | quickReactions={$quickReactions} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1466 | packs={roomPacks} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1467 | linkPreviews={$linkPreviews} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1468 | {loadPreview} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1469 | onQuickChange={(list) => void changeQuickReactions(list)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1470 | {people} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1471 | self={$sessionUser ?? null} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1472 | onReply={selectedRoom.membership === 'Joined' ? startReply : null} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1473 | onJump={jumpTo} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1474 | onEdit={selectedRoom.membership === 'Joined' ? startEdit : null} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1475 | editing={editing !== null && editing.eventId === g.item.event.event_id} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1476 | showSent={g.item.event.item_id === lastSentId && pendingItems.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1477 | /> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1478 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1479 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1480 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1481 | {#each pendingItems as p, i (p.id)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1482 | <MessageRow |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1483 | itemId={`pending-${p.id}`} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1484 | event={pendingToEvent(p)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1485 | onJump={jumpTo} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1486 | showSender={pendingShowSender(i)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1487 | senderAvatar={senderAvatarFor($sessionUser ?? '')} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1488 | {reacting} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1489 | onReact={(eventId, key, shortcode) => void react(eventId, key, shortcode)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1490 | quickReactions={$quickReactions} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1491 | packs={roomPacks} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1492 | linkPreviews={$linkPreviews} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1493 | {loadPreview} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1494 | onQuickChange={(list) => void changeQuickReactions(list)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1495 | /> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1496 | {#if p.status === 'failed'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1497 | <div class="pending-actions"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1498 | <span class="pending-error" role="alert">{p.error}</span> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1499 | <button type="button" class="ghost-btn" on:click={() => retryPending(p.id)}>Retry</button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1500 | <button type="button" class="ghost-btn danger" on:click={() => discardPending(p.id)}>Discard</button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1501 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1502 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1503 | {/each} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1504 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1505 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1506 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1507 | {#if selectedRoom.membership === 'Joined'} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1508 | {#if editing} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1509 | <div class="reply-bar" role="status"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1510 | <span class="reply-bar-label"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1511 | Editing message |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1512 | <span class="reply-bar-text">{editing.original}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1513 | </span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1514 | <button type="button" class="icon-btn" aria-label="Cancel edit" title="Cancel edit (Esc)" on:click={cancelEdit}> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1515 | <span aria-hidden="true">✕</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1516 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1517 | </div> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1518 | {:else if replyingTo && replyingTo.details.kind === 'Ready'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1519 | <div class="reply-bar" role="status"> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1520 | <span class="reply-bar-label"> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1521 | Replying to <strong>{senderLabel(replyingTo.details.sender)}</strong> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1522 | <span class="reply-bar-text">{contentPreview(replyingTo.details.content)}</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1523 | </span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1524 | <button type="button" class="icon-btn" aria-label="Cancel reply" title="Cancel reply (Esc)" on:click={() => (replyingTo = null)}> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1525 | <span aria-hidden="true">✕</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1526 | </button> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1527 | </div> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1528 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1529 | {#if $selectedRoomId && currentStaged.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1530 | {@const stagedRoom = $selectedRoomId} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1531 | <ul class="staged" aria-label="Attachments to send"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1532 | {#each currentStaged as attachment (attachment.id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1533 | <li class="staged-item"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1534 | {#if attachment.previewUrl} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1535 | <img src={attachment.previewUrl} alt={attachment.file.name || 'Pasted image'} /> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1536 | {:else} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1537 | <span class="staged-name">{attachment.file.name || 'attachment'}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1538 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1539 | <button |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1540 | type="button" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1541 | class="icon-btn staged-remove" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1542 | aria-label={`Remove ${attachment.file.name || 'attachment'}`} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1543 | title="Remove" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1544 | on:click={() => unstage(stagedRoom, attachment.id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1545 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1546 | <span aria-hidden="true">✕</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1547 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1548 | </li> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1549 | {/each} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1550 | </ul> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1551 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1552 | <form class="composer" class:replying={replyingTo || editing} class:staging={currentStaged.length > 0} on:submit|preventDefault={() => send()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1553 | <label class="visually-hidden" for="composer">Message {selectedRoom.name}</label> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1554 | {#if mentionQuery && mentionCandidates.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1555 | <ul class="mention-finder" role="listbox" aria-label="Mention someone"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1556 | {#each mentionCandidates as person, i (person.user_id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1557 | <li |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1558 | role="option" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1559 | aria-selected={i === mentionIndex} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1560 | class:active={i === mentionIndex} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1561 | on:pointerdown|preventDefault={() => void pickMention(person)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1562 | on:pointerenter={() => (mentionIndex = i)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1563 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1564 | <MxcAvatar mxc={person.avatar} label={person.name} size={22} /> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1565 | <span class="mention-name">{person.name}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1566 | <span class="mention-id">{person.user_id}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1567 | </li> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1568 | {/each} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1569 | </ul> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1570 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1571 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1572 | type="file" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1573 | multiple |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1574 | bind:this={fileInput} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1575 | class="visually-hidden" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1576 | aria-label="Attach a file" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1577 | on:change={() => void onFileChosen()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1578 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1579 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1580 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1581 | class="ghost-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1582 | title="Attach an image or file" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1583 | aria-label="Attach an image or file" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1584 | disabled={!($selectedRoomId && openReady[$selectedRoomId])} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1585 | on:click={pickFiles} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1586 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1587 | {uploadBusy ? `Uploading ${uploadName ?? 'file'}…` : '📎'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1588 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1589 | <textarea |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1590 | id="composer" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1591 | bind:this={composerEl} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1592 | bind:value={composer} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1593 | rows="1" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1594 | placeholder={`Message ${selectedRoom.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1595 | aria-label={`Message ${selectedRoom.name}. Enter to send, Shift Enter for a new line.`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1596 | on:keydown={onComposerKey} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1597 | on:input={updateMentionQuery} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1598 | on:click={updateMentionQuery} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1599 | on:keyup={(e) => (e.key.startsWith('Arrow') && e.key !== 'ArrowUp' && e.key !== 'ArrowDown') || e.key === 'Home' || e.key === 'End' ? updateMentionQuery() : undefined} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1600 | on:blur={() => (mentionQuery = null)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1601 | on:paste={onComposerPaste} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1602 | disabled={!($selectedRoomId && openReady[$selectedRoomId])} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1603 | ></textarea> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1604 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1605 | type="submit" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1606 | class="primary-btn" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1607 | disabled={(!composer.trim() && currentStaged.length === 0) || |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1608 | !($selectedRoomId && openReady[$selectedRoomId]) || |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1609 | (currentStaged.length > 0 && uploadBusy)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1610 | title={!($selectedRoomId && openReady[$selectedRoomId]) ? 'Waiting for the room to open' : 'Send message'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1611 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1612 | Send |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1613 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1614 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1615 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1616 | <div class="join-bar"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1617 | <p>You are not a member of this room.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1618 | <button type="button" class="primary-btn" disabled={joinBusy} on:click={() => void join(selectedRoom.room_id)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1619 | {joinBusy ? 'Joining…' : `Join ${selectedRoom.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1620 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1621 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1622 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1623 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1624 | </main> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1625 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1626 | {#if selectedRoom && membersOpen} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1627 | <aside class="members" aria-label={`Members of ${selectedRoom.name}`}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1628 | <div class="members-head"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1629 | <h2>Members</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1630 | <button type="button" class="icon-btn" aria-label="Close members" on:click={() => (membersOpen = false)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1631 | <span aria-hidden="true">✕</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1632 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1633 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1634 | {#if $membersLoading && members.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1635 | <p class="side-note">Loading members…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1636 | {:else if members.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1637 | <p class="side-note">No members loaded.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1638 | {#if $selectedRoomId} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1639 | <button type="button" class="ghost-btn" on:click={() => $selectedRoomId && void loadMembers($selectedRoomId)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1640 | Retry |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1641 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1642 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1643 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1644 | <ul class="member-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1645 | {#each members as member (member.user_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1646 | <li class="member"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1647 | <MxcAvatar mxc={member.avatar} label={member.display_name || member.name || member.user_id} size={30} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1648 | <span class="member-names"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1649 | <span class="member-name">{member.display_name || member.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1650 | <span class="member-id">{member.user_id}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1651 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1652 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1653 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1654 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1655 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1656 | </aside> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1657 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1658 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1659 | {#if dialog} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1660 | <div class="modal-wrap" role="presentation" on:click|self={() => (dialog = null)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1661 | {#if dialog === 'security'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1662 | <SecurityPanel |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1663 | encryptionState={$encryption} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1664 | verificationState={$verification} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1665 | onAction={() => void loadEncryption()} |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1666 | encryptedPreviews={$urlPreviewSettings.encrypted_rooms} |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1667 | onEncryptedPreviews={(enabled) => void changeEncryptedPreviews(enabled)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1668 | on:close={() => (dialog = null)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1669 | /> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1670 | {:else if dialog === 'settings'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1671 | <SettingsPanel |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1672 | quick={$quickReactions} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1673 | packs={roomPacks} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1674 | onQuickChange={(list) => void changeQuickReactions(list)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1675 | on:close={() => (dialog = null)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1676 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1677 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1678 | <div class="modal" role="dialog" aria-modal="true" aria-label={dialog === 'join' ? 'Join a room' : 'Create a room'}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1679 | <div class="modal-tabs" role="tablist" aria-label="Room actions"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1680 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1681 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1682 | role="tab" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1683 | aria-selected={dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1684 | class:active={dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1685 | on:click={() => (dialog = 'join')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1686 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1687 | Join |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1688 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1689 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1690 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1691 | role="tab" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1692 | aria-selected={dialog === 'create'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1693 | class:active={dialog === 'create'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1694 | on:click={() => (dialog = 'create')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1695 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1696 | Create |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1697 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1698 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1699 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1700 | class="icon-btn modal-x" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1701 | aria-label="Close dialog" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1702 | on:click={() => (dialog = null)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1703 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1704 | <span aria-hidden="true">✕</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1705 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1706 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1707 | {#if dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1708 | <form on:submit|preventDefault={() => void join(joinTarget)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1709 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1710 | <span>Room ID or alias</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1711 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1712 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1713 | placeholder="!room:example.org or #alias:example.org" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1714 | bind:value={joinTarget} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1715 | required |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1716 | disabled={joinBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1717 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1718 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1719 | <button type="submit" class="primary-btn wide" disabled={joinBusy || !joinTarget.trim()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1720 | {joinBusy ? 'Joining…' : 'Join room'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1721 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1722 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1723 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1724 | <form on:submit|preventDefault={() => void create()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1725 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1726 | <span>Room name</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1727 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1728 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1729 | placeholder="Weekend plans" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1730 | bind:value={createName} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1731 | required |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1732 | disabled={createBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1733 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1734 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1735 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1736 | <span>Topic (optional)</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1737 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1738 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1739 | placeholder="What should this room be about?" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1740 | bind:value={createTopic} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1741 | disabled={createBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1742 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1743 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1744 | <button type="submit" class="primary-btn wide" disabled={createBusy || !createName.trim()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1745 | {createBusy ? 'Creating…' : 'Create room'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1746 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1747 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1748 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1749 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1750 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1751 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1752 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1753 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1754 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1755 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1756 | <ImageLightbox /> |