From 547724266111656c1858333ccac9f0ede9774685 Mon Sep 17 00:00:00 2001 From: litruv Date: Sun, 1 Nov 2026 20:31:21 +1100 Subject: [PATCH] Fix the mechanical lint groups and delete the unused bindings. [skip build] --- src/app/components/ServerConfigsLoader.tsx | 2 +- .../account-switcher/AccountSwitcher.tsx | 6 +- src/app/components/editor/Editor.tsx | 2 +- src/app/components/message/Reply.tsx | 3 +- src/app/components/title-bar/TitleBar.tsx | 8 -- .../user-profile/UserRoomProfile.tsx | 1 - .../call/IncomingCallNotification.tsx | 13 ---- src/app/features/call/useCall.ts | 9 +-- src/app/features/forum/ForumBoardDetail.tsx | 13 ++-- src/app/features/forum/ForumBoardView.tsx | 1 - src/app/features/forum/ForumSpaceShell.tsx | 13 ++-- src/app/features/room-nav/RoomNavItem.tsx | 2 +- src/app/features/room/RoomInput.tsx | 8 +- src/app/features/room/RoomViewHeader.tsx | 3 - .../emoji-confetti/emojiParticleProfiles.ts | 1 - src/app/features/settings/account/Profile.tsx | 16 ++-- .../notifications/SystemNotification.tsx | 8 +- src/app/features/settings/plugins/Plugins.tsx | 74 +++++++++---------- .../permissions/Permissions.tsx | 9 ++- src/app/pages/client/ClientNonUIFeatures.tsx | 1 - src/app/pages/client/home/Home.tsx | 2 +- src/app/utils/backgroundSync.ts | 6 +- src/app/utils/copyHandler.ts | 2 +- src/app/utils/viewTransitions.ts | 2 +- src/client/initMatrix.ts | 32 +------- src/util/cryptE2ERoomKeys.js | 19 +++-- 26 files changed, 95 insertions(+), 161 deletions(-) diff --git a/src/app/components/ServerConfigsLoader.tsx b/src/app/components/ServerConfigsLoader.tsx index 9bc6776b..80b87c9f 100644 --- a/src/app/components/ServerConfigsLoader.tsx +++ b/src/app/components/ServerConfigsLoader.tsx @@ -34,7 +34,7 @@ export function ServerConfigsLoader({ children }: ServerConfigsLoaderProps) { if (authMetadata) { try { validatedAuthMetadata = validateAuthMetadata(authMetadata); - } catch (e) { + } catch { // Server returned auth metadata but it failed validation — ignore silently. } } diff --git a/src/app/components/account-switcher/AccountSwitcher.tsx b/src/app/components/account-switcher/AccountSwitcher.tsx index 106fa5b1..6310052e 100644 --- a/src/app/components/account-switcher/AccountSwitcher.tsx +++ b/src/app/components/account-switcher/AccountSwitcher.tsx @@ -89,7 +89,7 @@ const deleteAllMatrixDatabases = async (): Promise => { // Delete each database with timeout const deletePromises = dbsToDelete.map(async (dbName) => { try { - const deletePromise = new Promise((resolve, reject) => { + const deletePromise = new Promise((resolve) => { const request = indexedDB.deleteDatabase(dbName); request.onsuccess = () => { console.log(`[AccountSwitcher] ✅ Deleted database: ${dbName}`); @@ -155,7 +155,9 @@ export function AccountSwitcher({ currentUserId }: AccountSwitcherProps) { await deleteAllMatrixDatabases(); // Small delay to ensure cleanup is complete - await new Promise((resolve) => setTimeout(resolve, 100)); + await new Promise((resolve) => { + setTimeout(resolve, 100); + }); // Reload the page to initialize the new session console.log('[AccountSwitcher] Reloading page...'); diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index 8a6b5087..8fc82a7c 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -131,7 +131,7 @@ export const CustomEditor = forwardRef( const firstChild = editor.children[0]; if (SlateElement.isElement(firstChild) && firstChild.type === BlockType.Paragraph) { - const [firstInline, secondInline] = firstChild.children; + const [, secondInline] = firstChild.children; // Don't decorate if we already have a CommandElement if (SlateElement.isElement(secondInline) && secondInline.type === BlockType.Command) { diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx index 566d9ce6..ba32cc29 100644 --- a/src/app/components/message/Reply.tsx +++ b/src/app/components/message/Reply.tsx @@ -3,7 +3,7 @@ import { EventTimelineSet, Room } from 'matrix-js-sdk'; import React, { MouseEventHandler, ReactNode, useCallback, useMemo } from 'react'; import classNames from 'classnames'; import { Icon, Icons } from '../icons'; -import { getMemberAvatarMxc, getMemberDisplayName, trimReplyFromBody } from '../../utils/room'; +import { getMemberDisplayName, trimReplyFromBody } from '../../utils/room'; import { getMxIdLocalPart } from '../../utils/matrix'; import { LinePlaceholder } from './placeholder'; import { randomNumberBetween } from '../../utils/common'; @@ -116,7 +116,6 @@ export const Reply = as<'div', ReplyProps>( const { body } = replyEvent?.getContent() ?? {}; const sender = replyEvent?.getSender(); - const senderAvatarMxc = sender ? getMemberAvatarMxc(room, sender) : undefined; const customUserColor = useOtherUserColor(sender ?? '', room); const powerTag = sender ? getMemberPowerTag?.(sender) : undefined; const tagColor = powerTag?.color ? accessibleTagColors?.get(powerTag.color) : undefined; diff --git a/src/app/components/title-bar/TitleBar.tsx b/src/app/components/title-bar/TitleBar.tsx index 1e206a27..6f27b863 100644 --- a/src/app/components/title-bar/TitleBar.tsx +++ b/src/app/components/title-bar/TitleBar.tsx @@ -600,14 +600,6 @@ export function TitleBar({ mx, children }: TitleBarProps) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [mx, roomId, roomToParents, mDirects, updateCounter]); - // Get room name (for backward compatibility, keeping simple name too) - const roomName = useMemo(() => { - if (!mx || !roomId) return null; - const room = mx.getRoom(roomId); - return room?.name || null; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [mx, roomId, updateCounter]); - // Get total unread count const totalUnread = useMemo(() => { if (!mx) return 0; diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx index 030b8755..5fbd8b5f 100644 --- a/src/app/components/user-profile/UserRoomProfile.tsx +++ b/src/app/components/user-profile/UserRoomProfile.tsx @@ -59,7 +59,6 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) { const membership = useMembership(room, userId); const server = getMxIdServer(userId); - const displayName = getMemberDisplayName(room, userId); const avatarMxc = getMemberAvatarMxc(room, userId); const avatarUrl = (avatarMxc && mxcUrlToHttp(mx, avatarMxc, useAuthentication)) ?? undefined; diff --git a/src/app/features/call/IncomingCallNotification.tsx b/src/app/features/call/IncomingCallNotification.tsx index dbb04167..220fd28c 100644 --- a/src/app/features/call/IncomingCallNotification.tsx +++ b/src/app/features/call/IncomingCallNotification.tsx @@ -23,19 +23,6 @@ interface IncomingCall { startTime: number; } -/** - * Checks if a room is a DM or small group (not a server/space room) - * @param room - The Matrix room to check - * @returns true if the room is a DM or small group - */ -function isDirectOrSmallGroup(room: Room): boolean { - if (room.isSpaceRoom()) { - return false; - } - const memberCount = room.getJoinedMemberCount(); - return memberCount <= 10; -} - /** * Gets active call members from a room who are NOT the current user * Also returns the earliest call start time diff --git a/src/app/features/call/useCall.ts b/src/app/features/call/useCall.ts index 433f8109..18d003f3 100644 --- a/src/app/features/call/useCall.ts +++ b/src/app/features/call/useCall.ts @@ -246,14 +246,7 @@ export function useCallService(): CallContextValue { * Hook to check if a call is active in a specific room */ export function useRoomCall(roomId: string) { - const { - activeCall, - startCall, - endCall, - callSupported: globalCallSupported, - callSupportLoading: globalCallSupportLoading, - callService, - } = useCall(); + const { activeCall, startCall, endCall, callService } = useCall(); const mx = useMatrixClient(); const [roomCallSupported, setRoomCallSupported] = useState(false); const [roomCallSupportLoading, setRoomCallSupportLoading] = useState(true); diff --git a/src/app/features/forum/ForumBoardDetail.tsx b/src/app/features/forum/ForumBoardDetail.tsx index e7b2788f..a1290dd9 100644 --- a/src/app/features/forum/ForumBoardDetail.tsx +++ b/src/app/features/forum/ForumBoardDetail.tsx @@ -54,14 +54,11 @@ export function ForumBoardDetail() { [threads, selectedPostId], ); - const handleReplySent = useCallback( - (_reply: ForumPost) => { - if (selectedPostId) { - recordThreadReply(selectedPostId); - } - }, - [recordThreadReply, selectedPostId], - ); + const handleReplySent = useCallback(() => { + if (selectedPostId) { + recordThreadReply(selectedPostId); + } + }, [recordThreadReply, selectedPostId]); const showThread = Boolean(selectedPostId && activeTopicRoom); const threadInitialPost = optimisticPost?.eventId === selectedPostId ? optimisticPost : null; diff --git a/src/app/features/forum/ForumBoardView.tsx b/src/app/features/forum/ForumBoardView.tsx index 1f53c6c9..59818978 100644 --- a/src/app/features/forum/ForumBoardView.tsx +++ b/src/app/features/forum/ForumBoardView.tsx @@ -42,7 +42,6 @@ export function ForumBoardView({ forumSpace, scope }: ForumBoardViewProps) { hasMorePosts, loadingMore, insertThreadFromNewPost, - recordThreadReply, } = useForumBoard(scope, forumSpace); const activeTopicRoom = activeTopicRoomId ? mx.getRoom(activeTopicRoomId) : null; diff --git a/src/app/features/forum/ForumSpaceShell.tsx b/src/app/features/forum/ForumSpaceShell.tsx index 3c36e9e1..1da5ee87 100644 --- a/src/app/features/forum/ForumSpaceShell.tsx +++ b/src/app/features/forum/ForumSpaceShell.tsx @@ -86,14 +86,11 @@ export function ForumSpaceShell() { [insertThreadFromNewPost, selectPost], ); - const handleReplySent = useCallback( - (_reply: ForumPost) => { - if (selectedPostId) { - recordThreadReply(selectedPostId); - } - }, - [recordThreadReply, selectedPostId], - ); + const handleReplySent = useCallback(() => { + if (selectedPostId) { + recordThreadReply(selectedPostId); + } + }, [recordThreadReply, selectedPostId]); const showThread = Boolean(selectedPostId && activeTopicRoom); diff --git a/src/app/features/room-nav/RoomNavItem.tsx b/src/app/features/room-nav/RoomNavItem.tsx index 9f907e45..d1a286f0 100644 --- a/src/app/features/room-nav/RoomNavItem.tsx +++ b/src/app/features/room-nav/RoomNavItem.tsx @@ -342,7 +342,7 @@ export function RoomNavItem({ const rootBody = rootEvent.getContent()?.body ?? ''; return rootBody; - } catch (error) { + } catch { return undefined; } }, [room]); diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 532af812..949b78bd 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -94,12 +94,7 @@ import { getImageMsgContent, getVideoMsgContent, } from './msgContent'; -import { - getMemberDisplayName, - getMentionContent, - trimReplyFromBody, - getMemberAvatarMxc, -} from '../../utils/room'; +import { getMemberDisplayName, getMentionContent, trimReplyFromBody } from '../../utils/room'; import { CommandAutocomplete } from './CommandAutocomplete'; import { Command, SHRUG, TABLEFLIP, UNFLIP, useCommands } from '../../hooks/useCommands'; import { pluginRegistry } from '../settings/plugins/PluginAPI'; @@ -183,7 +178,6 @@ export const RoomInput = forwardRef( const [msgDraft, setMsgDraft] = useAtom(roomIdToMsgDraftAtomFamily(roomId)); const [replyDraft, setReplyDraft] = useAtom(roomIdToReplyDraftAtomFamily(roomId)); const replyUserID = replyDraft?.userId; - const replyAvatarMxc = replyUserID ? getMemberAvatarMxc(room, replyUserID) : undefined; const powerLevelTags = usePowerLevelTags(room, powerLevels); const creatorsTag = useRoomCreatorsTag(); diff --git a/src/app/features/room/RoomViewHeader.tsx b/src/app/features/room/RoomViewHeader.tsx index 6eb93865..6d1b4cce 100644 --- a/src/app/features/room/RoomViewHeader.tsx +++ b/src/app/features/room/RoomViewHeader.tsx @@ -528,9 +528,6 @@ export function RoomViewHeader({ forumLayout = false }: RoomViewHeaderProps) { : undefined; const dmUserId = isDirect ? guessDmRoomUserId(room, mx.getSafeUserId()) : undefined; - const dmAvatarMxc = - (dmUserId ? room.getMember(dmUserId)?.getMxcAvatarUrl() : undefined) || - (isDirect ? avatarMxc : undefined); const dmCustomColor = useOtherUserColor(dmUserId ?? ''); const dmFolderTabColor = stationery && isDirect diff --git a/src/app/features/room/emoji-confetti/emojiParticleProfiles.ts b/src/app/features/room/emoji-confetti/emojiParticleProfiles.ts index d59195bc..239fffb0 100644 --- a/src/app/features/room/emoji-confetti/emojiParticleProfiles.ts +++ b/src/app/features/room/emoji-confetti/emojiParticleProfiles.ts @@ -495,6 +495,5 @@ export function sampleBurstAngle(profile: EmojiBurstProfile): number { } const bias = profile.angleBias ?? -Math.PI / 2; - const halfSpread = profile.angleSpread / 2; return bias + (Math.random() - 0.5) * profile.angleSpread * (0.6 + Math.random() * 0.4); } diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 39341106..16f1d4db 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -11,7 +11,6 @@ import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication'; import { useAuthenticatedMediaUrl } from '../../../hooks/useAuthenticatedMediaUrl'; import { getTextShadowColor } from '../../../utils/common'; import { useFilePicker } from '../../../hooks/useFilePicker'; -import { useObjectURL } from '../../../hooks/useObjectURL'; import { createUploadAtom, UploadSuccess } from '../../../state/upload'; import { CompactUploadCardRenderer } from '../../../components/upload-card'; import { useUserColorPreference } from '../../../hooks/useUserColor'; @@ -51,7 +50,7 @@ function ProfileBanner({ const userId = mx.getUserId()!; const profile = useUserProfile(userId); const presence = useUserPresence(userId); - const [userBanner, setUserBanner, loading] = useUserBanner(); + const [userBanner, setUserBanner] = useUserBanner(); const [collectibles, updateCollectible] = useUserCollectibles(); const [saving, setSaving] = useState(false); const [error, setError] = useState(); @@ -118,7 +117,7 @@ function ProfileBanner({ setColorError(undefined); try { await setColorPreference({ on_dark: localOnDark, on_light: localOnLight }); - } catch (e) { + } catch { setColorError('Failed to save colors. Your server may not support profile fields (MSC4133).'); } setSavingColor(false); @@ -131,7 +130,7 @@ function ProfileBanner({ await setColorPreference(undefined); setLocalOnDark('#ffd9f5'); setLocalOnLight('#440000'); - } catch (e) { + } catch { setColorError('Failed to remove colors'); } setSavingColor(false); @@ -157,7 +156,7 @@ function ProfileBanner({ setVerbError(undefined); try { await setTypingVerb(parsed); - } catch (e) { + } catch { setVerbError('Failed to save typing verb. Server may not support profile fields (MSC4133).'); } setSavingVerb(false); @@ -169,7 +168,7 @@ function ProfileBanner({ try { await setTypingVerb(undefined); setLocalVerb(''); - } catch (e) { + } catch { setVerbError('Failed to remove typing verb'); } setSavingVerb(false); @@ -330,7 +329,6 @@ function ProfileBanner({ }, [mx, useAuthentication, userBanner, refreshTrigger]); const [imageFile, setImageFile] = useState(); - const imageFileURL = useObjectURL(imageFile); const uploadAtom = useMemo(() => { if (imageFile) return createUploadAtom(imageFile); return undefined; @@ -414,7 +412,7 @@ function ProfileBanner({ await setUserBanner(undefined); // Sync user object to propagate changes throughout app await syncUserAvatar(); - } catch (e) { + } catch { setError('Failed to remove banner.'); } setSaving(false); @@ -1209,8 +1207,6 @@ function ProfileBanner({ } export function Profile() { - const mx = useMatrixClient(); - const userId = mx.getUserId()!; const avatarRef = useRef(null); const nameRef = useRef(null); diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx index 4123ba2d..84dc4559 100644 --- a/src/app/features/settings/notifications/SystemNotification.tsx +++ b/src/app/features/settings/notifications/SystemNotification.tsx @@ -315,7 +315,9 @@ function AndroidPushNotifications() { radii="300" variant="Secondary" disabled={isBusy} - onClick={() => void reset()} + onClick={() => { + reset(); + }} > {resetState.status === AsyncStatus.Loading ? ( @@ -334,7 +336,9 @@ function AndroidPushNotifications() { radii="300" variant="Secondary" disabled={isBusy} - onClick={() => void ping()} + onClick={() => { + ping(); + }} > {pingState.status === AsyncStatus.Loading ? ( diff --git a/src/app/features/settings/plugins/Plugins.tsx b/src/app/features/settings/plugins/Plugins.tsx index 51822705..9742c471 100644 --- a/src/app/features/settings/plugins/Plugins.tsx +++ b/src/app/features/settings/plugins/Plugins.tsx @@ -242,6 +242,43 @@ function SettingRenderer({ return null; } +function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) { + const [imageError, setImageError] = useState(false); + + return ( + + {!imageError ? ( + {name} setImageError(true)} + /> + ) : ( + + + {name.charAt(0).toUpperCase()} + + + )} + + ); +} + type PluginsProps = { requestClose: () => void; }; @@ -346,43 +383,6 @@ export function Plugins({ requestClose }: PluginsProps) { [installedPlugins], ); - function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) { - const [imageError, setImageError] = useState(false); - - return ( - - {!imageError ? ( - {name} setImageError(true)} - /> - ) : ( - - - {name.charAt(0).toUpperCase()} - - - )} - - ); - } - const filteredMarketplacePlugins = useMemo(() => { if (!searchQuery.trim()) return marketplacePlugins; return fuzzyFilter(marketplacePlugins, searchQuery, (plugin) => [ diff --git a/src/app/features/space-settings/permissions/Permissions.tsx b/src/app/features/space-settings/permissions/Permissions.tsx index 3fc9e866..7d14ecb5 100644 --- a/src/app/features/space-settings/permissions/Permissions.tsx +++ b/src/app/features/space-settings/permissions/Permissions.tsx @@ -200,7 +200,9 @@ export function Permissions({ requestClose }: PermissionsProps) { // Add a small delay to avoid rate limiting if (completed < total) { - await new Promise((resolve) => setTimeout(resolve, 100)); + await new Promise((resolve) => { + setTimeout(resolve, 100); + }); } } } catch (error) { @@ -297,7 +299,9 @@ export function Permissions({ requestClose }: PermissionsProps) { // Add a small delay to avoid rate limiting if (completed < total) { - await new Promise((resolve) => setTimeout(resolve, 100)); + await new Promise((resolve) => { + setTimeout(resolve, 100); + }); } } } catch (error) { @@ -325,7 +329,6 @@ export function Permissions({ requestClose }: PermissionsProps) { return setPowerEditor(false)} />; } - const hasSyncableChildren = allChildren.length > 0; const isSyncing = syncState.status === AsyncStatus.Loading; const syncSuccess = syncState.status === AsyncStatus.Success; const syncError = syncState.status === AsyncStatus.Error; diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index c2d78804..99776117 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -235,7 +235,6 @@ function MessageNotifications() { const notify = useCallback( ({ - roomName, roomAvatar, username, messageBody, diff --git a/src/app/pages/client/home/Home.tsx b/src/app/pages/client/home/Home.tsx index 190b76d9..5e3f4414 100644 --- a/src/app/pages/client/home/Home.tsx +++ b/src/app/pages/client/home/Home.tsx @@ -384,7 +384,7 @@ export function Home() { {open && ( setOpen(false)} - onOpen={(roomIdOrAlias, viaServers, eventId) => { + onOpen={(roomIdOrAlias, viaServers) => { setOpen(false); const searchParams: _RoomSearchParams = { viaServers: viaServers?.join(','), diff --git a/src/app/utils/backgroundSync.ts b/src/app/utils/backgroundSync.ts index 829f505a..9a28096b 100644 --- a/src/app/utils/backgroundSync.ts +++ b/src/app/utils/backgroundSync.ts @@ -410,7 +410,7 @@ class AndroidUnifiedPushManager { if (!client) return; const { registerPlugin } = await loadCapacitorCore(); - const MatrixBackgroundSync = registerPlugin('MatrixBackgroundSync'); + registerPlugin('MatrixBackgroundSync'); const status = await this.safeGetStatus(); console.log('[BackgroundSync] Native status before pusher sync:', status); @@ -574,7 +574,9 @@ export const requestResetPushRegistration = async (): Promise<{ success: boolean // Endpoint arrives asynchronously from the distributor after register(). for (let i = 0; i < 40; i += 1) { - await new Promise((resolve) => setTimeout(resolve, 250)); + await new Promise((resolve) => { + setTimeout(resolve, 250); + }); const status = await getBackgroundSyncStatus(); if (status?.registered && status.endpoint) { return { success: true }; diff --git a/src/app/utils/copyHandler.ts b/src/app/utils/copyHandler.ts index f88f8d25..1071e4ba 100644 --- a/src/app/utils/copyHandler.ts +++ b/src/app/utils/copyHandler.ts @@ -58,7 +58,7 @@ export const setupCopyHandler = ( } textNode = walker.nextNode(); } - } catch (e) { + } catch { // Fallback: check if selection contains the content element isSelected = selection.containsNode(contentEl, true); } diff --git a/src/app/utils/viewTransitions.ts b/src/app/utils/viewTransitions.ts index bfd5afbc..7c5efd73 100644 --- a/src/app/utils/viewTransitions.ts +++ b/src/app/utils/viewTransitions.ts @@ -31,7 +31,7 @@ export const withViewTransition = async (callback: () => void | Promise): }); await transition.finished; - } catch (error) { + } catch { // Fallback if transition fails await callback(); } diff --git a/src/client/initMatrix.ts b/src/client/initMatrix.ts index 4ead03e5..0b14a952 100644 --- a/src/client/initMatrix.ts +++ b/src/client/initMatrix.ts @@ -131,33 +131,6 @@ const getAllIndexedDBNames = async (): Promise => { return []; }; -const deleteAllMatrixDatabases = async (): Promise => { - console.log('[initMatrix] Clearing all Matrix-related IndexedDB databases...'); - - const dbNames = await getAllIndexedDBNames(); - console.log('[initMatrix] Found databases:', dbNames); - - // Delete all Matrix-related databases (with matrix-js-sdk: prefix) - const matrixDbNames = dbNames.filter( - (name) => - name.startsWith('matrix-js-sdk:') || - name.startsWith('crypto@') || - name.startsWith('sync@') || - name === 'crypto-store' || - name === 'web-sync-store', - ); - - console.log('[initMatrix] Deleting Matrix databases:', matrixDbNames); - - for (const dbName of matrixDbNames) { - try { - await deleteIndexedDB(dbName); - } catch (error) { - console.error(`[initMatrix] Failed to delete ${dbName}:`, error); - } - } -}; - /** * Delete the Rust crypto database to fix one-time key conflicts. * This happens when the local crypto state has keys that conflict with server state. @@ -284,7 +257,7 @@ export const initClient = async (session: Session): Promise => { localStorage.removeItem('cinny_fix_key_conflict'); console.log('[initMatrix] ✅ Crypto database cleared'); } - } catch (e) { + } catch { localStorage.removeItem('cinny_fix_key_conflict'); } } @@ -450,9 +423,6 @@ export const logoutClient = async (mx: MatrixClient) => { } await mx.clearStores(); - // Import sessions management - const { sessionsAtom, currentSessionAtom, getSessionByUserId, getCurrentSession } = - await import('../app/state/sessions'); const { getLocalStorageItem, setLocalStorageItem } = await import('../app/state/utils/atomWithLocalStorage'); diff --git a/src/util/cryptE2ERoomKeys.js b/src/util/cryptE2ERoomKeys.js index 9087b7e2..7da95ab4 100644 --- a/src/util/cryptE2ERoomKeys.js +++ b/src/util/cryptE2ERoomKeys.js @@ -138,7 +138,7 @@ function unpackMegolmKeyFile(data) { // look for the start line let lineStart = 0; - while (1) { + for (;;) { const lineEnd = fileStr.indexOf('\n', lineStart); if (lineEnd < 0) { throw new Error('Header line not found'); @@ -156,7 +156,7 @@ function unpackMegolmKeyFile(data) { const dataStart = lineStart; // look for the end line - while (1) { + for (;;) { const lineEnd = fileStr.indexOf('\n', lineStart); const line = fileStr.slice(lineStart, lineEnd < 0 ? undefined : lineEnd).trim(); if (line === TRAILER_LINE) { @@ -304,15 +304,20 @@ export async function encryptMegolmKeyFile(data, password, options) { const bodyLength = 1 + salt.length + iv.length + 4 + cipherArray.length + 32; const resultBuffer = new Uint8Array(bodyLength); let idx = 0; - resultBuffer[idx++] = 1; // version + resultBuffer[idx] = 1; // version + idx += 1; resultBuffer.set(salt, idx); idx += salt.length; resultBuffer.set(iv, idx); idx += iv.length; - resultBuffer[idx++] = kdfRounds >> 24; - resultBuffer[idx++] = (kdfRounds >> 16) & 0xff; - resultBuffer[idx++] = (kdfRounds >> 8) & 0xff; - resultBuffer[idx++] = kdfRounds & 0xff; + resultBuffer[idx] = kdfRounds >> 24; + idx += 1; + resultBuffer[idx] = (kdfRounds >> 16) & 0xff; + idx += 1; + resultBuffer[idx] = (kdfRounds >> 8) & 0xff; + idx += 1; + resultBuffer[idx] = kdfRounds & 0xff; + idx += 1; resultBuffer.set(cipherArray, idx); idx += cipherArray.length;