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