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