Type the crypto, settings, and component any sites. [skip build]
This commit is contained in:
1 parent
6c8a085ae1
commit
9d17b14a9e
26 files changed
+68
-49
No files matched your search
@@ -30,7 +30,7 @@ function makeUIAAction<T>(
|
|||||||
authData: IAuthData,
|
authData: IAuthData,
|
||||||
performAction: PerformAction<T>,
|
performAction: PerformAction<T>,
|
||||||
resolve: (data: T) => void,
|
resolve: (data: T) => void,
|
||||||
reject: (error?: any) => void,
|
reject: (error?: unknown) => void,
|
||||||
): UIAAction<T> {
|
): UIAAction<T> {
|
||||||
const action: UIAAction<T> = {
|
const action: UIAAction<T> = {
|
||||||
authData,
|
authData,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { FormEventHandler, useCallback } from 'react';
|
import React, { FormEventHandler, useCallback } from 'react';
|
||||||
import { Box, Text, Button, Spinner, color } from 'folds';
|
import { Box, Text, Button, Spinner, color } from 'folds';
|
||||||
import { decodeRecoveryKey, deriveRecoveryKeyFromPassphrase } from 'matrix-js-sdk/lib/crypto-api';
|
import { decodeRecoveryKey, deriveRecoveryKeyFromPassphrase } from 'matrix-js-sdk/lib/crypto-api';
|
||||||
|
import { SecretStorageKeyDescriptionAesV1 } from 'matrix-js-sdk/lib/secret-storage';
|
||||||
import { PasswordInput } from './password-input';
|
import { PasswordInput } from './password-input';
|
||||||
import {
|
import {
|
||||||
SecretStorageKeyContent,
|
SecretStorageKeyContent,
|
||||||
@@ -39,7 +40,10 @@ export function SecretStorageRecoveryPassphrase({
|
|||||||
bits,
|
bits,
|
||||||
);
|
);
|
||||||
|
|
||||||
const match = await mx.secretStorage.checkKey(decodedRecoveryKey, keyContent as any);
|
const match = await mx.secretStorage.checkKey(
|
||||||
|
decodedRecoveryKey,
|
||||||
|
keyContent as SecretStorageKeyDescriptionAesV1,
|
||||||
|
);
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw new Error('Invalid recovery passphrase.');
|
throw new Error('Invalid recovery passphrase.');
|
||||||
@@ -131,7 +135,10 @@ export function SecretStorageRecoveryKey({
|
|||||||
async (recoveryKey) => {
|
async (recoveryKey) => {
|
||||||
const decodedRecoveryKey = decodeRecoveryKey(recoveryKey);
|
const decodedRecoveryKey = decodeRecoveryKey(recoveryKey);
|
||||||
|
|
||||||
const match = await mx.secretStorage.checkKey(decodedRecoveryKey, keyContent as any);
|
const match = await mx.secretStorage.checkKey(
|
||||||
|
decodedRecoveryKey,
|
||||||
|
keyContent as SecretStorageKeyDescriptionAesV1,
|
||||||
|
);
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw new Error('Invalid recovery key.');
|
throw new Error('Invalid recovery key.');
|
||||||
|
|||||||
@@ -68,12 +68,12 @@ const deleteAllMatrixDatabases = async (): Promise<void> => {
|
|||||||
// Try to get all databases if the API is available
|
// Try to get all databases if the API is available
|
||||||
try {
|
try {
|
||||||
if ('databases' in indexedDB) {
|
if ('databases' in indexedDB) {
|
||||||
const allDbs = await (indexedDB as any).databases();
|
const allDbs = await indexedDB.databases();
|
||||||
const matrixDbs = allDbs
|
const matrixDbs = allDbs
|
||||||
.map((db: any) => db.name)
|
.map((db) => db.name)
|
||||||
.filter(
|
.filter(
|
||||||
(name: string) =>
|
(name): name is string =>
|
||||||
name &&
|
typeof name === 'string' &&
|
||||||
(name.startsWith('matrix-js-sdk') ||
|
(name.startsWith('matrix-js-sdk') ||
|
||||||
name.includes('@@') ||
|
name.includes('@@') ||
|
||||||
name.startsWith('sync@@') ||
|
name.startsWith('sync@@') ||
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
EventType,
|
||||||
ICreateRoomOpts,
|
ICreateRoomOpts,
|
||||||
ICreateRoomStateEvent,
|
ICreateRoomStateEvent,
|
||||||
JoinRule,
|
JoinRule,
|
||||||
@@ -6,7 +7,7 @@ import {
|
|||||||
RestrictedAllowType,
|
RestrictedAllowType,
|
||||||
Room,
|
Room,
|
||||||
} from 'matrix-js-sdk';
|
} from 'matrix-js-sdk';
|
||||||
import { RoomJoinRulesEventContent } from 'matrix-js-sdk/lib/types';
|
import { RoomJoinRulesEventContent, SpaceChildEventContent } from 'matrix-js-sdk/lib/types';
|
||||||
import { CreateRoomKind } from './CreateRoomKindSelector';
|
import { CreateRoomKind } from './CreateRoomKindSelector';
|
||||||
import { RoomType, StateEvent } from '../../../types/matrix/room';
|
import { RoomType, StateEvent } from '../../../types/matrix/room';
|
||||||
import { getViaServers } from '../../plugins/via-servers';
|
import { getViaServers } from '../../plugins/via-servers';
|
||||||
@@ -17,7 +18,7 @@ export const createRoomCreationContent = (
|
|||||||
allowFederation: boolean,
|
allowFederation: boolean,
|
||||||
additionalCreators: string[] | undefined,
|
additionalCreators: string[] | undefined,
|
||||||
): object => {
|
): object => {
|
||||||
const content: Record<string, any> = {};
|
const content: Record<string, unknown> = {};
|
||||||
if (typeof type === 'string') {
|
if (typeof type === 'string') {
|
||||||
content.type = type;
|
content.type = type;
|
||||||
}
|
}
|
||||||
@@ -144,12 +145,12 @@ export const createRoom = async (mx: MatrixClient, data: CreateRoomData): Promis
|
|||||||
if (data.parent) {
|
if (data.parent) {
|
||||||
await mx.sendStateEvent(
|
await mx.sendStateEvent(
|
||||||
data.parent.roomId,
|
data.parent.roomId,
|
||||||
StateEvent.SpaceChild as any,
|
EventType.SpaceChild,
|
||||||
{
|
{
|
||||||
auto_join: false,
|
auto_join: false,
|
||||||
suggested: false,
|
suggested: false,
|
||||||
via: [getMxIdServer(mx.getUserId() ?? '') ?? ''],
|
via: [getMxIdServer(mx.getUserId() ?? '') ?? ''],
|
||||||
},
|
} as SpaceChildEventContent,
|
||||||
result.room_id,
|
result.room_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import React, {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
import { Box, Scroll, Text } from 'folds';
|
import { Box, Scroll, Text } from 'folds';
|
||||||
import {
|
import {
|
||||||
|
DecoratedRange,
|
||||||
Descendant,
|
Descendant,
|
||||||
Editor,
|
Editor,
|
||||||
|
NodeEntry,
|
||||||
createEditor,
|
createEditor,
|
||||||
Element as SlateElement,
|
Element as SlateElement,
|
||||||
Text as SlateText,
|
Text as SlateText,
|
||||||
@@ -122,8 +124,8 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
|||||||
const renderLeaf = useCallback((props: RenderLeafProps) => <RenderLeaf {...props} />, []);
|
const renderLeaf = useCallback((props: RenderLeafProps) => <RenderLeaf {...props} />, []);
|
||||||
|
|
||||||
const decorate = useCallback(
|
const decorate = useCallback(
|
||||||
([node, path]: [any, number[]]) => {
|
([node, path]: NodeEntry) => {
|
||||||
const ranges: any[] = [];
|
const ranges: (DecoratedRange & { pendingCommand?: boolean })[] = [];
|
||||||
|
|
||||||
// Only decorate text nodes in the first paragraph
|
// Only decorate text nodes in the first paragraph
|
||||||
if (path.length === 2 && path[0] === 0 && path[1] === 0 && SlateText.isText(node)) {
|
if (path.length === 2 && path[0] === 0 && path[1] === 0 && SlateText.isText(node)) {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export function ReadTextFile({ body, mimeType, url, encInfo, renderViewer }: Rea
|
|||||||
<Modal
|
<Modal
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
name: body,
|
name: body,
|
||||||
@@ -213,7 +213,7 @@ export function ReadPdfFile({ body, mimeType, url, encInfo, renderViewer }: Read
|
|||||||
<Modal
|
<Modal
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
name: body,
|
name: body,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
toRem,
|
toRem,
|
||||||
} from 'folds';
|
} from 'folds';
|
||||||
import { MatrixClient, MatrixError, Room } from 'matrix-js-sdk';
|
import { EventType, MatrixClient, MatrixError, Room } from 'matrix-js-sdk';
|
||||||
import { Icon, Icons } from '../icons';
|
import { Icon, Icons } from '../icons';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||||
@@ -134,7 +134,7 @@ async function removeSpaceChildrenSequentially(
|
|||||||
onProgress?.(i, total);
|
onProgress?.(i, total);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await mx.sendStateEvent(parentId, StateEvent.SpaceChild as any, {}, roomId);
|
await mx.sendStateEvent(parentId, EventType.SpaceChild, {}, roomId);
|
||||||
await delay(REMOVE_DELAY_MS);
|
await delay(REMOVE_DELAY_MS);
|
||||||
} catch {
|
} catch {
|
||||||
// Continue removing others even if one fails
|
// Continue removing others even if one fails
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export function WindowControls() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Only render on desktop (when Tauri is available)
|
// Only render on desktop (when Tauri is available)
|
||||||
if (typeof (window as any).__TAURI__ === 'undefined') {
|
if (typeof window.__TAURI__ === 'undefined') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const SOUND_FILES: Record<CallSoundType, string> = {
|
|||||||
* In dev or browser, sounds are served from public/sound/.
|
* In dev or browser, sounds are served from public/sound/.
|
||||||
*/
|
*/
|
||||||
async function resolveSoundBaseUrl(): Promise<string> {
|
async function resolveSoundBaseUrl(): Promise<string> {
|
||||||
const electronAudio = (window as any).electron?.audio;
|
const electronAudio = window.electron?.audio;
|
||||||
if (electronAudio?.getSoundBaseUrl) {
|
if (electronAudio?.getSoundBaseUrl) {
|
||||||
const base: string | null = await electronAudio.getSoundBaseUrl();
|
const base: string | null = await electronAudio.getSoundBaseUrl();
|
||||||
if (base) return base;
|
if (base) return base;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
} from 'folds';
|
} from 'folds';
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import { MatrixError } from 'matrix-js-sdk';
|
import { EventType, MatrixError } from 'matrix-js-sdk';
|
||||||
import FocusTrap from 'focus-trap-react';
|
import FocusTrap from 'focus-trap-react';
|
||||||
import { Icon, Icons } from '../../../components/icons';
|
import { Icon, Icons } from '../../../components/icons';
|
||||||
import { SequenceCard } from '../../../components/sequence-card';
|
import { SequenceCard } from '../../../components/sequence-card';
|
||||||
@@ -45,7 +45,7 @@ export function RoomEncryption({ permissions }: RoomEncryptionProps) {
|
|||||||
|
|
||||||
const [enableState, enable] = useAsyncCallback(
|
const [enableState, enable] = useAsyncCallback(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
await mx.sendStateEvent(room.roomId, StateEvent.RoomEncryption as any, {
|
await mx.sendStateEvent(room.roomId, EventType.RoomEncryption, {
|
||||||
algorithm: ROOM_ENC_ALGO,
|
algorithm: ROOM_ENC_ALGO,
|
||||||
});
|
});
|
||||||
}, [mx, room.roomId]),
|
}, [mx, room.roomId]),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { MouseEventHandler, useCallback, useMemo, useState } from 'react';
|
import React, { MouseEventHandler, useCallback, useMemo, useState } from 'react';
|
||||||
import { Button, color, config, Menu, MenuItem, PopOut, RectCords, Spinner, Text } from 'folds';
|
import { Button, color, config, Menu, MenuItem, PopOut, RectCords, Spinner, Text } from 'folds';
|
||||||
import { HistoryVisibility, MatrixError } from 'matrix-js-sdk';
|
import { EventType, HistoryVisibility, MatrixError } from 'matrix-js-sdk';
|
||||||
import { RoomHistoryVisibilityEventContent } from 'matrix-js-sdk/lib/types';
|
import { RoomHistoryVisibilityEventContent } from 'matrix-js-sdk/lib/types';
|
||||||
import FocusTrap from 'focus-trap-react';
|
import FocusTrap from 'focus-trap-react';
|
||||||
import { Icon, Icons } from '../../../components/icons';
|
import { Icon, Icons } from '../../../components/icons';
|
||||||
@@ -65,7 +65,7 @@ export function RoomHistoryVisibility({ permissions }: RoomHistoryVisibilityProp
|
|||||||
const content: RoomHistoryVisibilityEventContent = {
|
const content: RoomHistoryVisibilityEventContent = {
|
||||||
history_visibility: visibility,
|
history_visibility: visibility,
|
||||||
};
|
};
|
||||||
await mx.sendStateEvent(room.roomId, StateEvent.RoomHistoryVisibility as any, content);
|
await mx.sendStateEvent(room.roomId, EventType.RoomHistoryVisibility, content);
|
||||||
},
|
},
|
||||||
[mx, room.roomId],
|
[mx, room.roomId],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import { color, Text } from 'folds';
|
import { color, Text } from 'folds';
|
||||||
import { JoinRule, MatrixError, RestrictedAllowType } from 'matrix-js-sdk';
|
import { EventType, JoinRule, MatrixError, RestrictedAllowType } from 'matrix-js-sdk';
|
||||||
import { RoomJoinRulesEventContent } from 'matrix-js-sdk/lib/types';
|
import { RoomJoinRulesEventContent } from 'matrix-js-sdk/lib/types';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import {
|
import {
|
||||||
@@ -113,7 +113,7 @@ export function RoomJoinRules({ permissions }: RoomJoinRulesProps) {
|
|||||||
join_rule: joinRule as JoinRule,
|
join_rule: joinRule as JoinRule,
|
||||||
};
|
};
|
||||||
if (allow.length > 0) c.allow = allow;
|
if (allow.length > 0) c.allow = allow;
|
||||||
await mx.sendStateEvent(room.roomId, StateEvent.RoomJoinRules as any, c);
|
await mx.sendStateEvent(room.roomId, EventType.RoomJoinRules, c);
|
||||||
},
|
},
|
||||||
[mx, room, space, subspaces, roomIdToParents],
|
[mx, room, space, subspaces, roomIdToParents],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable react/no-array-index-key */
|
/* eslint-disable react/no-array-index-key */
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Badge, Box, Button, Chip, config, Menu, Spinner, Text } from 'folds';
|
import { Badge, Box, Button, Chip, config, Menu, Spinner, Text } from 'folds';
|
||||||
|
import { EventType } from 'matrix-js-sdk';
|
||||||
import { produce } from 'immer';
|
import { produce } from 'immer';
|
||||||
import { Icon, Icons } from '../../../components/icons';
|
import { Icon, Icons } from '../../../components/icons';
|
||||||
import { SequenceCard } from '../../../components/sequence-card';
|
import { SequenceCard } from '../../../components/sequence-card';
|
||||||
@@ -16,7 +17,6 @@ import { PermissionGroup } from './types';
|
|||||||
import { getPowerLevelTag, getPowers, usePowerLevelTags } from '../../../hooks/usePowerLevelTags';
|
import { getPowerLevelTag, getPowers, usePowerLevelTags } from '../../../hooks/usePowerLevelTags';
|
||||||
import { useRoom } from '../../../hooks/useRoom';
|
import { useRoom } from '../../../hooks/useRoom';
|
||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
import { StateEvent } from '../../../../types/matrix/room';
|
|
||||||
import { PowerSwitcher } from '../../../components/power';
|
import { PowerSwitcher } from '../../../components/power';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
||||||
import { useAlive } from '../../../hooks/useAlive';
|
import { useAlive } from '../../../hooks/useAlive';
|
||||||
@@ -86,7 +86,7 @@ export function PermissionGroups({
|
|||||||
|
|
||||||
return draftPowerLevels;
|
return draftPowerLevels;
|
||||||
});
|
});
|
||||||
await mx.sendStateEvent(room.roomId, StateEvent.RoomPowerLevels as any, editedPowerLevels);
|
await mx.sendStateEvent(room.roomId, EventType.RoomPowerLevels, editedPowerLevels);
|
||||||
}, [mx, room, powerLevels, permissionUpdate, permissionGroups]),
|
}, [mx, room, powerLevels, permissionUpdate, permissionGroups]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
toRem,
|
toRem,
|
||||||
} from 'folds';
|
} from 'folds';
|
||||||
|
import { EventType } from 'matrix-js-sdk';
|
||||||
import { Icon, Icons } from '../../components/icons';
|
import { Icon, Icons } from '../../components/icons';
|
||||||
import { HierarchyItem } from '../../hooks/useSpaceHierarchy';
|
import { HierarchyItem } from '../../hooks/useSpaceHierarchy';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { MSpaceChildContent, StateEvent } from '../../../types/matrix/room';
|
import { MSpaceChildContent } from '../../../types/matrix/room';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||||
import { UseStateProvider } from '../../components/UseStateProvider';
|
import { UseStateProvider } from '../../components/UseStateProvider';
|
||||||
import { LeaveSpacePrompt } from '../../components/leave-space-prompt';
|
import { LeaveSpacePrompt } from '../../components/leave-space-prompt';
|
||||||
@@ -47,7 +48,7 @@ function SuggestMenuItem({
|
|||||||
const [toggleState, handleToggleSuggested] = useAsyncCallback(
|
const [toggleState, handleToggleSuggested] = useAsyncCallback(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
const newContent: MSpaceChildContent = { ...content, suggested: !content.suggested };
|
const newContent: MSpaceChildContent = { ...content, suggested: !content.suggested };
|
||||||
return mx.sendStateEvent(parentId, StateEvent.SpaceChild as any, newContent, roomId);
|
return mx.sendStateEvent(parentId, EventType.SpaceChild, newContent, roomId);
|
||||||
}, [mx, parentId, roomId, content]),
|
}, [mx, parentId, roomId, content]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ function RemoveMenuItem({
|
|||||||
|
|
||||||
const [removeState, handleRemove] = useAsyncCallback(
|
const [removeState, handleRemove] = useAsyncCallback(
|
||||||
useCallback(
|
useCallback(
|
||||||
() => mx.sendStateEvent(parentId, StateEvent.SpaceChild as any, {}, roomId),
|
() => mx.sendStateEvent(parentId, EventType.SpaceChild, {}, roomId),
|
||||||
[mx, parentId, roomId],
|
[mx, parentId, roomId],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ export function RoomTombstone({ roomId, body, replacementRoomId }: RoomTombstone
|
|||||||
<Text size="T400">{body || 'This room has been replaced and is no longer active.'}</Text>
|
<Text size="T400">{body || 'This room has been replaced and is no longer active.'}</Text>
|
||||||
{joinState.status === AsyncStatus.Error && (
|
{joinState.status === AsyncStatus.Error && (
|
||||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||||
{(joinState.error as any)?.message ?? 'Failed to join replacement room!'}
|
{joinState.error instanceof Error
|
||||||
|
? joinState.error.message
|
||||||
|
: 'Failed to join replacement room!'}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export const Reactions = as<'div', ReactionsProps>(
|
|||||||
})}
|
})}
|
||||||
{reactions.length > 0 && (
|
{reactions.length > 0 && (
|
||||||
<Overlay
|
<Overlay
|
||||||
onContextMenu={(evt: any) => {
|
onContextMenu={(evt) => {
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
}}
|
}}
|
||||||
open={!!viewer}
|
open={!!viewer}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable react/destructuring-assignment */
|
/* eslint-disable react/destructuring-assignment */
|
||||||
import React, { forwardRef, MouseEventHandler, useCallback, useMemo, useRef } from 'react';
|
import React, { forwardRef, MouseEventHandler, useCallback, useMemo, useRef } from 'react';
|
||||||
import { MatrixEvent, Room } from 'matrix-js-sdk';
|
import { EventType, MatrixEvent, Room } from 'matrix-js-sdk';
|
||||||
import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types';
|
import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types';
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
@@ -123,7 +123,7 @@ function PinnedMessage({
|
|||||||
pinned: content.pinned.filter((id) => id !== eventId),
|
pinned: content.pinned.filter((id) => id !== eventId),
|
||||||
};
|
};
|
||||||
|
|
||||||
return mx.sendStateEvent(room.roomId, StateEvent.RoomPinnedEvents as any, newContent);
|
return mx.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, newContent);
|
||||||
}, [room, eventId, mx]),
|
}, [room, eventId, mx]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -366,8 +366,8 @@ function ProfileBanner() {
|
|||||||
handleRemoveUpload();
|
handleRemoveUpload();
|
||||||
// Sync user object to propagate changes throughout app
|
// Sync user object to propagate changes throughout app
|
||||||
await syncUserAvatar();
|
await syncUserAvatar();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
const errorMsg = e?.message || 'Unknown error';
|
const errorMsg = e instanceof Error ? e.message : 'Unknown error';
|
||||||
console.error('[ProfileBanner] setUserBanner failed:', e);
|
console.error('[ProfileBanner] setUserBanner failed:', e);
|
||||||
setError(`Failed to save banner: ${errorMsg}`);
|
setError(`Failed to save banner: ${errorMsg}`);
|
||||||
}
|
}
|
||||||
@@ -391,8 +391,8 @@ function ProfileBanner() {
|
|||||||
}
|
}
|
||||||
setAvatarFile(undefined);
|
setAvatarFile(undefined);
|
||||||
await syncUserAvatar();
|
await syncUserAvatar();
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
setError(`Failed to save avatar: ${e?.message || 'Unknown error'}`);
|
setError(`Failed to save avatar: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
||||||
}
|
}
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
getLocalStorageItem,
|
getLocalStorageItem,
|
||||||
setLocalStorageItem,
|
setLocalStorageItem,
|
||||||
} from '../../../state/utils/atomWithLocalStorage';
|
} from '../../../state/utils/atomWithLocalStorage';
|
||||||
|
import { Sessions } from '../../../state/sessions';
|
||||||
|
|
||||||
export enum GetBaseUrlError {
|
export enum GetBaseUrlError {
|
||||||
NotAllow = 'NotAllow',
|
NotAllow = 'NotAllow',
|
||||||
@@ -120,7 +121,7 @@ export const useLoginComplete = (data?: CustomLoginResponse) => {
|
|||||||
const { response: loginRes, baseUrl: loginBaseUrl } = data;
|
const { response: loginRes, baseUrl: loginBaseUrl } = data;
|
||||||
|
|
||||||
// Add session to sessions list
|
// Add session to sessions list
|
||||||
const sessions = getLocalStorageItem('matrixSessions', []);
|
const sessions = getLocalStorageItem<Sessions>('matrixSessions', []);
|
||||||
|
|
||||||
const newSession = {
|
const newSession = {
|
||||||
baseUrl: loginBaseUrl,
|
baseUrl: loginBaseUrl,
|
||||||
@@ -134,7 +135,7 @@ export const useLoginComplete = (data?: CustomLoginResponse) => {
|
|||||||
|
|
||||||
// Check if session already exists (by userId AND deviceId to avoid conflicts)
|
// Check if session already exists (by userId AND deviceId to avoid conflicts)
|
||||||
const existingIndex = sessions.findIndex(
|
const existingIndex = sessions.findIndex(
|
||||||
(s: any) => s.userId === loginRes.user_id && s.deviceId === loginRes.device_id,
|
(s) => s.userId === loginRes.user_id && s.deviceId === loginRes.device_id,
|
||||||
);
|
);
|
||||||
if (existingIndex >= 0) {
|
if (existingIndex >= 0) {
|
||||||
// Preserve fallbackSdkStores if it was set, but never enable it for new logins
|
// Preserve fallbackSdkStores if it was set, but never enable it for new logins
|
||||||
|
|||||||
@@ -274,7 +274,9 @@ export function SpaceTombstone({ roomId, replacementRoomId }: SpaceTombstoneProp
|
|||||||
<Text size="T200">This space has been replaced and is no longer active.</Text>
|
<Text size="T200">This space has been replaced and is no longer active.</Text>
|
||||||
{joinState.status === AsyncStatus.Error && (
|
{joinState.status === AsyncStatus.Error && (
|
||||||
<Text className={BreakWord} style={{ color: color.Critical.Main }} size="T200">
|
<Text className={BreakWord} style={{ color: color.Critical.Main }} size="T200">
|
||||||
{(joinState.error as any)?.message ?? 'Failed to join replacement space!'}
|
{joinState.error instanceof Error
|
||||||
|
? joinState.error.message
|
||||||
|
: 'Failed to join replacement space!'}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const promiseFulfilledResult = <T>(
|
|||||||
if (settledResult.status === 'fulfilled') return settledResult.value;
|
if (settledResult.status === 'fulfilled') return settledResult.value;
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
export const promiseRejectedResult = <T>(settledResult: PromiseSettledResult<T>): any => {
|
export const promiseRejectedResult = <T>(settledResult: PromiseSettledResult<T>): unknown => {
|
||||||
if (settledResult.status === 'rejected') return settledResult.reason;
|
if (settledResult.status === 'rejected') return settledResult.reason;
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export const getLoginTermUrl = (params: UIAParams): string | undefined => {
|
|||||||
if (terms.policies === null) return undefined;
|
if (terms.policies === null) return undefined;
|
||||||
if ('privacy_policy' in terms.policies && typeof terms.policies.privacy_policy === 'object') {
|
if ('privacy_policy' in terms.policies && typeof terms.policies.privacy_policy === 'object') {
|
||||||
if (terms.policies.privacy_policy === null) return undefined;
|
if (terms.policies.privacy_policy === null) return undefined;
|
||||||
const langToPolicy = terms.policies.privacy_policy as Record<string, any>;
|
const langToPolicy = terms.policies.privacy_policy as Record<string, { url?: string }>;
|
||||||
const url = langToPolicy.en?.url;
|
const url = langToPolicy.en?.url;
|
||||||
if (typeof url === 'string') return url;
|
if (typeof url === 'string') return url;
|
||||||
|
|
||||||
|
|||||||
@@ -165,9 +165,10 @@ export const uploadContent = async (
|
|||||||
const mxc = data.content_uri;
|
const mxc = data.content_uri;
|
||||||
if (mxc) onSuccess(mxc);
|
if (mxc) onSuccess(mxc);
|
||||||
else onError(new MatrixError(data));
|
else onError(new MatrixError(data));
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
const error = typeof e?.message === 'string' ? e.message : undefined;
|
const err = e as { message?: string; name?: string };
|
||||||
const errcode = typeof e?.name === 'string' ? e.message : undefined;
|
const error = typeof err?.message === 'string' ? err.message : undefined;
|
||||||
|
const errcode = typeof err?.name === 'string' ? err.message : undefined;
|
||||||
onError(new MatrixError({ error, errcode }));
|
onError(new MatrixError({ error, errcode }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
AccountDataEvents,
|
||||||
EventTimeline,
|
EventTimeline,
|
||||||
EventTimelineSet,
|
EventTimelineSet,
|
||||||
EventType,
|
EventType,
|
||||||
@@ -52,7 +53,7 @@ export const getStateEvents = (room: Room, eventType: StateEvent): MatrixEvent[]
|
|||||||
export const getAccountData = (
|
export const getAccountData = (
|
||||||
mx: MatrixClient,
|
mx: MatrixClient,
|
||||||
eventType: AccountDataEvent,
|
eventType: AccountDataEvent,
|
||||||
): MatrixEvent | undefined => mx.getAccountData(eventType as any);
|
): MatrixEvent | undefined => mx.getAccountData(eventType as keyof AccountDataEvents);
|
||||||
|
|
||||||
export const getMDirects = (mDirectEvent: MatrixEvent): Set<string> => {
|
export const getMDirects = (mDirectEvent: MatrixEvent): Set<string> => {
|
||||||
const roomIds = new Set<string>();
|
const roomIds = new Set<string>();
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ const getAllIndexedDBNames = async (): Promise<string[]> => {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
const databasesPromise = (globalThis.indexedDB as any)
|
const databasesPromise = globalThis.indexedDB
|
||||||
.databases()
|
.databases()
|
||||||
.then((dbs: any[]) => dbs.map((db: any) => db.name).filter(Boolean));
|
.then((dbs) => dbs.map((db) => db.name).filter((name) => typeof name === 'string'));
|
||||||
|
|
||||||
return await Promise.race([databasesPromise, timeoutPromise]);
|
return await Promise.race([databasesPromise, timeoutPromise]);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
@@ -49,6 +49,7 @@ interface ElectronAPI {
|
|||||||
};
|
};
|
||||||
audio?: {
|
audio?: {
|
||||||
playNotificationSound: (soundType?: string) => Promise<{ success: boolean; error?: string }>;
|
playNotificationSound: (soundType?: string) => Promise<{ success: boolean; error?: string }>;
|
||||||
|
getSoundBaseUrl?: () => Promise<string | null>;
|
||||||
};
|
};
|
||||||
clipboard?: {
|
clipboard?: {
|
||||||
writeText: (text: string) => void;
|
writeText: (text: string) => void;
|
||||||
|
|||||||
Reference in new issue
Block a user