Fix the mechanical lint groups and delete the unused bindings. [skip build]
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ const deleteAllMatrixDatabases = async (): Promise<void> => {
|
||||
// Delete each database with timeout
|
||||
const deletePromises = dbsToDelete.map(async (dbName) => {
|
||||
try {
|
||||
const deletePromise = new Promise<void>((resolve, reject) => {
|
||||
const deletePromise = new Promise<void>((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...');
|
||||
|
||||
@@ -131,7 +131,7 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -42,7 +42,6 @@ export function ForumBoardView({ forumSpace, scope }: ForumBoardViewProps) {
|
||||
hasMorePosts,
|
||||
loadingMore,
|
||||
insertThreadFromNewPost,
|
||||
recordThreadReply,
|
||||
} = useForumBoard(scope, forumSpace);
|
||||
|
||||
const activeTopicRoom = activeTopicRoomId ? mx.getRoom(activeTopicRoomId) : null;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ export function RoomNavItem({
|
||||
|
||||
const rootBody = rootEvent.getContent()?.body ?? '';
|
||||
return rootBody;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}, [room]);
|
||||
|
||||
@@ -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<HTMLDivElement, RoomInputProps>(
|
||||
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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<string>();
|
||||
@@ -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<File>();
|
||||
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<HTMLDivElement>(null);
|
||||
const nameRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
||||
@@ -315,7 +315,9 @@ function AndroidPushNotifications() {
|
||||
radii="300"
|
||||
variant="Secondary"
|
||||
disabled={isBusy}
|
||||
onClick={() => void reset()}
|
||||
onClick={() => {
|
||||
reset();
|
||||
}}
|
||||
>
|
||||
{resetState.status === AsyncStatus.Loading ? (
|
||||
<Spinner variant="Secondary" size="200" />
|
||||
@@ -334,7 +336,9 @@ function AndroidPushNotifications() {
|
||||
radii="300"
|
||||
variant="Secondary"
|
||||
disabled={isBusy}
|
||||
onClick={() => void ping()}
|
||||
onClick={() => {
|
||||
ping();
|
||||
}}
|
||||
>
|
||||
{pingState.status === AsyncStatus.Loading ? (
|
||||
<Spinner variant="Secondary" size="200" />
|
||||
|
||||
@@ -242,6 +242,43 @@ function SettingRenderer({
|
||||
return null;
|
||||
}
|
||||
|
||||
function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) {
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
return (
|
||||
<Avatar size="500" radii="400">
|
||||
{!imageError ? (
|
||||
<img
|
||||
src={thumbnail}
|
||||
alt={name}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
onError={() => setImageError(true)}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
justifyContent="Center"
|
||||
alignItems="Center"
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
background: `linear-gradient(135deg, ${color.Secondary.Container} 0%, ${color.Primary.Container} 100%)`,
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
>
|
||||
<Text size="H3" priority="300" style={{ fontWeight: 600 }}>
|
||||
{name.charAt(0).toUpperCase()}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Avatar>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<Avatar size="500" radii="400">
|
||||
{!imageError ? (
|
||||
<img
|
||||
src={thumbnail}
|
||||
alt={name}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
onError={() => setImageError(true)}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
justifyContent="Center"
|
||||
alignItems="Center"
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
background: `linear-gradient(135deg, ${color.Secondary.Container} 0%, ${color.Primary.Container} 100%)`,
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
>
|
||||
<Text size="H3" priority="300" style={{ fontWeight: 600 }}>
|
||||
{name.charAt(0).toUpperCase()}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Avatar>
|
||||
);
|
||||
}
|
||||
|
||||
const filteredMarketplacePlugins = useMemo(() => {
|
||||
if (!searchQuery.trim()) return marketplacePlugins;
|
||||
return fuzzyFilter(marketplacePlugins, searchQuery, (plugin) => [
|
||||
|
||||
@@ -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 <PowersEditor powerLevels={powerLevels} requestClose={() => 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;
|
||||
|
||||
@@ -235,7 +235,6 @@ function MessageNotifications() {
|
||||
|
||||
const notify = useCallback(
|
||||
({
|
||||
roomName,
|
||||
roomAvatar,
|
||||
username,
|
||||
messageBody,
|
||||
|
||||
@@ -384,7 +384,7 @@ export function Home() {
|
||||
{open && (
|
||||
<JoinAddressPrompt
|
||||
onCancel={() => setOpen(false)}
|
||||
onOpen={(roomIdOrAlias, viaServers, eventId) => {
|
||||
onOpen={(roomIdOrAlias, viaServers) => {
|
||||
setOpen(false);
|
||||
const searchParams: _RoomSearchParams = {
|
||||
viaServers: viaServers?.join(','),
|
||||
|
||||
@@ -410,7 +410,7 @@ class AndroidUnifiedPushManager {
|
||||
if (!client) return;
|
||||
|
||||
const { registerPlugin } = await loadCapacitorCore();
|
||||
const MatrixBackgroundSync = registerPlugin<MatrixBackgroundSyncPlugin>('MatrixBackgroundSync');
|
||||
registerPlugin<MatrixBackgroundSyncPlugin>('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 };
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export const withViewTransition = async (callback: () => void | Promise<void>):
|
||||
});
|
||||
|
||||
await transition.finished;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// Fallback if transition fails
|
||||
await callback();
|
||||
}
|
||||
|
||||
@@ -131,33 +131,6 @@ const getAllIndexedDBNames = async (): Promise<string[]> => {
|
||||
return [];
|
||||
};
|
||||
|
||||
const deleteAllMatrixDatabases = async (): Promise<void> => {
|
||||
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<MatrixClient> => {
|
||||
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');
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user