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'; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 6 | import PinButton from './lib/PinButton.svelte'; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 7 | import ContextMenu, { type MenuItem } from './lib/ContextMenu.svelte'; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 8 | import StickerPicker from './lib/StickerPicker.svelte'; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 9 | import PackManager from './lib/PackManager.svelte'; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 10 | import { clonePackDestinations, editableChoices, shortcodeFor } from './lib/packs'; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 11 | import type { CommandRequest } from './lib/transport'; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 12 | import UserCard, { type UserAction } from './lib/UserCard.svelte'; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 13 | import { allowed, canRedact, isMuted, parsePowerLevels, type PowerLevels } from './lib/permissions'; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 14 | import { moveBefore, pinnedFirst, sortSpaces } from './lib/rail-order'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 15 | import ImageLightbox from './lib/ImageLightbox.svelte'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 16 | import { lightbox } from './lib/lightbox'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 17 | import SecurityPanel from './lib/SecurityPanel.svelte'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 18 | import { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 19 | closeRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 20 | createRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 21 | getEncryption, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 22 | getMembers, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 23 | getProfile, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 24 | getRooms, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 25 | getSession, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 26 | getSpaceChildren, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 27 | joinRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 28 | leaveRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 29 | logout, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 30 | markRead, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 31 | openRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 32 | paginateRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 33 | reactToMessage, |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 34 | runCommand, |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 35 | sendMessage, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 36 | uploadAttachment, |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 37 | uploadAvatar, |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 38 | uploadRoomAvatar, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 39 | editMessage |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 40 | } from './lib/api'; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 41 | import { isKnownCommand, parseCommand, splitTarget, unescapeCommand } from './lib/commands'; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 42 | import type { ParsedCommand } from './lib/commands'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 43 | import { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 44 | banners, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 45 | blocked, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 46 | connectEvents, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 47 | connection, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 48 | disconnectEvents, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 49 | dismissBanner, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 50 | encryption, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 51 | membersByRoom, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 52 | membersLoading, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 53 | pushBanner, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 54 | imagePacks, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 55 | resetClientState, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 56 | rooms, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 57 | selectedRoomId, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 58 | sessionUser, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 59 | softLogout, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 60 | timelines, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 61 | verification |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 62 | } from './lib/store'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 63 | import { discardPending, pendingByRoom, queueSend, resetPending, retryPending } from './lib/pending'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 64 | import type { PendingMessage } from './lib/pending'; |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 65 | import { insideOpenFence } from './lib/markdown'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 66 | import { mentionQueryAt, mentionsFromHtml, rankPeople, resolveMentions } from './lib/mentions'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 67 | import type { Mention, MentionQuery } from './lib/mentions'; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 68 | import { loadQuickReactions, quickReactions, saveQuickReactions } from './lib/quick-reactions'; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 69 | import { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 70 | linkPreviews, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 71 | loadUrlPreviewSettings, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 72 | requestLinkPreview, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 73 | saveUrlPreviewSettings, |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 74 | urlPreviewSettings |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 75 | } from './lib/link-previews'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 76 | import { notifyTyping, stopTyping } from './lib/typing'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 77 | import { formatDay } from './lib/format'; |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 78 | import { lastSpaceRooms, lineHeight, markdownEnabled, messageSpacing, navFolded, railFolded } from './lib/appearance'; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 79 | import SettingsPanel from './lib/SettingsPanel.svelte'; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 80 | import { packsForRoom, parseEncryptionState, parseOwnProfile, parseVerificationState, contentPreview, senderLabel } from './lib/types'; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 81 | import type { ImagePack, MemberSummary, OwnProfile, PackImage, Person, QuickReaction, ReplyReference, RoomSummary, SendState, TimelineEvent, TimelineItem } from './lib/types'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 82 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 83 | let roomsLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 84 | let booted = false; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 85 | let wasOnline = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 86 | let search = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 87 | let sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 88 | let membersOpen = false; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 89 | let replyingTo: ReplyReference | null = null; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 90 | let dialog: 'join' | 'create' | 'security' | 'settings' | 'packs' | null = null; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 91 | let stickersOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 92 | let joinTarget = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 93 | let joinBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 94 | let createName = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 95 | let createTopic = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 96 | let createBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 97 | let leaveBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 98 | let paginateBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 99 | let reacting = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 100 | let composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 101 | let drafts: Record<string, string> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 102 | let stickToBottom = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 103 | let timelineEl: HTMLElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 104 | let composerEl: HTMLTextAreaElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 105 | let fileInput: HTMLInputElement | null = null; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 106 | let avatarInput: HTMLInputElement | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 107 | let uploadBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 108 | let uploadName: string | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 109 | interface StagedAttachment { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 110 | id: number; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 111 | file: File; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 112 | previewUrl: string | null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 113 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 114 | let staged: Record<string, StagedAttachment[]> = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 115 | let editing: { roomId: string; eventId: string; original: string; stash: string } | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 116 | /** 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 | 117 | let pickedMentions: Record<string, Mention[]> = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 118 | let mentionQuery: MentionQuery | null = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 119 | let mentionIndex = 0; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 120 | let nextStagedId = 1; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 121 | const WARM_ROOM_LIMIT = 8; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 122 | /** Rooms left open after switching away so coming back is instant, least recently viewed first. */ |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 123 | let warmRooms: string[] = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 124 | let openReady: Record<string, boolean> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 125 | let openFailed: Record<string, string> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 126 | let membersFor: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 127 | let lastReadKey = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 128 | let readTimer: number | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 129 | let profile: OwnProfile | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 130 | let profileMxc: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 131 | let selectedSpaceId: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 132 | let spaceChildIds: string[] | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 133 | let spaceChildrenLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 134 | let spaceChildrenError: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 135 | let avatarByUser: Record<string, string | null> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 136 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 137 | // 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 | 138 | $: { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 139 | const online = $connection === 'online'; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 140 | if (online && !wasOnline) { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 141 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 142 | void loadUrlPreviewSettings(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 143 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 144 | wasOnline = online; |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 145 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 146 | $: selectedRoom = $rooms.find((r) => r.room_id === $selectedRoomId) ?? null; |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 147 | $: roomPacks = packsForRoom($imagePacks, $selectedRoomId); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 148 | $: previewsAllowed = selectedRoom !== null && (!selectedRoom.encrypted || $urlPreviewSettings.encrypted_rooms); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 149 | $: loadPreview = previewsAllowed && $selectedRoomId ? previewLoader($selectedRoomId) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 150 | $: spaceRooms = $rooms.filter((r) => r.space); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 151 | $: spaceParents = parentSpaceMap(spaceRooms); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 152 | $: railSpaces = spaceRooms.filter((s) => !spaceParents.has(s.room_id)); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 153 | let railOverride: string[] | null = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 154 | $: if (railOverride && sortSpaces(railSpaces, null).map((s) => s.room_id).join() === railOverride.join()) railOverride = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 155 | $: orderedRail = sortSpaces(railSpaces, railOverride); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 156 | $: pinnedRail = orderedRail.filter((s) => s.favourite); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 157 | $: otherRail = orderedRail.filter((s) => !s.favourite); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 158 | $: railSelected = selectedSpaceId ? topSpaceOf(selectedSpaceId, spaceParents) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 159 | $: invites = $rooms.filter((r) => r.membership === 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 160 | $: query = search.trim().toLowerCase(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 161 | $: selectedSpace = selectedSpaceId ? ($rooms.find((r) => r.room_id === selectedSpaceId) ?? null) : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 162 | // While a space's children load (or fail), show no channels rather than the |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 163 | // full list — listing everything would falsely imply it belongs to the space. |
f12c7de2a3ab | atagen | 2026-10-23 08:10 UTC | 164 | $: baseRooms = selectedSpaceId ? (spaceChildIds ? $rooms.filter((r) => spaceChildIds?.includes(r.room_id)) : []) : $rooms; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 165 | $: visibleRooms = query |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 166 | ? baseRooms.filter( |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 167 | (r) => |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 168 | r.name.toLowerCase().includes(query) || r.room_id.toLowerCase().includes(query) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 169 | ) |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 170 | : baseRooms; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 171 | $: directRooms = pinnedFirst(visibleRooms.filter((r) => r.direct && !r.space && r.membership !== 'Invited')); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 172 | $: groupRooms = pinnedFirst(visibleRooms.filter((r) => !r.direct && !r.space && r.membership !== 'Invited')); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 173 | $: spaceList = pinnedFirst(visibleRooms.filter((r) => r.space && r.membership !== 'Invited')); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 174 | $: channelRooms = baseRooms.filter((r) => !r.space && r.membership !== 'Invited'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 175 | $: recoveryBanner = $encryption && ($encryption.recovery === 'Disabled' || $encryption.recovery === 'Incomplete') ? $encryption : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 176 | $: verificationBanner = $verification && $verification.kind !== 'Done' ? $verification : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 177 | $: items = $selectedRoomId ? ($timelines[$selectedRoomId] ?? []) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 178 | $: currentStaged = $selectedRoomId ? (staged[$selectedRoomId] ?? []) : []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 179 | $: members = $selectedRoomId ? ($membersByRoom[$selectedRoomId] ?? []) : []; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 180 | $: people = peopleIn(items, members); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 181 | $: mentionCandidates = mentionQuery ? rankPeople(Object.values(people), mentionQuery.query, $sessionUser ?? null) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 182 | $: if (mentionIndex >= mentionCandidates.length) mentionIndex = 0; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 183 | $: hasStart = items.some((i) => i.kind === 'start'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 184 | $: grouped = buildGroups(items); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 185 | $: lastSentId = lastOwnSent(items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 186 | $: pendingItems = $selectedRoomId ? ($pendingByRoom[$selectedRoomId] ?? []) : []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 187 | $: lastRealOwn = lastSenderIsOwn(items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 188 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 189 | function lastSenderIsOwn(list: TimelineItem[]): boolean { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 190 | for (let i = list.length - 1; i >= 0; i -= 1) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 191 | const it = list[i]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 192 | if (it.kind === 'event') return it.event.sender.user_id === $sessionUser; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 193 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 194 | return false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 195 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 196 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 197 | function pendingShowSender(index: number): boolean { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 198 | return index === 0 ? !lastRealOwn : false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 199 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 200 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 201 | function pendingToEvent(p: PendingMessage): TimelineEvent { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 202 | const state: SendState = p.status === 'failed' ? { kind: 'Failed', will_retry: false } : { kind: 'Sending' }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 203 | return { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 204 | item_id: `pending-${p.id}`, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 205 | event_id: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 206 | transaction_id: p.id, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 207 | sender: { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 208 | user_id: $sessionUser ?? '', |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 209 | display_name: profile?.display_name ?? null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 210 | avatar: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 211 | name_ambiguous: false |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 212 | }, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 213 | timestamp_ms: p.createdAt, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 214 | own: true, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 215 | send_state: state, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 216 | content: { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 217 | kind: 'Message', |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 218 | message: { kind: 'Text', body: p.body, geo_uri: null, formatted_body: p.formatted, edited: false, media: null, link_previews: [] } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 219 | }, |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 220 | reply_to: p.replyTo, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 221 | thread_root: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 222 | thread_summary: null, |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 223 | reactions: [], |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 224 | read_by: [], |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 225 | editable: false |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 226 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 227 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 228 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 229 | interface Group { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 230 | key: string; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 231 | item: TimelineItem; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 232 | showSender: boolean; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 233 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 234 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 235 | function lastOwnSent(list: TimelineItem[]): string | null { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 236 | for (let i = list.length - 1; i >= 0; i--) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 237 | const item = list[i]; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 238 | 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 | 239 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 240 | return null; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 241 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 242 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 243 | function buildGroups(list: TimelineItem[]): Group[] { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 244 | const out: Group[] = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 245 | let prevSender: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 246 | let prevTs = 0; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 247 | list.forEach((item, index) => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 248 | let showSender = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 249 | if (item.kind === 'event') { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 250 | const e = item.event; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 251 | showSender = |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 252 | prevSender !== e.sender.user_id || Math.abs(e.timestamp_ms - prevTs) > 5 * 60 * 1000; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 253 | prevSender = e.sender.user_id; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 254 | prevTs = e.timestamp_ms; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 255 | out.push({ key: e.item_id || e.event_id || `m-${index}`, item, showSender }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 256 | } else { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 257 | prevSender = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 258 | out.push({ key: `${item.kind}-${index}`, item, showSender }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 259 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 260 | }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 261 | return out; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 262 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 263 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 264 | function roomUnread(r: RoomSummary): number { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 265 | return r.unread_messages + r.unread_mentions; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 266 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 267 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 268 | onMount(() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 269 | void boot(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 270 | return () => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 271 | disconnectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 272 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 273 | if (readTimer !== null) window.clearTimeout(readTimer); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 274 | }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 275 | }); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 276 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 277 | async function boot(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 278 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 279 | const session = await getSession(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 280 | blocked.set(session.blocked ?? false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 281 | sessionUser.set(session.user_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 282 | if (session.user_id) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 283 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 284 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 285 | connectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 286 | void loadProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 287 | void loadEncryption(); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 288 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 289 | void loadUrlPreviewSettings(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 290 | } else { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 291 | softLogout.set(session.soft_logout ?? null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 292 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 293 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 294 | pushBanner(e instanceof Error ? `Session check failed: ${e.message}` : 'Session check failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 295 | sessionUser.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 296 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 297 | booted = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 298 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 299 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 300 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 301 | async function refreshRooms(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 302 | roomsLoading = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 303 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 304 | const res = await getRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 305 | rooms.set(res.rooms); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 306 | pruneSpaceFilter(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 307 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 308 | pushBanner(e instanceof Error ? e.message : 'Could not load rooms'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 309 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 310 | roomsLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 311 | } |
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 | async function loadProfile(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 315 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 316 | const raw = await getProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 317 | profile = parseOwnProfile(raw); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 318 | profileMxc = profile.avatar_url; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 319 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 320 | profile = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 321 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 322 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 323 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 324 | async function loadEncryption(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 325 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 326 | const res = await getEncryption(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 327 | const state = parseEncryptionState(res.state); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 328 | if (state) encryption.set(state); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 329 | const verificationState = parseVerificationState(res.verification); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 330 | if (verificationState) verification.set(verificationState); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 331 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 332 | // Encryption status also arrives over SSE; a failed first fetch is not fatal. |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 333 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 334 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 335 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 336 | function afterLogin(userId: string): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 337 | sessionUser.set(userId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 338 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 339 | blocked.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 340 | void refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 341 | connectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 342 | void loadProfile(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 343 | void loadEncryption(); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 344 | void loadQuickReactions(); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 345 | void loadUrlPreviewSettings(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 346 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 347 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 348 | async function doLogout(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 349 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 350 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 351 | await logout(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 352 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 353 | pushBanner(e instanceof Error ? e.message : 'Logout failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 354 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 355 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 356 | disconnectEvents(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 357 | resetClientState(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 358 | softLogout.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 359 | blocked.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 360 | sessionUser.set(null); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 361 | lightbox.set(null); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 362 | composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 363 | drafts = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 364 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 365 | membersOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 366 | sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 367 | profile = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 368 | profileMxc = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 369 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 370 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 371 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 372 | openReady = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 373 | openFailed = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 374 | warmRooms = []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 375 | pickedMentions = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 376 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 377 | clearAllStaged(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 378 | avatarByUser = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 379 | resetPending(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 380 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 381 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 382 | /** 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 | 383 | function parentSpaceMap(spaces: RoomSummary[]): Map<string, string> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 384 | const ids = new Set(spaces.map((s) => s.room_id)); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 385 | const parents = new Map<string, string>(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 386 | for (const space of spaces) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 387 | for (const child of space.children) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 388 | 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 | 389 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 390 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 391 | for (const space of spaces) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 392 | const parent = space.parent_spaces.find((id) => id !== space.room_id && ids.has(id)); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 393 | if (parent && !parents.has(space.room_id)) parents.set(space.room_id, parent); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 394 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 395 | for (const id of [...parents.keys()]) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 396 | const seen = new Set<string>([id]); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 397 | let at = parents.get(id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 398 | while (at && !seen.has(at)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 399 | seen.add(at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 400 | at = parents.get(at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 401 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 402 | if (at) parents.delete(id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 403 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 404 | return parents; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 405 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 406 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 407 | function topSpaceOf(id: string, parents: Map<string, string>): string { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 408 | let at = id; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 409 | while (parents.has(at)) at = parents.get(at)!; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 410 | return at; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 411 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 412 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 413 | function pruneSpaceFilter(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 414 | if (!selectedSpaceId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 415 | if (!$rooms.some((r) => r.room_id === selectedSpaceId)) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 416 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 417 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 418 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 419 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 420 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 421 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 422 | async function selectHome(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 423 | selectedSpaceId = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 424 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 425 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 426 | sidebarOpen = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 427 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 428 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 429 | async function selectSpace(spaceId: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 430 | if ($selectedRoomId && composer.trim()) drafts[$selectedRoomId] = composer; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 431 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 432 | selectedSpaceId = spaceId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 433 | spaceChildIds = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 434 | spaceChildrenError = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 435 | spaceChildrenLoading = true; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 436 | const last = $lastSpaceRooms[spaceId]; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 437 | const resume = last && $rooms.some((r) => r.room_id === last && !r.space) ? last : null; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 438 | if (resume) { |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 439 | void selectRoom(resume); |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 440 | } else { |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 441 | sidebarOpen = true; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 442 | // A space is navigation, not a message timeline. |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 443 | selectedRoomId.set(null); |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 444 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 445 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 446 | const res = await getSpaceChildren(spaceId); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 447 | if (selectedSpaceId === spaceId) { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 448 | spaceChildIds = res.room_ids ?? []; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 449 | if (resume && !spaceChildIds.includes(resume) && $selectedRoomId === resume) { |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 450 | sidebarOpen = true; |
fddb0bcaabeb | atagen | 2026-10-24 07:02 UTC | 451 | selectedRoomId.set(null); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 452 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 453 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 454 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 455 | if (selectedSpaceId === spaceId) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 456 | spaceChildrenError = e instanceof Error ? e.message : 'Could not load rooms in this space'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 457 | spaceChildIds = []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 458 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 459 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 460 | if (selectedSpaceId === spaceId) spaceChildrenLoading = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 461 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 462 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 463 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 464 | async function selectRoom(roomId: string, peek = false): Promise<void> { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 465 | peeking = peek ? roomId : null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 466 | if ($selectedRoomId && composer.trim()) drafts[$selectedRoomId] = composer; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 467 | if (roomId === $selectedRoomId && openReady[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 468 | sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 469 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 470 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 471 | stopTyping(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 472 | const spaceId = selectedSpaceId; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 473 | if (spaceId) lastSpaceRooms.update((all) => ({ ...all, [spaceId]: roomId })); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 474 | selectedRoomId.set(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 475 | composer = drafts[roomId] ?? ''; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 476 | replyingTo = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 477 | editing = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 478 | mentionQuery = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 479 | stickToBottom = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 480 | lastReadKey = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 481 | sidebarOpen = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 482 | touchWarmRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 483 | if (openReady[roomId]) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 484 | if (membersOpen) void loadMembers(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 485 | await tick(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 486 | scrollToBottom(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 487 | queueReadReceipt(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 488 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 489 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 490 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 491 | if (openFailed[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 492 | const nextFailed = { ...openFailed }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 493 | delete nextFailed[roomId]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 494 | openFailed = nextFailed; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 495 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 496 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 497 | await openRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 498 | if (warmRooms.includes(roomId)) openReady = { ...openReady, [roomId]: true }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 499 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 500 | const message = e instanceof Error ? e.message : `Could not open room ${roomId}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 501 | openFailed = { ...openFailed, [roomId]: message }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 502 | pushBanner(message); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 503 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 504 | if (membersOpen) void loadMembers(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 505 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 506 | scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 507 | queueReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 508 | composerEl?.focus(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 509 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 510 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 511 | function touchWarmRoom(roomId: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 512 | warmRooms = [...warmRooms.filter((id) => id !== roomId), roomId]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 513 | while (warmRooms.length > WARM_ROOM_LIMIT) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 514 | const evicted = warmRooms[0]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 515 | warmRooms = warmRooms.slice(1); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 516 | forgetOpenRoom(evicted); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 517 | closeRoom(evicted).catch(() => undefined); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 518 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 519 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 520 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 521 | function forgetOpenRoom(roomId: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 522 | warmRooms = warmRooms.filter((id) => id !== roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 523 | const nextReady = { ...openReady }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 524 | delete nextReady[roomId]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 525 | openReady = nextReady; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 526 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 527 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 528 | function scrollToBottom(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 529 | if (timelineEl) timelineEl.scrollTop = timelineEl.scrollHeight; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 530 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 531 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 532 | let userScrollUntil = 0; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 533 | let draggingScrollbar = false; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 534 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 535 | function noteUserScroll(): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 536 | userScrollUntil = performance.now() + 300; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 537 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 538 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 539 | function onTimelineKey(e: KeyboardEvent): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 540 | if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(e.key)) noteUserScroll(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 541 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 542 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 543 | function onTimelinePointer(e: PointerEvent): void { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 544 | if (e.target === timelineEl) draggingScrollbar = true; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 545 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 546 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 547 | function onTimelineScroll(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 548 | if (!timelineEl) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 549 | const gap = timelineEl.scrollHeight - timelineEl.scrollTop - timelineEl.clientHeight; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 550 | if (gap < 80) stickToBottom = true; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 551 | else if (draggingScrollbar || performance.now() < userScrollUntil) stickToBottom = false; |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 552 | } |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 553 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 554 | function pinTimeline(node: HTMLElement) { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 555 | const observer = new ResizeObserver(() => { |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 556 | if (stickToBottom) scrollToBottom(); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 557 | }); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 558 | observer.observe(node); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 559 | if (node.parentElement) observer.observe(node.parentElement); |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 560 | return { destroy: () => observer.disconnect() }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 561 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 562 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 563 | $: void trackTimeline($selectedRoomId, items); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 564 | async function trackTimeline(roomId: string | null, list: TimelineItem[]): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 565 | if (!roomId || list.length === 0) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 566 | if (roomId !== $selectedRoomId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 567 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 568 | if (stickToBottom) scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 569 | queueReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 570 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 571 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 572 | function queueReadReceipt(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 573 | if (readTimer !== null) window.clearTimeout(readTimer); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 574 | readTimer = window.setTimeout(() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 575 | readTimer = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 576 | void sendReadReceipt(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 577 | }, 800); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 578 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 579 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 580 | async function sendReadReceipt(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 581 | const roomId = $selectedRoomId; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 582 | if (!roomId || roomId === peeking) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 583 | const list = $timelines[roomId] ?? []; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 584 | for (let i = list.length - 1; i >= 0; i -= 1) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 585 | const entry = list[i]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 586 | if (entry.kind === 'event' && entry.event.event_id) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 587 | const key = `${roomId}:${entry.event.event_id}`; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 588 | if (key === lastReadKey) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 589 | lastReadKey = key; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 590 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 591 | await markRead(roomId, entry.event.event_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 592 | } catch { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 593 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 594 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 595 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 596 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 597 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 598 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 599 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 600 | function send(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 601 | if (editing) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 602 | submitEdit(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 603 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 604 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 605 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 606 | const body = composer.trim(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 607 | const attachments = roomId ? (staged[roomId] ?? []) : []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 608 | if (!roomId || (!body && attachments.length === 0)) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 609 | if (!openReady[roomId]) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 610 | pushBanner('Still opening this room — sending is disabled until the room is ready.'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 611 | return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 612 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 613 | if (attachments.length > 0 && uploadBusy) return; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 614 | const command = parseCommand(body); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 615 | if (command && !isKnownCommand(command.name)) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 616 | pushBanner(`Unknown command /${command.name}`); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 617 | return; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 618 | } |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 619 | if (command && attachments.length > 0) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 620 | if (command.name !== 'roomavatar' && command.name !== 'globalavatar') { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 621 | pushBanner(`/${command.name} doesn't take attachments`); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 622 | return; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 623 | } |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 624 | if (command.args || attachments.length !== 1 || !attachments[0].file.type.startsWith('image/')) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 625 | pushBanner(`/${command.name} takes a single attached image`); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 626 | return; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 627 | } |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 628 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 629 | composer = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 630 | if (roomId in drafts) delete drafts[roomId]; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 631 | stickToBottom = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 632 | const reply = replyingTo; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 633 | replyingTo = null; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 634 | const text = unescapeCommand(body); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 635 | const mentions = resolveMentions(text, pickedMentions[roomId] ?? []); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 636 | pickedMentions = { ...pickedMentions, [roomId]: [] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 637 | mentionQuery = null; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 638 | if (command) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 639 | const image = attachments[0] ?? null; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 640 | if (image) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 641 | const { [roomId]: _used, ...rest } = staged; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 642 | staged = rest; |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 643 | } |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 644 | void execute(roomId, command, reply, mentions, image?.file ?? null).finally(() => { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 645 | if (image?.previewUrl) URL.revokeObjectURL(image.previewUrl); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 646 | }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 647 | } else if (attachments.length === 0) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 648 | queueSend(roomId, text, reply, mentions, $markdownEnabled); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 649 | } else { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 650 | const { [roomId]: _sent, ...rest } = staged; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 651 | staged = rest; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 652 | void sendAttachments(roomId, text, reply, mentions, attachments); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 653 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 654 | if (peeking === roomId) stopPeeking(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 655 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 656 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 657 | |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 658 | function lastOwnEventId(): string | null { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 659 | for (let i = items.length - 1; i >= 0; i -= 1) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 660 | const entry = items[i]; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 661 | if (entry.kind === 'event' && entry.event.own && entry.event.event_id && entry.event.content.kind !== 'Redacted') { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 662 | return entry.event.event_id; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 663 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 664 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 665 | return null; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 666 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 667 | |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 668 | async function execute( |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 669 | roomId: string, |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 670 | command: ParsedCommand, |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 671 | reply: ReplyReference | null, |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 672 | mentions: Mention[], |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 673 | image: File | null |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 674 | ): Promise<void> { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 675 | const { name, args } = command; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 676 | const target = () => { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 677 | const found = splitTarget(args, Object.values(people)); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 678 | if ('error' in found) throw new Error(found.error); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 679 | return found; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 680 | }; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 681 | const required = (what: string) => { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 682 | if (!args) throw new Error(`/${name} needs ${what}`); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 683 | return args; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 684 | }; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 685 | try { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 686 | switch (name) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 687 | case 'me': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 688 | case 'notice': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 689 | await sendMessage(roomId, required('something to say'), null, mentions, $markdownEnabled, name === 'me' ? 'emote' : 'notice'); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 690 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 691 | case 'msg': { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 692 | const { user_id, rest } = target(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 693 | const res = (await runCommand({ op: 'direct', user_id })) as { room_id: string }; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 694 | await refreshRooms(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 695 | await selectRoom(res.room_id); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 696 | if (rest) queueSend(res.room_id, rest, null, [], $markdownEnabled); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 697 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 698 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 699 | case 'join': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 700 | await join(required('a room id or alias')); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 701 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 702 | case 'leave': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 703 | await leave(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 704 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 705 | case 'invite': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 706 | await runCommand({ op: 'invite', room_id: roomId, user_id: target().user_id }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 707 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 708 | case 'disinvite': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 709 | case 'kick': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 710 | case 'ban': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 711 | case 'unban': { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 712 | const { user_id, rest } = target(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 713 | const op = name === 'disinvite' ? 'kick' : name; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 714 | await runCommand({ op, room_id: roomId, user_id, reason: rest || null }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 715 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 716 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 717 | case 'powerlevel': { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 718 | const { user_id, rest } = target(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 719 | const level = Number(rest); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 720 | if (!rest || !Number.isInteger(level)) throw new Error('/powerlevel needs a whole number after the name'); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 721 | await runCommand({ op: 'set_power_level', room_id: roomId, user_id, level }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 722 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 723 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 724 | case 'mute': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 725 | case 'unmute': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 726 | await runCommand({ op: 'mute', room_id: roomId, user_id: target().user_id, muted: name === 'mute' }); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 727 | break; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 728 | case 'ignore': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 729 | case 'unignore': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 730 | await runCommand({ op: name, user_id: target().user_id }); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 731 | break; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 732 | case 'roomnick': |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 733 | await runCommand({ op: 'set_room_display_name', room_id: roomId, name: args || null }); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 734 | break; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 735 | case 'roomavatar': |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 736 | if (image) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 737 | await uploadRoomAvatar(roomId, image); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 738 | } else if (args && !args.startsWith('mxc://')) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 739 | throw new Error('/roomavatar takes an mxc:// link, an attached image, or nothing to drop the override'); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 740 | } else { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 741 | await runCommand({ op: 'set_room_avatar', room_id: roomId, mxc: args || null }); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 742 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 743 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 744 | case 'delete': { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 745 | const eventId = reply?.event_id ?? lastOwnEventId(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 746 | if (!eventId) throw new Error('Nothing of yours to delete here'); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 747 | await runCommand({ op: 'redact', room_id: roomId, event_id: eventId, reason: args || null }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 748 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 749 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 750 | case 'globalnick': |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 751 | await runCommand({ op: 'set_display_name', name: required('a name') }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 752 | await loadProfile(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 753 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 754 | case 'globalavatar': |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 755 | if (image) { |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 756 | await uploadAvatar(image); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 757 | await loadProfile(); |
6c8fd192fb8c | atagen | 2026-10-24 08:20 UTC | 758 | } else if (!args) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 759 | avatarInput?.click(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 760 | } else if (args.startsWith('mxc://')) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 761 | await runCommand({ op: 'set_avatar', mxc: args }); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 762 | await loadProfile(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 763 | } else { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 764 | throw new Error('/globalavatar takes an mxc:// link, or nothing to pick a file'); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 765 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 766 | break; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 767 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 768 | } catch (e) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 769 | pushBanner(e instanceof Error ? e.message : `/${name} failed`); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 770 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 771 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 772 | |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 773 | async function onAvatarChosen(): Promise<void> { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 774 | const file = avatarInput?.files?.[0]; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 775 | if (avatarInput) avatarInput.value = ''; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 776 | if (!file) return; |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 777 | try { |
5e9271c9b8f1 | atagen | 2026-10-24 07:45 UTC | 778 | await uploadAvatar(file); |
5e9271c9b8f1 | atagen | 2026-10-24 07:45 UTC | 779 | await loadProfile(); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 780 | } catch (e) { |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 781 | pushBanner(e instanceof Error ? e.message : 'Avatar upload failed'); |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 782 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 783 | } |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 784 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 785 | async function sendAttachments( |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 786 | roomId: string, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 787 | body: string, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 788 | reply: ReplyReference | null, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 789 | mentions: Mention[], |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 790 | attachments: StagedAttachment[] |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 791 | ): Promise<void> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 792 | let first = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 793 | uploadBusy = true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 794 | try { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 795 | for (const attachment of attachments) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 796 | uploadName = attachment.file.name || 'attachment'; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 797 | try { |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 798 | if (first) await uploadAttachment(roomId, attachment.file, body || null, reply?.event_id ?? null, mentions, $markdownEnabled); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 799 | else await uploadAttachment(roomId, attachment.file); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 800 | first = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 801 | } catch (e) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 802 | pushBanner(e instanceof Error ? e.message : 'Upload failed'); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 803 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 804 | if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 805 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 806 | } finally { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 807 | uploadBusy = false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 808 | uploadName = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 809 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 810 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 811 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 812 | function stageFiles(files: File[]): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 813 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 814 | if (!roomId || !openReady[roomId]) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 815 | const accepted: StagedAttachment[] = []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 816 | for (const file of files) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 817 | if (file.size === 0 || file.size > 20 * 1024 * 1024) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 818 | pushBanner(`${file.name || 'File'} must be between 1 byte and 20 MiB.`); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 819 | continue; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 820 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 821 | const previewUrl = file.type.startsWith('image/') ? URL.createObjectURL(file) : null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 822 | accepted.push({ id: nextStagedId++, file, previewUrl }); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 823 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 824 | if (accepted.length === 0) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 825 | staged = { ...staged, [roomId]: [...(staged[roomId] ?? []), ...accepted] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 826 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 827 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 828 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 829 | function unstage(roomId: string, id: number): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 830 | const list = staged[roomId] ?? []; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 831 | const removed = list.find((a) => a.id === id); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 832 | if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 833 | staged = { ...staged, [roomId]: list.filter((a) => a.id !== id) }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 834 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 835 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 836 | function clearAllStaged(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 837 | for (const list of Object.values(staged)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 838 | for (const attachment of list) if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 839 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 840 | staged = {}; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 841 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 842 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 843 | function startEdit(eventId: string, body: string): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 844 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 845 | if (!roomId) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 846 | const stash = editing ? editing.stash : composer; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 847 | editing = { roomId, eventId, original: body, stash }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 848 | const entry = items.find((i) => i.kind === 'event' && i.event.event_id === eventId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 849 | if (entry?.kind === 'event' && entry.event.content.kind === 'Message') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 850 | const existing = mentionsFromHtml(entry.event.content.message.formatted_body); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 851 | pickedMentions = { ...pickedMentions, [roomId]: [...(pickedMentions[roomId] ?? []), ...existing] }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 852 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 853 | composer = body; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 854 | replyingTo = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 855 | composerEl?.focus(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 856 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 857 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 858 | function cancelEdit(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 859 | if (!editing) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 860 | composer = editing.stash; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 861 | editing = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 862 | composerEl?.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 863 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 864 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 865 | function submitEdit(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 866 | if (!editing) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 867 | const { roomId, eventId, original } = editing; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 868 | const body = composer.trim(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 869 | cancelEdit(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 870 | if (!body || body === original.trim()) return; |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 871 | editMessage(roomId, eventId, body, resolveMentions(body, pickedMentions[roomId] ?? []), $markdownEnabled).catch((e) => pushBanner(e instanceof Error ? e.message : 'Edit failed')); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 872 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 873 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 874 | function editLastOwn(): boolean { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 875 | for (let i = items.length - 1; i >= 0; i -= 1) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 876 | const entry = items[i]; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 877 | if (entry.kind !== 'event' || !entry.event.own) continue; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 878 | const ev = entry.event; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 879 | 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 | 880 | startEdit(ev.event_id, ev.content.message.body); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 881 | return true; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 882 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 883 | return false; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 884 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 885 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 886 | function startReply(target: ReplyReference): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 887 | if (editing) cancelEdit(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 888 | replyingTo = target; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 889 | composerEl?.focus(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 890 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 891 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 892 | function jumpTo(eventId: string): void { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 893 | const el = timelineEl?.querySelector<HTMLElement>(`[data-event="${CSS.escape(eventId)}"]`); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 894 | if (!el) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 895 | pushBanner('The original message is not loaded. Scroll up to load older messages.'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 896 | return; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 897 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 898 | stickToBottom = false; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 899 | el.scrollIntoView({ block: 'center', behavior: 'smooth' }); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 900 | el.classList.remove('flash'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 901 | void el.offsetWidth; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 902 | el.classList.add('flash'); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 903 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 904 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 905 | let typedText = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 906 | let typedRoom: string | null = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 907 | $: trackTypingInput(composer, $selectedRoomId, openReady); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 908 | function trackTypingInput(text: string, roomId: string | null, ready: Record<string, boolean>): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 909 | const edited = roomId === typedRoom && text !== typedText; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 910 | typedText = text; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 911 | typedRoom = roomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 912 | if (!roomId || !ready[roomId] || !text.trim()) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 913 | stopTyping(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 914 | } else if (edited && roomId !== peeking) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 915 | notifyTyping(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 916 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 917 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 918 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 919 | $: void trackPending($selectedRoomId, pendingItems); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 920 | async function trackPending(roomId: string | null, list: PendingMessage[]): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 921 | if (!roomId || list.length === 0) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 922 | if (roomId !== $selectedRoomId) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 923 | await tick(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 924 | if (stickToBottom) scrollToBottom(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 925 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 926 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 927 | function updateMentionQuery(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 928 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 929 | const next = composerEl && roomId ? mentionQueryAt(composerEl.value, composerEl.selectionStart ?? composerEl.value.length) : null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 930 | if (next && !mentionQuery && roomId && !$membersByRoom[roomId]) void loadMembers(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 931 | if (next?.start !== mentionQuery?.start) mentionIndex = 0; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 932 | mentionQuery = next; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 933 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 934 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 935 | async function pickMention(person: Person): Promise<void> { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 936 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 937 | if (!mentionQuery || !roomId || !composerEl) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 938 | const caret = composerEl.selectionStart ?? composer.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 939 | const inserted = `${person.name} `; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 940 | composer = composer.slice(0, mentionQuery.start) + inserted + composer.slice(caret); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 941 | const at = mentionQuery.start + inserted.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 942 | pickedMentions = { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 943 | ...pickedMentions, |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 944 | [roomId]: [...(pickedMentions[roomId] ?? []), { user_id: person.user_id, text: person.name }] |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 945 | }; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 946 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 947 | await tick(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 948 | composerEl.focus(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 949 | composerEl.setSelectionRange(at, at); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 950 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 951 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 952 | function onComposerKey(ev: KeyboardEvent): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 953 | if (mentionQuery && mentionCandidates.length > 0) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 954 | if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 955 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 956 | const step = ev.key === 'ArrowDown' ? 1 : -1; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 957 | mentionIndex = (mentionIndex + step + mentionCandidates.length) % mentionCandidates.length; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 958 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 959 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 960 | if ((ev.key === 'Enter' && !ev.shiftKey) || ev.key === 'Tab') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 961 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 962 | void pickMention(mentionCandidates[mentionIndex]); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 963 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 964 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 965 | if (ev.key === 'Escape') { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 966 | ev.stopPropagation(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 967 | mentionQuery = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 968 | return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 969 | } |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 970 | } |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 971 | if (ev.key === 'Enter' && !ev.shiftKey && !insideOpenFence(composer, composerEl?.selectionStart ?? composer.length)) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 972 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 973 | send(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 974 | } else if (ev.key === 'Escape' && editing) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 975 | ev.stopPropagation(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 976 | cancelEdit(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 977 | } else if (ev.key === 'Escape' && replyingTo) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 978 | ev.stopPropagation(); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 979 | replyingTo = null; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 980 | } else if (ev.key === 'ArrowUp' && !composer && !editing && editLastOwn()) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 981 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 982 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 983 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 984 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 985 | function pickFiles(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 986 | const roomId = $selectedRoomId; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 987 | if (!roomId || !openReady[roomId]) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 988 | fileInput?.click(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 989 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 990 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 991 | function onFileChosen(): void { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 992 | stageFiles(Array.from(fileInput?.files ?? [])); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 993 | if (fileInput) fileInput.value = ''; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 994 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 995 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 996 | function onComposerPaste(ev: ClipboardEvent): void { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 997 | const data = ev.clipboardData; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 998 | // 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 | 999 | if (!data || data.types.includes('text/plain')) return; |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1000 | const images = Array.from(data.files).filter((f) => f.type.startsWith('image/')); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1001 | if (images.length === 0) return; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1002 | ev.preventDefault(); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1003 | stageFiles(images); |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1004 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1005 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1006 | async function react(eventId: string, key: string, shortcode?: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1007 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1008 | if (!roomId || !eventId || reacting) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1009 | reacting = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1010 | try { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1011 | await reactToMessage(roomId, eventId, key, shortcode); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1012 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1013 | pushBanner(e instanceof Error ? e.message : 'Reaction failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1014 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1015 | reacting = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1016 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1017 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1018 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1019 | function previewLoader(roomId: string): (url: string) => void { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1020 | return (url) => requestLinkPreview(roomId, url); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1021 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1022 | |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1023 | async function changeEncryptedPreviews(enabled: boolean): Promise<void> { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1024 | try { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1025 | await saveUrlPreviewSettings({ encrypted_rooms: enabled }); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1026 | } catch (e) { |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1027 | pushBanner(e instanceof Error ? e.message : 'Could not save link preview setting'); |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1028 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1029 | } |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 1030 | |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1031 | async function changeQuickReactions(list: QuickReaction[]): Promise<void> { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1032 | try { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1033 | await saveQuickReactions(list); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1034 | } catch (e) { |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1035 | pushBanner(e instanceof Error ? e.message : 'Could not save quick reactions'); |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1036 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1037 | } |
544a170ead2c | atagen | 2026-10-20 11:47 UTC | 1038 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1039 | async function paginate(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1040 | const roomId = $selectedRoomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1041 | if (!roomId || paginateBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1042 | paginateBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1043 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1044 | await paginateRoom(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1045 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1046 | pushBanner(e instanceof Error ? e.message : 'Loading older messages failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1047 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1048 | paginateBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1049 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1050 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1051 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1052 | async function loadMembers(roomId: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1053 | if (membersFor === roomId && $membersLoading) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1054 | membersFor = roomId; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1055 | membersLoading.set(true); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1056 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1057 | const res = await getMembers(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1058 | membersByRoom.update((all) => ({ ...all, [roomId]: res.members })); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1059 | avatarByUser = { ...avatarByUser, ...avatarMap(res.members) }; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1060 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1061 | pushBanner(e instanceof Error ? e.message : 'Could not load members'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1062 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1063 | if (membersFor === roomId) membersLoading.set(false); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1064 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1065 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1066 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1067 | function avatarMap(list: MemberSummary[]): Record<string, string | null> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1068 | const next: Record<string, string | null> = {}; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1069 | for (const member of list) next[member.user_id] = member.avatar; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1070 | return next; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1071 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1072 | |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1073 | function peopleIn(list: TimelineItem[], roster: MemberSummary[]): Record<string, Person> { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1074 | const out: Record<string, Person> = {}; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1075 | for (const item of list) { |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1076 | if (item.kind !== 'event') continue; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1077 | const s = item.event.sender; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1078 | out[s.user_id] = { user_id: s.user_id, name: senderLabel(s), avatar: s.avatar }; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1079 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1080 | 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 | 1081 | return out; |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1082 | } |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1083 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1084 | function senderAvatarFor(userId: string): string | null { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1085 | return avatarByUser[userId] ?? null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1086 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1087 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1088 | function toggleMembers(): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1089 | membersOpen = !membersOpen; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1090 | if (membersOpen && $selectedRoomId) void loadMembers($selectedRoomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1091 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1092 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1093 | async function join(target: string): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1094 | const room = target.trim(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1095 | if (!room || joinBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1096 | joinBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1097 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1098 | const res = await joinRoom(room); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1099 | joinTarget = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1100 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1101 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1102 | await selectRoom(res.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1103 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1104 | pushBanner(e instanceof Error ? e.message : 'Join failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1105 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1106 | joinBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1107 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1108 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1109 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1110 | async function create(): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1111 | const name = createName.trim(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1112 | if (!name || createBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1113 | createBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1114 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1115 | const res = await createRoom(name, createTopic.trim() || undefined); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1116 | createName = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1117 | createTopic = ''; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1118 | dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1119 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1120 | await selectRoom(res.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1121 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1122 | pushBanner(e instanceof Error ? e.message : 'Create room failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1123 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1124 | createBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1125 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1126 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1127 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1128 | async function leave(roomId: string | null = $selectedRoomId): Promise<void> { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1129 | if (!roomId || leaveBusy) return; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1130 | leaveBusy = true; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1131 | stopTyping(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1132 | try { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1133 | await leaveRoom(roomId); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1134 | if ($selectedRoomId === roomId) selectedRoomId.set(null); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1135 | if (warmRooms.includes(roomId)) { |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1136 | forgetOpenRoom(roomId); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1137 | closeRoom(roomId).catch(() => undefined); |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1138 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1139 | await refreshRooms(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1140 | } catch (e) { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1141 | pushBanner(e instanceof Error ? e.message : 'Leave failed'); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1142 | } finally { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1143 | leaveBusy = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1144 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1145 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1146 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1147 | function connectionClass(state: string): string { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1148 | if (state === 'online') return 'dot-online'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1149 | if (state === 'connecting' || state === 'reconnecting') return 'dot-busy'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1150 | return 'dot-off'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1151 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1152 | |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1153 | let dragSpaceId: string | null = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1154 | let dropTarget: { id: string; after: boolean } | null = null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1155 | let menu: { items: MenuItem[]; x: number; y: number } | null = null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1156 | let userCard: { userId: string; x: number; y: number; confirm: 'kick' | 'ban' | null } | null = null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1157 | let levelsByRoom: Record<string, PowerLevels | null> = {}; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1158 | let peeking: string | null = null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1159 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1160 | $: roomLevels = $selectedRoomId ? (levelsByRoom[$selectedRoomId] ?? null) : null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1161 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1162 | function personFor(userId: string): Person { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1163 | return people[userId] ?? { user_id: userId, name: userId, avatar: avatarByUser[userId] ?? null }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1164 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1165 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1166 | function memberFor(userId: string): MemberSummary | null { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1167 | return members.find((m) => m.user_id === userId) ?? null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1168 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1169 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1170 | async function loadLevels(roomId: string): Promise<void> { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1171 | try { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1172 | const levels = parsePowerLevels(await runCommand({ op: 'power_levels', room_id: roomId })); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1173 | levelsByRoom = { ...levelsByRoom, [roomId]: levels }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1174 | } catch { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1175 | levelsByRoom = { ...levelsByRoom, [roomId]: levelsByRoom[roomId] ?? null }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1176 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1177 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1178 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1179 | async function openUser(userId: string, x: number, y: number, asMenu: boolean): Promise<void> { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1180 | const roomId = $selectedRoomId; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1181 | if (roomId && !(roomId in levelsByRoom)) await loadLevels(roomId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1182 | else if (roomId) void loadLevels(roomId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1183 | if (asMenu) menu = { items: userMenuItems(userId, x, y), x, y }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1184 | else userCard = { userId, x, y, confirm: null }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1185 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1186 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1187 | function copyText(text: string): void { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1188 | navigator.clipboard.writeText(text).catch(() => pushBanner('Could not copy to the clipboard')); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1189 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1190 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1191 | function userMenuItems(userId: string, x: number, y: number): MenuItem[] { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1192 | const own = userId === $sessionUser; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1193 | const member = memberFor(userId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1194 | const items: MenuItem[] = []; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1195 | if (!own) items.push({ label: 'Message', action: () => void userAction(userId, { kind: 'message' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1196 | items.push({ label: 'Mention', action: () => void userAction(userId, { kind: 'mention' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1197 | items.push({ label: 'Copy user ID', action: () => copyText(userId) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1198 | if (roomLevels && $sessionUser) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1199 | const can = allowed(roomLevels, $sessionUser, userId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1200 | const banned = member?.membership === 'Ban'; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1201 | if (can.setLevel && !own) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1202 | const muted = isMuted(roomLevels, userId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1203 | items.push({ label: muted ? 'Unmute' : 'Mute', action: () => void userAction(userId, { kind: muted ? 'unmute' : 'mute' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1204 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1205 | if (can.kick && !banned) items.push({ label: 'Kick…', danger: true, action: () => (userCard = { userId, x, y, confirm: 'kick' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1206 | if (can.ban && banned) items.push({ label: 'Unban', action: () => void userAction(userId, { kind: 'unban' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1207 | if (can.ban && !banned) items.push({ label: 'Ban…', danger: true, action: () => (userCard = { userId, x, y, confirm: 'ban' }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1208 | if (can.setLevel) items.push({ label: 'Power level…', action: () => (userCard = { userId, x, y, confirm: null }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1209 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1210 | if (!own) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1211 | const kind = member?.ignored ? 'unignore' : 'ignore'; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1212 | items.push({ label: member?.ignored ? 'Unignore' : 'Ignore', action: () => void userAction(userId, { kind }) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1213 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1214 | return items; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1215 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1216 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1217 | async function insertMention(person: Person): Promise<void> { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1218 | const roomId = $selectedRoomId; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1219 | if (!roomId) return; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1220 | const lead = composer && !/\s$/.test(composer) ? ' ' : ''; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1221 | composer = `${composer}${lead}${person.name} `; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1222 | pickedMentions = { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1223 | ...pickedMentions, |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1224 | [roomId]: [...(pickedMentions[roomId] ?? []), { user_id: person.user_id, text: person.name }] |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1225 | }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1226 | await tick(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1227 | composerEl?.focus(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1228 | composerEl?.setSelectionRange(composer.length, composer.length); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1229 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1230 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1231 | async function userAction(userId: string, action: UserAction): Promise<void> { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1232 | const roomId = $selectedRoomId; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1233 | try { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1234 | switch (action.kind) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1235 | case 'message': { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1236 | const res = (await runCommand({ op: 'direct', user_id: userId })) as { room_id: string }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1237 | await refreshRooms(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1238 | await selectRoom(res.room_id); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1239 | return; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1240 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1241 | case 'mention': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1242 | await insertMention(personFor(userId)); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1243 | return; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1244 | case 'ignore': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1245 | case 'unignore': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1246 | await runCommand({ op: action.kind, user_id: userId }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1247 | if (roomId) void loadMembers(roomId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1248 | return; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1249 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1250 | if (!roomId) return; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1251 | switch (action.kind) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1252 | case 'kick': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1253 | case 'ban': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1254 | await runCommand({ op: action.kind, room_id: roomId, user_id: userId, reason: action.reason }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1255 | break; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1256 | case 'unban': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1257 | await runCommand({ op: 'unban', room_id: roomId, user_id: userId, reason: null }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1258 | break; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1259 | case 'mute': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1260 | case 'unmute': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1261 | await runCommand({ op: 'mute', room_id: roomId, user_id: userId, muted: action.kind === 'mute' }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1262 | break; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1263 | case 'power': |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1264 | await runCommand({ op: 'set_power_level', room_id: roomId, user_id: userId, level: action.level }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1265 | break; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1266 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1267 | void loadLevels(roomId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1268 | void loadMembers(roomId); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1269 | } catch (e) { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1270 | pushBanner(e instanceof Error ? e.message : 'That action failed'); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1271 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1272 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1273 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1274 | function roomMenuItems(room: RoomSummary): MenuItem[] { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1275 | const items: MenuItem[] = room.space |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1276 | ? [{ label: 'Open', action: () => void selectSpace(room.room_id) }] |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1277 | : [ |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1278 | { label: 'Open', action: () => void selectRoom(room.room_id) }, |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1279 | { label: 'Peek', action: () => void selectRoom(room.room_id, true) } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1280 | ]; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1281 | items.push({ label: room.favourite ? 'Unpin' : room.space ? 'Pin to top' : 'Pin', action: () => void togglePin(room) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1282 | items.push({ label: 'Copy link', action: () => copyText(`https://matrix.to/#/${room.canonical_alias ?? room.room_id}`) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1283 | items.push({ label: 'Copy room ID', action: () => copyText(room.room_id) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1284 | if (room.membership === 'Joined') items.push({ label: 'Leave', danger: true, action: () => void leave(room.room_id) }); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1285 | return items; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1286 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1287 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1288 | function openRoomMenu(ev: MouseEvent, room: RoomSummary): void { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1289 | menu = { items: roomMenuItems(room), x: ev.clientX, y: ev.clientY }; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1290 | } |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1291 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1292 | function roomName(roomId: string): string { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1293 | return $rooms.find((r) => r.room_id === roomId)?.name ?? roomId; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1294 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1295 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1296 | async function sendSticker(roomId: string, pack: ImagePack, image: PackImage): Promise<void> { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1297 | stickersOpen = false; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1298 | stickToBottom = true; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1299 | try { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1300 | await runCommand({ op: 'send_sticker', room_id: roomId, pack_id: pack.id, shortcode: image.shortcode }); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1301 | if (peeking === roomId) stopPeeking(); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1302 | } catch (e) { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1303 | pushBanner(e instanceof Error ? e.message : 'Could not send the sticker'); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1304 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1305 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1306 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1307 | async function runClone(request: CommandRequest, failure: string): Promise<void> { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1308 | try { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1309 | const res = (await runCommand(request)) as { skipped?: string[] } | undefined; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1310 | if (res?.skipped?.length) pushBanner(`Couldn't copy ${res.skipped.map((s) => `:${s}:`).join(', ')}`); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1311 | } catch (e) { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1312 | pushBanner(e instanceof Error ? e.message : failure); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1313 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1314 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1315 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1316 | function openCloneImageMenu(pack: ImagePack, image: PackImage, x: number, y: number): void { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1317 | const items = editableChoices($imagePacks, roomName) |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1318 | .filter((c) => c.pack?.id !== pack.id) |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1319 | .map((choice) => ({ |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1320 | label: `Clone to ${choice.label}`, |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1321 | action: () => |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1322 | void runClone({ op: 'clone_pack_image', from_pack: pack.id, shortcode: image.shortcode, to: choice.target }, 'Could not clone the sticker') |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1323 | })); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1324 | menu = { items, x, y }; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1325 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1326 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1327 | function openClonePackMenu(pack: ImagePack, x: number, y: number): void { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1328 | const packRooms = $rooms.filter((r) => r.can_edit_packs && r.membership === 'Joined'); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1329 | const items = clonePackDestinations(pack, packRooms, roomName).map((d) => ({ |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1330 | label: d.label, |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1331 | action: () => void runClone({ op: 'clone_pack', from_pack: pack.id, to: d.target, display_name: d.display_name }, 'Could not clone the pack') |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1332 | })); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1333 | menu = { items, x, y }; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1334 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1335 | |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1336 | function openCloneStickerMenu(eventId: string, body: string, x: number, y: number): void { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1337 | const roomId = $selectedRoomId; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1338 | if (!roomId) return; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1339 | const items = editableChoices($imagePacks, roomName).map((choice) => ({ |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1340 | label: `Clone to ${choice.label}`, |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1341 | action: () => { |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1342 | const taken = new Set(choice.pack?.images.map((i) => i.shortcode) ?? []); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1343 | void runClone( |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1344 | { op: 'clone_sticker', room_id: roomId, event_id: eventId, to: choice.target, shortcode: shortcodeFor(body || 'sticker', taken) }, |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1345 | 'Could not clone the sticker' |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1346 | ); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1347 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1348 | })); |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1349 | menu = { items, x, y }; |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1350 | } |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 1351 | |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1352 | async function openMessageMenu(event: TimelineEvent, x: number, y: number): Promise<void> { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1353 | const roomId = $selectedRoomId; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1354 | const eventId = event.event_id; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1355 | if (!roomId || !eventId) return; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1356 | if (!(roomId in levelsByRoom)) await loadLevels(roomId); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1357 | const joined = selectedRoom?.membership === 'Joined'; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1358 | const content = event.content; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1359 | const items: MenuItem[] = []; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1360 | if (joined) { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1361 | items.push({ |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1362 | label: 'Reply', |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1363 | action: () => |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1364 | startReply({ |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1365 | event_id: eventId, |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1366 | details: { kind: 'Ready', sender: event.sender, content, timestamp_ms: event.timestamp_ms } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1367 | }) |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1368 | }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1369 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1370 | if (joined && event.own && event.editable && content.kind === 'Message' && content.message.kind === 'Text') { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1371 | const body = content.message.body; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1372 | items.push({ label: 'Edit', action: () => startEdit(eventId, body) }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1373 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1374 | if (content.kind === 'Message' && content.message.body) { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1375 | const body = content.message.body; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1376 | items.push({ label: 'Copy text', action: () => copyText(body) }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1377 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1378 | items.push({ label: 'Copy link', action: () => copyText(`https://matrix.to/#/${roomId}/${eventId}`) }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1379 | if (content.kind === 'Sticker') { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1380 | const body = content.body; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1381 | items.push({ label: 'Clone sticker…', action: () => openCloneStickerMenu(eventId, body, x, y) }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1382 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1383 | const me = $sessionUser; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1384 | if (joined && me && roomLevels && canRedact(roomLevels, me, event.sender.user_id) && content.kind !== 'Redacted') { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1385 | items.push({ |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1386 | label: 'Delete message…', |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1387 | danger: true, |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1388 | action: () => |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1389 | (menu = { |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1390 | x, |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1391 | y, |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1392 | items: [ |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1393 | { label: 'Delete', danger: true, action: () => void runClone({ op: 'redact', room_id: roomId, event_id: eventId, reason: null }, 'Could not delete the message') }, |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1394 | { label: 'Cancel', action: () => undefined } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1395 | ] |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1396 | }) |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1397 | }); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1398 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1399 | if (!event.own) items.push(...userMenuItems(event.sender.user_id, x, y)); |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1400 | menu = { items, x, y }; |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1401 | } |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 1402 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1403 | function stopPeeking(): void { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1404 | peeking = null; |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1405 | queueReadReceipt(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1406 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1407 | |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1408 | async function togglePin(room: RoomSummary): Promise<void> { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1409 | try { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1410 | await runCommand({ op: 'set_favourite', room_id: room.room_id, favourite: !room.favourite }); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1411 | } catch (e) { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1412 | pushBanner(e instanceof Error ? e.message : 'Could not change the pin'); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1413 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1414 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1415 | |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1416 | function startRailDrag(ev: DragEvent, id: string): void { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1417 | dragSpaceId = id; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1418 | if (ev.dataTransfer) { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1419 | ev.dataTransfer.effectAllowed = 'move'; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1420 | ev.dataTransfer.setData('text/plain', id); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1421 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1422 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1423 | |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1424 | function overRailSpace(ev: DragEvent, space: RoomSummary): void { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1425 | const dragged = orderedRail.find((s) => s.room_id === dragSpaceId); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1426 | if (!dragged || dragged.room_id === space.room_id || dragged.favourite !== space.favourite) return; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1427 | ev.preventDefault(); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1428 | const rect = (ev.currentTarget as HTMLElement).getBoundingClientRect(); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1429 | dropTarget = { id: space.room_id, after: ev.clientY > rect.top + rect.height / 2 }; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1430 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1431 | |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1432 | async function dropRailSpace(): Promise<void> { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1433 | const moved = dragSpaceId; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1434 | const target = dropTarget; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1435 | dragSpaceId = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1436 | dropTarget = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1437 | if (!moved || !target) return; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1438 | const ids = orderedRail.map((s) => s.room_id); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1439 | const before = target.after ? (ids[ids.indexOf(target.id) + 1] ?? null) : target.id; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1440 | const order = moveBefore(ids, moved, before === moved ? null : before); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1441 | if (order.join() === ids.join()) return; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1442 | railOverride = order; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1443 | try { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1444 | await runCommand({ op: 'reorder_spaces', order }); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1445 | } catch (e) { |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1446 | railOverride = null; |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1447 | pushBanner(e instanceof Error ? e.message : 'Could not reorder spaces'); |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1448 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1449 | } |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1450 | |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1451 | let roomMenuOpen = false; |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1452 | let roomMenuEl: HTMLDivElement | null = null; |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1453 | |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1454 | function roomMenuAction(action: () => void): void { |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1455 | roomMenuOpen = false; |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1456 | action(); |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1457 | } |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1458 | |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1459 | function closeRoomMenuOutside(ev: PointerEvent): void { |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1460 | if (roomMenuOpen && !roomMenuEl?.contains(ev.target as Node)) roomMenuOpen = false; |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1461 | } |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1462 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1463 | function onKeydown(ev: KeyboardEvent): void { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1464 | if (ev.key === 'Escape') { |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1465 | if (roomMenuOpen) roomMenuOpen = false; |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1466 | else if (dialog) dialog = null; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1467 | else if (membersOpen && window.innerWidth < 1100) membersOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1468 | else if (sidebarOpen) sidebarOpen = false; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1469 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1470 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1471 | </script> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1472 | |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1473 | <svelte:window |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1474 | on:keydown={onKeydown} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1475 | on:pointerdown={closeRoomMenuOutside} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1476 | on:pointerup={() => (draggingScrollbar = false)} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1477 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1478 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1479 | {#if !booted} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1480 | <div class="splash" role="status" aria-label="Loading Malice"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1481 | <div class="splash-mark" aria-hidden="true">M</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1482 | <p>Loading Malice…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1483 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1484 | {:else if $blocked} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1485 | <div class="splash" role="status" aria-label="Malice is open in another tab"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1486 | <div class="splash-mark" aria-hidden="true">M</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1487 | <p>Malice is open in another tab. Close this tab or use that one instead.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1488 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1489 | {:else if $sessionUser == null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1490 | <LoginPanel softLogout={$softLogout} on:done={(ev) => afterLogin(ev.detail)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1491 | {:else} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1492 | <div |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1493 | class="app" |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1494 | class:nav-folded={$navFolded && selectedRoom} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1495 | class:rail-folded={$railFolded && selectedRoom} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1496 | class:members-open={selectedRoom && membersOpen} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1497 | style:--msg-gap={`${$messageSpacing}px`} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1498 | style:--msg-line-height={$lineHeight} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 1499 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1500 | <header class="chat-head"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1501 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1502 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1503 | class="icon-btn only-mobile" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1504 | aria-label="Open room list" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1505 | on:click={() => (sidebarOpen = true)} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1506 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1507 | <span aria-hidden="true">☰</span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1508 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1509 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1510 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1511 | class="icon-btn only-desktop pane-toggle" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1512 | aria-pressed={!$railFolded} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1513 | aria-label={$railFolded ? 'Show spaces' : 'Hide spaces'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1514 | title={$railFolded ? 'Show spaces' : 'Hide spaces'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1515 | on:click={() => railFolded.update((v) => !v)} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1516 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1517 | <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1518 | <rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="2" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1519 | <circle cx="7" cy="9" r="1.4" fill="currentColor" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1520 | <circle cx="7" cy="13" r="1.4" fill="currentColor" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1521 | <circle cx="7" cy="17" r="1.4" fill="currentColor" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1522 | </svg> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1523 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1524 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1525 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1526 | class="icon-btn only-desktop pane-toggle" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1527 | aria-pressed={!$navFolded} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1528 | aria-label={$navFolded ? 'Show channels' : 'Hide channels'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1529 | title={$navFolded ? 'Show channels' : 'Hide channels'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1530 | on:click={() => navFolded.update((v) => !v)} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1531 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1532 | <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1533 | <rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="2" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1534 | <path d="M10 4v16" stroke="currentColor" stroke-width="2" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1535 | </svg> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1536 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1537 | {#if selectedRoom} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1538 | <div class="head-title"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1539 | <div class="head-room"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1540 | <MxcAvatar mxc={selectedRoom.avatar} label={selectedRoom.name} size={36} shape={selectedRoom.space ? 'rounded' : 'circle'} /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1541 | <div class="head-room-text"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1542 | <h1>{selectedRoom.name}</h1> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1543 | <div class="head-meta"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1544 | {#if selectedRoom.space} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1545 | <span class="pill">space</span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1546 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1547 | {#if selectedRoom.encrypted} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1548 | <span class="pill" title="End-to-end encrypted">🔒 encrypted</span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1549 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1550 | {#if selectedRoom.direct} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1551 | <span class="pill">direct</span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1552 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1553 | <span class="conn" title={`Sync state: ${$connection}`}> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1554 | <span class="dot {connectionClass($connection)}" aria-hidden="true"></span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1555 | {$connection} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1556 | </span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1557 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1558 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1559 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1560 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1561 | {:else} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1562 | <div class="head-title"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1563 | <div class="head-room"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1564 | {#if selectedSpace} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1565 | <MxcAvatar mxc={selectedSpace.avatar} label={selectedSpace.name} size={36} shape="rounded" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1566 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1567 | <div class="head-room-text"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1568 | <h1>{selectedSpace?.name ?? 'Home'}</h1> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1569 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1570 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1571 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1572 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1573 | <div class="head-actions"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1574 | {#if selectedRoom} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1575 | {#if peeking === selectedRoom.room_id} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1576 | <button type="button" class="icon-btn" aria-pressed="true" aria-label="Stop peeking" title="Stop peeking" on:click={stopPeeking}> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1577 | <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1578 | <path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12z" fill="none" stroke="currentColor" stroke-width="2" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1579 | <circle cx="12" cy="12" r="3" fill="currentColor" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1580 | </svg> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1581 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1582 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1583 | {#if selectedRoom.membership !== 'Joined'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1584 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1585 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1586 | class="primary-btn" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1587 | disabled={joinBusy} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1588 | on:click={() => void join(selectedRoom.room_id)} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1589 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1590 | {joinBusy ? 'Joining…' : 'Join'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1591 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1592 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1593 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1594 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1595 | class="icon-btn" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1596 | aria-pressed={membersOpen} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1597 | aria-label={membersOpen ? 'Hide members' : 'Show members'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1598 | title="Members" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1599 | on:click={toggleMembers} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1600 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1601 | <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1602 | <circle cx="12" cy="8" r="4" fill="none" stroke="currentColor" stroke-width="2" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1603 | <path d="M4 20c0-4 3.6-6 8-6s8 2 8 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1604 | </svg> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1605 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1606 | <div class="room-menu-wrap" bind:this={roomMenuEl}> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1607 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1608 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1609 | class="icon-btn" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1610 | aria-haspopup="menu" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1611 | aria-expanded={roomMenuOpen} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1612 | aria-label="Room options" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1613 | title="Room options" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1614 | on:click={() => (roomMenuOpen = !roomMenuOpen)} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1615 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1616 | <span aria-hidden="true">⋯</span> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1617 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1618 | {#if roomMenuOpen} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1619 | <div class="room-menu" role="menu"> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1620 | <button type="button" role="menuitem" on:click={() => roomMenuAction(() => (dialog = 'security'))}> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1621 | Security |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1622 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1623 | {#if selectedRoom.membership === 'Joined'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1624 | <button |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1625 | type="button" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1626 | role="menuitem" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1627 | class="danger" |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1628 | disabled={leaveBusy} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1629 | on:click={() => roomMenuAction(() => void leave())} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1630 | > |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1631 | {leaveBusy ? 'Leaving…' : 'Leave room'} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1632 | </button> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1633 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1634 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1635 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1636 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1637 | {/if} |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1638 | </div> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1639 | </header> |
1d319c602324 | atagen | 2026-10-24 09:14 UTC | 1640 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1641 | <nav class="rail" aria-label="Servers and spaces"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1642 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1643 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1644 | class="rail-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1645 | class:active={selectedSpaceId === null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1646 | title="Home — all channels" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1647 | aria-label="Home — all channels" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1648 | aria-pressed={selectedSpaceId === null} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1649 | on:click={() => void selectHome()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1650 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1651 | <span aria-hidden="true">⌂</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1652 | </button> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1653 | {#each [pinnedRail, otherRail] as group} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1654 | {#if group.length > 0} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1655 | <div class="rail-sep" aria-hidden="true"></div> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1656 | {/if} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1657 | {#each group as space (space.room_id)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1658 | <button |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1659 | type="button" |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1660 | class="rail-btn rail-space" |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1661 | class:active={railSelected === space.room_id} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1662 | class:drop-before={dropTarget?.id === space.room_id && !dropTarget.after} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1663 | class:drop-after={dropTarget?.id === space.room_id && dropTarget.after} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1664 | class:pinned={space.favourite} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1665 | title={space.name} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1666 | aria-label={`Show channels in space ${space.name}`} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1667 | aria-pressed={selectedSpaceId === space.room_id} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1668 | draggable="true" |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1669 | on:click={() => void selectSpace(space.room_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1670 | on:contextmenu|preventDefault={(ev) => openRoomMenu(ev, space)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1671 | on:dragstart={(ev) => startRailDrag(ev, space.room_id)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1672 | on:dragover={(ev) => overRailSpace(ev, space)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1673 | on:dragleave={() => dropTarget?.id === space.room_id && (dropTarget = null)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1674 | on:drop|preventDefault={() => void dropRailSpace()} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1675 | on:dragend={() => ((dragSpaceId = null), (dropTarget = null))} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1676 | > |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1677 | <MxcAvatar mxc={space.avatar} label={space.name} size={44} shape="rounded" /> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1678 | </button> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1679 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1680 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1681 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1682 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1683 | class="rail-btn rail-add" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1684 | aria-label="Join or create a room" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1685 | on:click={() => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1686 | dialog = 'join'; |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1687 | }} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1688 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1689 | <span aria-hidden="true">+</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1690 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1691 | </nav> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1692 | |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1693 | {#if menu} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1694 | <ContextMenu items={menu.items} x={menu.x} y={menu.y} onClose={() => (menu = null)} /> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1695 | {/if} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1696 | {#if userCard} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1697 | {#key userCard} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1698 | {@const cardUser = userCard.userId} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1699 | <UserCard |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1700 | person={personFor(cardUser)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1701 | member={memberFor(cardUser)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1702 | levels={roomLevels} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1703 | self={$sessionUser ?? null} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1704 | x={userCard.x} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1705 | y={userCard.y} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1706 | confirm={userCard.confirm} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1707 | onAction={(action) => void userAction(cardUser, action)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1708 | onClose={() => (userCard = null)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1709 | /> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1710 | {/key} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1711 | {/if} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1712 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1713 | <aside class="sidebar" class:open={sidebarOpen} aria-label="Rooms"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1714 | <div class="side-search"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1715 | <label class="visually-hidden" for="room-search">Search rooms</label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1716 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1717 | id="room-search" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1718 | type="search" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1719 | placeholder="Search rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1720 | bind:value={search} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1721 | autocomplete="off" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1722 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1723 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1724 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1725 | class="icon-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1726 | title="Refresh rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1727 | aria-label="Refresh rooms" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1728 | disabled={roomsLoading} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1729 | on:click={() => void refreshRooms()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1730 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1731 | <span aria-hidden="true">⟳</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1732 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1733 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1734 | <div class="side-scroll"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1735 | {#if selectedSpace} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1736 | <div class="space-context"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1737 | <MxcAvatar mxc={selectedSpace.avatar} label={selectedSpace.name} size={28} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1738 | <div class="space-context-text"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1739 | <strong>{selectedSpace.name}</strong> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1740 | </div> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1741 | {#if spaceParents.has(selectedSpace.room_id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1742 | {@const parentId = spaceParents.get(selectedSpace.room_id) ?? ''} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1743 | <button |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1744 | type="button" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1745 | class="icon-btn" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1746 | title="Up to the parent space" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1747 | aria-label="Up to the parent space" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1748 | on:click={() => void selectSpace(parentId)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1749 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1750 | <span aria-hidden="true">↑</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1751 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1752 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1753 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1754 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1755 | <div class="space-context"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1756 | <div class="space-context-text"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1757 | <strong>Home</strong> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1758 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1759 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1760 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1761 | {#if roomsLoading && $rooms.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1762 | <p class="side-note">Loading rooms…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1763 | {:else if $rooms.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1764 | <p class="side-note">No rooms yet</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1765 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1766 | <button type="button" on:click={() => (dialog = 'join')}>Join a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1767 | <button type="button" on:click={() => (dialog = 'create')}>Create one</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1768 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1769 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1770 | {#if selectedSpaceId && spaceChildrenLoading} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1771 | <p class="side-note">Loading channels…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1772 | {:else if selectedSpaceId && spaceChildrenError} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1773 | <p class="side-note" role="alert">{spaceChildrenError}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1774 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1775 | <button type="button" on:click={() => selectedSpaceId && void selectSpace(selectedSpaceId)}>Retry</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1776 | <button type="button" on:click={() => void selectHome()}>Back to Home</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1777 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1778 | {:else if selectedSpaceId && spaceChildIds && channelRooms.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1779 | <p class="side-note">No channels</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1780 | <div class="side-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1781 | <button type="button" on:click={() => void selectHome()}>Back to Home</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1782 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1783 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1784 | {#if invites.length > 0 && !selectedSpaceId} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1785 | <h2 class="side-h">Invites</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1786 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1787 | {#each invites as room (room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1788 | <li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1789 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1790 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1791 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1792 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1793 | on:click={() => void selectRoom(room.room_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1794 | on:contextmenu|preventDefault={(ev) => openRoomMenu(ev, room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1795 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1796 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1797 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1798 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1799 | class="invite-join" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1800 | role="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1801 | tabindex="0" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1802 | aria-label={`Join ${room.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1803 | on:click|stopPropagation={() => void join(room.room_id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1804 | on:keydown|stopPropagation={(ev) => { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1805 | if (ev.key === 'Enter' || ev.key === ' ') { |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1806 | ev.preventDefault(); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1807 | void join(room.room_id); |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1808 | } |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1809 | }} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1810 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1811 | Join |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1812 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1813 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1814 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1815 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1816 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1817 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1818 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1819 | {#if directRooms.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1820 | <h2 class="side-h">Direct messages</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1821 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1822 | {#each directRooms as room (room.room_id)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1823 | <li class="room-item"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1824 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1825 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1826 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1827 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1828 | aria-current={$selectedRoomId === room.room_id ? 'true' : undefined} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1829 | on:click={() => void selectRoom(room.room_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1830 | on:contextmenu|preventDefault={(ev) => openRoomMenu(ev, room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1831 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1832 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1833 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1834 | {#if roomUnread(room) > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1835 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1836 | class="badge" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1837 | class:mention={room.unread_mentions > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1838 | aria-label={`${roomUnread(room)} unread`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1839 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1840 | {roomUnread(room) > 99 ? '99+' : roomUnread(room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1841 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1842 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1843 | </button> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1844 | <PinButton pinned={room.favourite} label={room.name} onToggle={() => void togglePin(room)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1845 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1846 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1847 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1848 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1849 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1850 | {#if groupRooms.length > 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1851 | <h2 class="side-h">{selectedSpace ? 'Channels' : 'Rooms'}</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1852 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1853 | {#each groupRooms as room (room.room_id)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1854 | <li class="room-item"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1855 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1856 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1857 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1858 | class:active={$selectedRoomId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1859 | aria-current={$selectedRoomId === room.room_id ? 'true' : undefined} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1860 | on:click={() => void selectRoom(room.room_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1861 | on:contextmenu|preventDefault={(ev) => openRoomMenu(ev, room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1862 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1863 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1864 | <span class="room-hash" aria-hidden="true">#</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1865 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1866 | {#if roomUnread(room) > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1867 | <span |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1868 | class="badge" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1869 | class:mention={room.unread_mentions > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1870 | aria-label={`${roomUnread(room)} unread`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1871 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1872 | {roomUnread(room) > 99 ? '99+' : roomUnread(room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1873 | </span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1874 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1875 | </button> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1876 | <PinButton pinned={room.favourite} label={room.name} onToggle={() => void togglePin(room)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1877 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1878 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1879 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1880 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1881 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1882 | {#if spaceList.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 1883 | <h2 class="side-h">{selectedSpace ? 'Subspaces' : 'Spaces'}</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1884 | <ul class="room-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1885 | {#each spaceList as room (room.room_id)} |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1886 | <li class="room-item"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1887 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1888 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1889 | class="room-row" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1890 | class:active={selectedSpaceId === room.room_id} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1891 | aria-label={`Show channels in space ${room.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1892 | on:click={() => void selectSpace(room.room_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 1893 | on:contextmenu|preventDefault={(ev) => openRoomMenu(ev, room)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1894 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1895 | <MxcAvatar mxc={room.avatar} label={room.name} size={26} shape="rounded" /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1896 | <span class="room-hash" aria-hidden="true">◇</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1897 | <span class="room-name">{room.name}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1898 | </button> |
7cca1d5628d1 | atagen | 2026-10-24 07:36 UTC | 1899 | <PinButton pinned={room.favourite} label={room.name} onToggle={() => void togglePin(room)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1900 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1901 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1902 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1903 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1904 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1905 | {#if query && visibleRooms.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1906 | <p class="side-note">No rooms match “{search.trim()}”.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1907 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1908 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1909 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1910 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1911 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1912 | <div class="side-footer"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1913 | <div class="me" title={$sessionUser}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1914 | {#if profileMxc} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1915 | <MxcAvatar mxc={profileMxc} label={profile?.display_name ?? $sessionUser} size={30} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1916 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1917 | <span class="me-avatar" aria-hidden="true">{$sessionUser.slice(1, 2).toUpperCase()}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1918 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1919 | <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 | 1920 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1921 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1922 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1923 | class="icon-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1924 | title="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1925 | aria-label="Encryption and verification" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1926 | on:click={() => (dialog = 'security')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1927 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1928 | <span aria-hidden="true">🛡</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1929 | </button> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1930 | <button |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1931 | type="button" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1932 | class="icon-btn" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1933 | title="Settings" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1934 | aria-label="Settings" |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1935 | on:click={() => (dialog = 'settings')} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1936 | > |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1937 | <span aria-hidden="true">⚙</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 1938 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1939 | <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 | 1940 | <span aria-hidden="true">⏻</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1941 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1942 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1943 | </aside> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1944 | {#if sidebarOpen} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1945 | <button type="button" class="scrim" aria-label="Close room list" on:click={() => (sidebarOpen = false)}></button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1946 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1947 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1948 | <main class="chat"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1949 | {#if $banners.length > 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1950 | <div class="banners" aria-live="polite"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1951 | {#each $banners as banner (banner.id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1952 | <div class="banner" role="alert"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1953 | <span>{banner.message}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1954 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1955 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1956 | aria-label="Dismiss error" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1957 | on:click={() => dismissBanner(banner.id)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1958 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1959 | ✕ |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1960 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1961 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1962 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1963 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1964 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1965 | {#if !selectedRoom} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1966 | <div class="empty"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1967 | <div class="empty-mark" aria-hidden="true">◈</div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1968 | {#if selectedSpace} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1969 | <h1>{selectedSpace.name}</h1> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1970 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1971 | <h1>Welcome to Malice</h1> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1972 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1973 | <div class="empty-cta"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1974 | <button type="button" class="primary-btn" on:click={() => (dialog = 'join')}>Join a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1975 | <button type="button" class="ghost-btn" on:click={() => (dialog = 'create')}>Create a room</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1976 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1977 | <p class="conn-line"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1978 | <span class="dot {connectionClass($connection)}" aria-hidden="true"></span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1979 | {$connection} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1980 | </p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1981 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1982 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1983 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1984 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1985 | {#if recoveryBanner} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1986 | <div class="sec-banner warn" role="status"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1987 | <span>Message history is locked</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1988 | <button type="button" on:click={() => (dialog = 'security')}>Recover</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1989 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1990 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1991 | {#if verificationBanner} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1992 | <div class="sec-banner" role="status"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1993 | {#if verificationBanner.kind === 'Incoming'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1994 | <span>A device wants to verify this session</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1995 | <button type="button" on:click={() => (dialog = 'security')}>Review request</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1996 | {:else if verificationBanner.kind === 'Comparison'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 1997 | <span>Verification codes ready</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1998 | <button type="button" on:click={() => (dialog = 'security')}>Compare codes</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 1999 | {:else if verificationBanner.kind === 'Waiting'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2000 | <span>Verification started</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2001 | <button type="button" on:click={() => (dialog = 'security')}>Open verification</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2002 | {:else if verificationBanner.kind === 'Failed'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2003 | <span>Verification failed: {verificationBanner.message}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2004 | <button type="button" on:click={() => (dialog = 'security')}>Try again</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2005 | {:else if verificationBanner.kind === 'Cancelled'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2006 | <span>Verification cancelled: {verificationBanner.reason}</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2007 | <button type="button" on:click={() => (dialog = 'security')}>Open security</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2008 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2009 | <span>Verification in progress</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2010 | <button type="button" on:click={() => (dialog = 'security')}>Open security</button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2011 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2012 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2013 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2014 | {#if $selectedRoomId && openFailed[$selectedRoomId]} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2015 | <p class="conn-banner error" role="alert">{openFailed[$selectedRoomId]}</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2016 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2017 | |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2018 | <!-- svelte-ignore a11y_no_static_element_interactions --> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2019 | <div |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2020 | class="timeline" |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2021 | bind:this={timelineEl} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2022 | on:scroll={onTimelineScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2023 | on:wheel={noteUserScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2024 | on:touchmove={noteUserScroll} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2025 | on:keydown={onTimelineKey} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2026 | on:pointerdown={onTimelinePointer} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2027 | aria-label={`Messages in ${selectedRoom.name}`} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2028 | > |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2029 | <div class="timeline-inner" use:pinTimeline> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2030 | <div class="timeline-top"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2031 | {#if hasStart} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2032 | <p class="start-note">Beginning of history</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2033 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2034 | <button type="button" class="ghost-btn" disabled={paginateBusy} on:click={() => void paginate()}> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2035 | {paginateBusy ? 'Loading…' : 'Load older messages'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2036 | </button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2037 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2038 | </div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2039 | {#if grouped.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2040 | <p class="side-note timeline-empty">No messages yet</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2041 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2042 | {#each grouped as g (g.key)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2043 | {#if g.item.kind === 'day'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2044 | <div class="day-row"><span>{formatDay(g.item.timestamp_ms)}</span></div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2045 | {:else if g.item.kind === 'readMarker'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2046 | <div class="new-row"><span>New</span></div> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2047 | {:else if g.item.kind === 'start'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2048 | <p class="start-note">Beginning of history</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2049 | {:else if g.item.kind === 'unknown'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2050 | <p class="unknown-note">Unsupported event ({g.item.label})</p> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2051 | {:else} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2052 | <MessageRow |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2053 | itemId={g.key} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2054 | event={g.item.event} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2055 | showSender={g.showSender} |
787cdbbf0721 | atagen | 2026-10-24 06:50 UTC | 2056 | senderAvatar={senderAvatarFor(g.item.event.sender.user_id) ?? g.item.event.sender.avatar} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2057 | {reacting} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2058 | onReact={(eventId, key, shortcode) => void react(eventId, key, shortcode)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2059 | quickReactions={$quickReactions} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2060 | packs={roomPacks} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2061 | linkPreviews={$linkPreviews} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2062 | {loadPreview} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2063 | onQuickChange={(list) => void changeQuickReactions(list)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2064 | {people} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2065 | self={$sessionUser ?? null} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2066 | onUser={(userId, x, y, asMenu) => void openUser(userId, x, y, asMenu)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2067 | onCloneSticker={openCloneStickerMenu} |
0380cd8c765c | atagen | 2026-10-24 09:08 UTC | 2068 | onMore={(ev, x, y) => void openMessageMenu(ev, x, y)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2069 | onReply={selectedRoom.membership === 'Joined' ? startReply : null} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2070 | onJump={jumpTo} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2071 | onEdit={selectedRoom.membership === 'Joined' ? startEdit : null} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2072 | editing={editing !== null && editing.eventId === g.item.event.event_id} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2073 | showSent={g.item.event.item_id === lastSentId && pendingItems.length === 0} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2074 | /> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2075 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2076 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2077 | {/if} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2078 | {#each pendingItems as p, i (p.id)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2079 | <MessageRow |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2080 | itemId={`pending-${p.id}`} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2081 | event={pendingToEvent(p)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2082 | onJump={jumpTo} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2083 | showSender={pendingShowSender(i)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2084 | senderAvatar={senderAvatarFor($sessionUser ?? '')} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2085 | {reacting} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2086 | onReact={(eventId, key, shortcode) => void react(eventId, key, shortcode)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2087 | quickReactions={$quickReactions} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2088 | packs={roomPacks} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2089 | linkPreviews={$linkPreviews} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2090 | {loadPreview} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2091 | onQuickChange={(list) => void changeQuickReactions(list)} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2092 | /> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2093 | {#if p.status === 'failed'} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2094 | <div class="pending-actions"> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2095 | <span class="pending-error" role="alert">{p.error}</span> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2096 | <button type="button" class="ghost-btn" on:click={() => retryPending(p.id)}>Retry</button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2097 | <button type="button" class="ghost-btn danger" on:click={() => discardPending(p.id)}>Discard</button> |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2098 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2099 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2100 | {/each} |
705b1e1062c2 | atagen | 2026-10-23 09:05 UTC | 2101 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2102 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2103 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2104 | {#if selectedRoom.membership === 'Joined'} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2105 | {#if editing} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2106 | <div class="reply-bar" role="status"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2107 | <span class="reply-bar-label"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2108 | Editing message |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2109 | <span class="reply-bar-text">{editing.original}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2110 | </span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2111 | <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 | 2112 | <span aria-hidden="true">✕</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2113 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2114 | </div> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2115 | {:else if replyingTo && replyingTo.details.kind === 'Ready'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2116 | <div class="reply-bar" role="status"> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2117 | <span class="reply-bar-label"> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2118 | Replying to <strong>{senderLabel(replyingTo.details.sender)}</strong> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2119 | <span class="reply-bar-text">{contentPreview(replyingTo.details.content)}</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2120 | </span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2121 | <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 | 2122 | <span aria-hidden="true">✕</span> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2123 | </button> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2124 | </div> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2125 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2126 | {#if $selectedRoomId && currentStaged.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2127 | {@const stagedRoom = $selectedRoomId} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2128 | <ul class="staged" aria-label="Attachments to send"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2129 | {#each currentStaged as attachment (attachment.id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2130 | <li class="staged-item"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2131 | {#if attachment.previewUrl} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2132 | <img src={attachment.previewUrl} alt={attachment.file.name || 'Pasted image'} /> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2133 | {:else} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2134 | <span class="staged-name">{attachment.file.name || 'attachment'}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2135 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2136 | <button |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2137 | type="button" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2138 | class="icon-btn staged-remove" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2139 | aria-label={`Remove ${attachment.file.name || 'attachment'}`} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2140 | title="Remove" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2141 | on:click={() => unstage(stagedRoom, attachment.id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2142 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2143 | <span aria-hidden="true">✕</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2144 | </button> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2145 | </li> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2146 | {/each} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2147 | </ul> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2148 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2149 | <form class="composer" class:replying={replyingTo || editing} class:staging={currentStaged.length > 0} on:submit|preventDefault={() => send()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2150 | <label class="visually-hidden" for="composer">Message {selectedRoom.name}</label> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2151 | {#if mentionQuery && mentionCandidates.length > 0} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2152 | <ul class="mention-finder" role="listbox" aria-label="Mention someone"> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2153 | {#each mentionCandidates as person, i (person.user_id)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2154 | <li |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2155 | role="option" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2156 | aria-selected={i === mentionIndex} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2157 | class:active={i === mentionIndex} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2158 | on:pointerdown|preventDefault={() => void pickMention(person)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2159 | on:pointerenter={() => (mentionIndex = i)} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2160 | > |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2161 | <MxcAvatar mxc={person.avatar} label={person.name} size={22} /> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2162 | <span class="mention-name">{person.name}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2163 | <span class="mention-id">{person.user_id}</span> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2164 | </li> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2165 | {/each} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2166 | </ul> |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2167 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2168 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2169 | type="file" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2170 | multiple |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2171 | bind:this={fileInput} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2172 | class="visually-hidden" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2173 | aria-label="Attach a file" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2174 | on:change={() => void onFileChosen()} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2175 | /> |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2176 | <input |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2177 | type="file" |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2178 | accept="image/*" |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2179 | bind:this={avatarInput} |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2180 | class="visually-hidden" |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2181 | aria-label="Choose a new avatar" |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2182 | on:change={() => void onAvatarChosen()} |
e4c64c36f105 | atagen | 2026-10-24 07:09 UTC | 2183 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2184 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2185 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2186 | class="ghost-btn" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2187 | title="Attach an image or file" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2188 | aria-label="Attach an image or file" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2189 | disabled={!($selectedRoomId && openReady[$selectedRoomId])} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2190 | on:click={pickFiles} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2191 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2192 | {uploadBusy ? `Uploading ${uploadName ?? 'file'}…` : '📎'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2193 | </button> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2194 | <button |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2195 | type="button" |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2196 | class="icon-btn sticker-btn" |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2197 | title="Stickers" |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2198 | aria-label="Stickers" |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2199 | aria-expanded={stickersOpen} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2200 | disabled={!($selectedRoomId && openReady[$selectedRoomId])} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2201 | on:click={() => (stickersOpen = !stickersOpen)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2202 | > |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2203 | <svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2204 | <path d="M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v7l-7 7H6a2 2 0 0 1-2-2z" fill="none" stroke="currentColor" stroke-width="1.8" /> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2205 | <path d="M13 20v-5a2 2 0 0 1 2-2h5" fill="none" stroke="currentColor" stroke-width="1.8" /> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2206 | </svg> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2207 | </button> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2208 | {#if stickersOpen && $selectedRoomId} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2209 | {@const stickerRoom = $selectedRoomId} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2210 | <div class="sticker-pop"> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2211 | <StickerPicker |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2212 | packs={roomPacks} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2213 | {roomName} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2214 | onSend={(pack, image) => void sendSticker(stickerRoom, pack, image)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2215 | onClone={(pack, image, x, y) => openCloneImageMenu(pack, image, x, y)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2216 | onClonePack={(pack, x, y) => openClonePackMenu(pack, x, y)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2217 | onManage={() => ((stickersOpen = false), (dialog = 'packs'))} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2218 | onClose={() => (stickersOpen = false)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2219 | /> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2220 | </div> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2221 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2222 | <textarea |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2223 | id="composer" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2224 | bind:this={composerEl} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2225 | bind:value={composer} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2226 | rows="1" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2227 | placeholder={`Message ${selectedRoom.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2228 | aria-label={`Message ${selectedRoom.name}. Enter to send, Shift Enter for a new line.`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2229 | on:keydown={onComposerKey} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2230 | on:input={updateMentionQuery} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2231 | on:click={updateMentionQuery} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2232 | 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 | 2233 | on:blur={() => (mentionQuery = null)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2234 | on:paste={onComposerPaste} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2235 | disabled={!($selectedRoomId && openReady[$selectedRoomId])} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2236 | ></textarea> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2237 | <button |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2238 | type="button" |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2239 | class="icon-btn md-toggle" |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2240 | aria-pressed={$markdownEnabled} |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2241 | aria-label={$markdownEnabled ? 'Turn markdown off' : 'Turn markdown on'} |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2242 | title={$markdownEnabled ? 'Markdown on' : 'Markdown off'} |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2243 | on:click={() => markdownEnabled.update((v) => !v)} |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2244 | > |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2245 | <svg viewBox="0 0 24 16" width="22" height="15" aria-hidden="true"> |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2246 | <rect x="1" y="1" width="22" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="1.6" /> |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2247 | <path d="M4.5 11.5v-7l2.75 3 2.75-3v7M15.5 4.5v6.5M13 8.5l2.5 2.75L18 8.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" /> |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2248 | </svg> |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2249 | </button> |
6d6a4c34bdc1 | atagen | 2026-10-24 06:51 UTC | 2250 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2251 | type="submit" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2252 | class="primary-btn" |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2253 | disabled={(!composer.trim() && currentStaged.length === 0) || |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2254 | !($selectedRoomId && openReady[$selectedRoomId]) || |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2255 | (currentStaged.length > 0 && uploadBusy)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2256 | title={!($selectedRoomId && openReady[$selectedRoomId]) ? 'Waiting for the room to open' : 'Send message'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2257 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2258 | Send |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2259 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2260 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2261 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2262 | <div class="join-bar"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2263 | <p>You are not a member of this room.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2264 | <button type="button" class="primary-btn" disabled={joinBusy} on:click={() => void join(selectedRoom.room_id)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2265 | {joinBusy ? 'Joining…' : `Join ${selectedRoom.name}`} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2266 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2267 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2268 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2269 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2270 | </main> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2271 | |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 2272 | {#if selectedRoom} |
e15025643a20 | atagen | 2026-10-24 06:51 UTC | 2273 | <aside class="members" aria-hidden={!membersOpen} aria-label={`Members of ${selectedRoom.name}`}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2274 | <div class="members-head"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2275 | <h2>Members</h2> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2276 | <button type="button" class="icon-btn" aria-label="Close members" on:click={() => (membersOpen = false)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2277 | <span aria-hidden="true">✕</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2278 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2279 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2280 | {#if $membersLoading && members.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2281 | <p class="side-note">Loading members…</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2282 | {:else if members.length === 0} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2283 | <p class="side-note">No members loaded.</p> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2284 | {#if $selectedRoomId} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2285 | <button type="button" class="ghost-btn" on:click={() => $selectedRoomId && void loadMembers($selectedRoomId)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2286 | Retry |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2287 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2288 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2289 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2290 | <ul class="member-list"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2291 | {#each members as member (member.user_id)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2292 | <li> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2293 | <button |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2294 | type="button" |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2295 | class="member" |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2296 | on:click={(ev) => { |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2297 | const rect = ev.currentTarget.getBoundingClientRect(); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2298 | void openUser(member.user_id, rect.left - 308, rect.top, false); |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2299 | }} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2300 | on:contextmenu|preventDefault={(ev) => void openUser(member.user_id, ev.clientX, ev.clientY, true)} |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2301 | > |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2302 | <MxcAvatar mxc={member.avatar} label={member.display_name || member.name || member.user_id} size={30} /> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2303 | <span class="member-names"> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2304 | <span class="member-name">{member.display_name || member.name}</span> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2305 | <span class="member-id">{member.user_id}</span> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2306 | </span> |
d8624c214c04 | atagen | 2026-10-24 08:24 UTC | 2307 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2308 | </li> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2309 | {/each} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2310 | </ul> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2311 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2312 | </aside> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2313 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2314 | |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2315 | {#if dialog} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2316 | <div class="modal-wrap" role="presentation" on:click|self={() => (dialog = null)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2317 | {#if dialog === 'security'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2318 | <SecurityPanel |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2319 | encryptionState={$encryption} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2320 | verificationState={$verification} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2321 | onAction={() => void loadEncryption()} |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 2322 | encryptedPreviews={$urlPreviewSettings.encrypted_rooms} |
ecb8598b38af | atagen | 2026-10-22 09:19 UTC | 2323 | onEncryptedPreviews={(enabled) => void changeEncryptedPreviews(enabled)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2324 | on:close={() => (dialog = null)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2325 | /> |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2326 | {:else if dialog === 'settings'} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2327 | <SettingsPanel |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2328 | quick={$quickReactions} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2329 | packs={roomPacks} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2330 | onQuickChange={(list) => void changeQuickReactions(list)} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2331 | on:close={() => (dialog = null)} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2332 | on:packs={() => (dialog = 'packs')} |
df3c0f2b3da4 | atagen | 2026-10-22 13:07 UTC | 2333 | /> |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2334 | {:else if dialog === 'packs'} |
d095131eec0e | atagen | 2026-10-24 08:39 UTC | 2335 | <PackManager packs={$imagePacks} rooms={$rooms} onError={pushBanner} on:close={() => (dialog = null)} /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2336 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2337 | <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 | 2338 | <div class="modal-tabs" role="tablist" aria-label="Room actions"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2339 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2340 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2341 | role="tab" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2342 | aria-selected={dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2343 | class:active={dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2344 | on:click={() => (dialog = 'join')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2345 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2346 | Join |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2347 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2348 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2349 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2350 | role="tab" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2351 | aria-selected={dialog === 'create'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2352 | class:active={dialog === 'create'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2353 | on:click={() => (dialog = 'create')} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2354 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2355 | Create |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2356 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2357 | <button |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2358 | type="button" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2359 | class="icon-btn modal-x" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2360 | aria-label="Close dialog" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2361 | on:click={() => (dialog = null)} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2362 | > |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2363 | <span aria-hidden="true">✕</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2364 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2365 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2366 | {#if dialog === 'join'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2367 | <form on:submit|preventDefault={() => void join(joinTarget)}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2368 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2369 | <span>Room ID or alias</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2370 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2371 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2372 | placeholder="!room:example.org or #alias:example.org" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2373 | bind:value={joinTarget} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2374 | required |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2375 | disabled={joinBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2376 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2377 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2378 | <button type="submit" class="primary-btn wide" disabled={joinBusy || !joinTarget.trim()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2379 | {joinBusy ? 'Joining…' : 'Join room'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2380 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2381 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2382 | {:else} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2383 | <form on:submit|preventDefault={() => void create()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2384 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2385 | <span>Room name</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2386 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2387 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2388 | placeholder="Weekend plans" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2389 | bind:value={createName} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2390 | required |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2391 | disabled={createBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2392 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2393 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2394 | <label class="field"> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2395 | <span>Topic (optional)</span> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2396 | <input |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2397 | type="text" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2398 | placeholder="What should this room be about?" |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2399 | bind:value={createTopic} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2400 | disabled={createBusy} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2401 | /> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2402 | </label> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2403 | <button type="submit" class="primary-btn wide" disabled={createBusy || !createName.trim()}> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2404 | {createBusy ? 'Creating…' : 'Create room'} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2405 | </button> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2406 | </form> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2407 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2408 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2409 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2410 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2411 | {/if} |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2412 | </div> |
973f8fbdaf80 | atagen | 2026-09-28 09:10 UTC | 2413 | {/if} |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2414 | |
cf23dbf4e77c | atagen | 2026-10-23 06:36 UTC | 2415 | <ImageLightbox /> |