mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
chore(lint): lint autofix
This commit is contained in:
21 files changed
+52
-49
No files matched your search
@@ -5,7 +5,7 @@ import { roomToUnreadAtom } from '../state/room/roomToUnread';
|
||||
|
||||
type RoomUnreadProviderProps = {
|
||||
roomId: string;
|
||||
children: (unread?: Unread) => ReactElement<any>;
|
||||
children: (unread?: Unread) => ReactElement;
|
||||
};
|
||||
export function RoomUnreadProvider({ roomId, children }: RoomUnreadProviderProps) {
|
||||
const unread = useRoomUnread(roomId, roomToUnreadAtom);
|
||||
@@ -15,7 +15,7 @@ export function RoomUnreadProvider({ roomId, children }: RoomUnreadProviderProps
|
||||
|
||||
type RoomsUnreadProviderProps = {
|
||||
rooms: string[];
|
||||
children: (unread?: Unread) => ReactElement<any>;
|
||||
children: (unread?: Unread) => ReactElement;
|
||||
};
|
||||
export function RoomsUnreadProvider({ rooms, children }: RoomsUnreadProviderProps) {
|
||||
const unread = useRoomsUnread(rooms, roomToUnreadAtom);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Dispatch, ReactElement, SetStateAction, useState } from 'react';
|
||||
|
||||
type UseStateProviderProps<T> = {
|
||||
initial: T | (() => T);
|
||||
children: (value: T, setter: Dispatch<SetStateAction<T>>) => ReactElement<any>;
|
||||
children: (value: T, setter: Dispatch<SetStateAction<T>>) => ReactElement;
|
||||
};
|
||||
export function UseStateProvider<T>({ initial, children }: UseStateProviderProps<T>) {
|
||||
return children(...useState(initial));
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Box,
|
||||
@@ -82,9 +81,16 @@ export function DirectInvitePrompt({
|
||||
}
|
||||
aria-disabled={converting}
|
||||
>
|
||||
<Text size="B400">{converting ? 'Converting...' : 'Convert to Group Chat and Invite'}</Text>
|
||||
<Text size="B400">
|
||||
{converting ? 'Converting...' : 'Convert to Group Chat and Invite'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Button variant="Warning" fill="Soft" onClick={onInviteDirect} disabled={converting}>
|
||||
<Button
|
||||
variant="Warning"
|
||||
fill="Soft"
|
||||
onClick={onInviteDirect}
|
||||
disabled={converting}
|
||||
>
|
||||
<Text size="B400">Invite to Direct Message anyway</Text>
|
||||
</Button>
|
||||
<Button variant="Secondary" fill="Soft" onClick={onCancel} disabled={converting}>
|
||||
|
||||
@@ -91,7 +91,7 @@ export function UserMentionAutocomplete({
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
const roomId: string = room.roomId!;
|
||||
const roomId: string = room.roomId;
|
||||
const roomAliasOrId = room.getCanonicalAlias() || roomId;
|
||||
const members = useRoomMembers(mx, roomId);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const isHeading3 = isKeyHotkey('mod+3');
|
||||
/**
|
||||
* @return boolean true if shortcut is toggled.
|
||||
*/
|
||||
export const toggleKeyboardShortcut = (editor: Editor, event: KeyboardEvent<Element>): boolean => {
|
||||
export const toggleKeyboardShortcut = (editor: Editor, event: KeyboardEvent): boolean => {
|
||||
if (isKeyHotkey('backspace', event) && editor.selection && Range.isCollapsed(editor.selection)) {
|
||||
const startPoint = Range.start(editor.selection);
|
||||
if (startPoint.offset !== 0) return false;
|
||||
|
||||
@@ -65,9 +65,7 @@ export function UploadBoardHeader({
|
||||
const handleSend = async () => {
|
||||
if (sendingRef.current) return;
|
||||
sendingRef.current = true;
|
||||
await onSend(
|
||||
uploads.filter((upload) => upload.status === UploadStatus.Success) as UploadSuccess[]
|
||||
);
|
||||
await onSend(uploads.filter((upload) => upload.status === UploadStatus.Success));
|
||||
sendingRef.current = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export const getWidgetUrl = (
|
||||
userId: mx.getUserId()!,
|
||||
deviceId: mx.getDeviceId()!,
|
||||
roomId,
|
||||
baseUrl: mx.baseUrl!,
|
||||
baseUrl: mx.baseUrl,
|
||||
parentUrl: window.location.origin,
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ export class SmallWidget extends EventEmitter {
|
||||
|
||||
private type: string; // Type of the widget (e.g., 'm.call')
|
||||
|
||||
private readUpToMap: { [roomId: string]: string } = {}; // room ID to event ID
|
||||
private readUpToMap: Record<string, string> = {}; // room ID to event ID
|
||||
|
||||
private readonly eventsToFeed = new WeakSet<MatrixEvent>();
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ export class SmallWidgetDriver extends WidgetDriver {
|
||||
public async sendToDevice(
|
||||
eventType: string,
|
||||
encrypted: boolean,
|
||||
contentMap: { [userId: string]: { [deviceId: string]: object } }
|
||||
contentMap: Record<string, Record<string, object>>
|
||||
): Promise<void> {
|
||||
const client = this.mxClient;
|
||||
|
||||
@@ -322,7 +322,7 @@ export class SmallWidgetDriver extends WidgetDriver {
|
||||
if (!crypto) throw new Error('E2EE not enabled');
|
||||
|
||||
// attempt to re-batch these up into a single request
|
||||
const invertedContentMap: { [content: string]: { userId: string; deviceId: string }[] } = {};
|
||||
const invertedContentMap: Record<string, { userId: string; deviceId: string }[]> = {};
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const userId of Object.keys(contentMap)) {
|
||||
|
||||
@@ -219,7 +219,7 @@ export function Lobby() {
|
||||
|
||||
return [getRoom(i.space.roomId), ...childRooms];
|
||||
})
|
||||
.filter((r) => !!r) as Room[],
|
||||
.filter((r) => !!r),
|
||||
[hierarchy, getRoom]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -91,6 +91,7 @@ import {
|
||||
roomUploadAtomFamily,
|
||||
TUploadItem,
|
||||
TUploadMetadata,
|
||||
IReplyDraft,
|
||||
} from '$state/room/roomInputDrafts';
|
||||
import { UploadCardRenderer } from '$components/upload-card';
|
||||
import {
|
||||
|
||||
@@ -1118,7 +1118,7 @@ export function RoomTimeline({
|
||||
const myReaction = reactions.find(factoryEventSentBy(mx.getUserId()!));
|
||||
|
||||
if (myReaction && !!(myReaction as any)?.isRelation()) {
|
||||
mx.redactEvent(room.roomId, (myReaction as any).getId()!);
|
||||
mx.redactEvent(room.roomId, (myReaction as any).getId());
|
||||
return;
|
||||
}
|
||||
const rShortcode =
|
||||
|
||||
@@ -14,17 +14,16 @@ type AccountDataProps = {
|
||||
};
|
||||
export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataProps) {
|
||||
const mx = useMatrixClient();
|
||||
const [accountDataTypes, setAccountDataKeys] = useState<string[]>(
|
||||
() =>
|
||||
// TODO: tighten this once account data event typing is standardized.
|
||||
Array.from(mx.store.accountData.keys()) as string[]
|
||||
const [accountDataTypes, setAccountDataKeys] = useState<string[]>(() =>
|
||||
// TODO: tighten this once account data event typing is standardized.
|
||||
Array.from(mx.store.accountData.keys())
|
||||
);
|
||||
|
||||
useAccountDataCallback(
|
||||
mx,
|
||||
useCallback(() => {
|
||||
// TODO: tighten this once account data event typing is standardized.
|
||||
setAccountDataKeys(Array.from(mx.store.accountData.keys()) as string[]);
|
||||
setAccountDataKeys(Array.from(mx.store.accountData.keys()));
|
||||
}, [mx])
|
||||
);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ export class GenericWidgetDriver extends WidgetDriver {
|
||||
content as TimelineEvents[keyof TimelineEvents]
|
||||
);
|
||||
}
|
||||
return { roomId, eventId: r!.event_id };
|
||||
return { roomId, eventId: r.event_id };
|
||||
}
|
||||
|
||||
public async sendDelayedEvent<K extends keyof StateEvents>(
|
||||
@@ -167,13 +167,13 @@ export class GenericWidgetDriver extends WidgetDriver {
|
||||
public async sendToDevice(
|
||||
eventType: string,
|
||||
encrypted: boolean,
|
||||
contentMap: { [userId: string]: { [deviceId: string]: object } }
|
||||
contentMap: Record<string, Record<string, object>>
|
||||
): Promise<void> {
|
||||
const client = this.mxClient;
|
||||
if (encrypted) {
|
||||
const crypto = client.getCrypto();
|
||||
if (!crypto) throw new Error('E2EE not enabled');
|
||||
const invertedContentMap: { [content: string]: { userId: string; deviceId: string }[] } = {};
|
||||
const invertedContentMap: Record<string, { userId: string; deviceId: string }[]> = {};
|
||||
for (const userId of Object.keys(contentMap)) {
|
||||
for (const deviceId of Object.keys(contentMap[userId])) {
|
||||
const key = JSON.stringify(contentMap[userId][deviceId]);
|
||||
|
||||
@@ -84,7 +84,7 @@ export function WidgetIframe({ widget, roomId, mx, onCapabilityRequest }: Widget
|
||||
messaging.transport.reply(ev.detail, { events });
|
||||
});
|
||||
|
||||
const readUpToMap: { [rId: string]: string } = {};
|
||||
const readUpToMap: Record<string, string> = {};
|
||||
mx.getRooms().forEach((room) => {
|
||||
const roomEvents = room.getLiveTimeline()?.getEvents() || [];
|
||||
const last = roomEvents[roomEvents.length - 1];
|
||||
|
||||
@@ -14,7 +14,7 @@ export const useMutualRoomsSupport = (): boolean => {
|
||||
return !!supported;
|
||||
};
|
||||
|
||||
export const useMutualRooms = (userId: string): AsyncState<string[], unknown> => {
|
||||
export const useMutualRooms = (userId: string): AsyncState<string[]> => {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const supported = useMutualRoomsSupport();
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
lightTheme,
|
||||
rosePineTheme,
|
||||
silverTheme,
|
||||
gruvdarkTheme
|
||||
gruvdarkTheme,
|
||||
} from '../../colors.css';
|
||||
import { settingsAtom } from '../state/settings';
|
||||
import { useSetting } from '../state/hooks/settings';
|
||||
@@ -64,7 +64,15 @@ export const CinnyDarkTheme: Theme = {
|
||||
|
||||
export const useThemes = (): Theme[] => {
|
||||
const themes: Theme[] = useMemo(
|
||||
() => [LightTheme, SilverTheme, DarkTheme, ButterTheme, RosePineTheme, CinnyDarkTheme, GruvdarkTheme],
|
||||
() => [
|
||||
LightTheme,
|
||||
SilverTheme,
|
||||
DarkTheme,
|
||||
ButterTheme,
|
||||
RosePineTheme,
|
||||
CinnyDarkTheme,
|
||||
GruvdarkTheme,
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
@@ -395,12 +395,12 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
|
||||
}
|
||||
const scrollElement = getScrollElement();
|
||||
if (!scrollElement) return;
|
||||
const backAnchor = scrollElement.querySelector(
|
||||
const backAnchor = scrollElement.querySelector<HTMLElement>(
|
||||
`[${PAGINATOR_ANCHOR_ATTR}="${Direction.Backward}"]`
|
||||
) as HTMLElement | null;
|
||||
const frontAnchor = scrollElement.querySelector(
|
||||
);
|
||||
const frontAnchor = scrollElement.querySelector<HTMLElement>(
|
||||
`[${PAGINATOR_ANCHOR_ATTR}="${Direction.Forward}"]`
|
||||
) as HTMLElement | null;
|
||||
);
|
||||
|
||||
if (backAnchor && isIntersectingScrollView(scrollElement, backAnchor)) {
|
||||
paginate(Direction.Backward);
|
||||
|
||||
@@ -258,7 +258,7 @@ export function ClientRoot({ children }: ClientRootProps) {
|
||||
);
|
||||
|
||||
return (
|
||||
<SpecVersions baseUrl={baseUrl!}>
|
||||
<SpecVersions baseUrl={baseUrl}>
|
||||
{mx && <SyncStatus mx={mx} />}
|
||||
{loading && <ClientRootOptions mx={mx} session={activeSession} onLogout={handleLogout} />}
|
||||
{(loadState.status === AsyncStatus.Error || startState.status === AsyncStatus.Error) && (
|
||||
|
||||
@@ -7,12 +7,7 @@ import {
|
||||
ReactNode,
|
||||
useEffect,
|
||||
} from 'react';
|
||||
import {
|
||||
WidgetApiToWidgetAction,
|
||||
WidgetApiAction,
|
||||
ClientWidgetApi,
|
||||
IWidgetApiRequestData,
|
||||
} from 'matrix-widget-api';
|
||||
import { WidgetApiToWidgetAction, ClientWidgetApi, IWidgetApiRequestData } from 'matrix-widget-api';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { SmallWidget } from '$features/call/SmallWidget';
|
||||
|
||||
@@ -132,7 +127,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||
const hangUp = useCallback(() => {
|
||||
setActiveClientWidgetApi(null, null, null, null);
|
||||
setActiveCallRoomIdState(null);
|
||||
activeClientWidgetApi?.transport.send(`${WIDGET_HANGUP_ACTION}`, {});
|
||||
activeClientWidgetApi?.transport.send(WIDGET_HANGUP_ACTION, {});
|
||||
setIsActiveCallReady(false);
|
||||
}, [activeClientWidgetApi?.transport, setActiveClientWidgetApi]);
|
||||
|
||||
@@ -148,7 +143,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||
return Promise.reject(new Error('Mismatched active call clientWidgetApi'));
|
||||
}
|
||||
|
||||
await activeClientWidgetApi.transport.send(action as WidgetApiAction, data);
|
||||
await activeClientWidgetApi.transport.send(action, data);
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ import { MatrixClient, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { StateEvent } from '$types/matrix/room';
|
||||
import { getAccountData, getStateEvent, getStateEvents } from '$utils/room';
|
||||
import { AccountDataEvent } from '$types/matrix/accountData';
|
||||
import { EmoteRoomsContent, ImageUsage } from './types';
|
||||
import { ImageUsage } from './types';
|
||||
import { ImagePack } from './ImagePack';
|
||||
import { PackMetaReader } from './PackMetaReader';
|
||||
import { PackAddress } from './PackAddress';
|
||||
@@ -49,9 +49,7 @@ export function getRoomImagePacks(room: Room): ImagePack[] {
|
||||
}
|
||||
|
||||
export function getGlobalImagePacks(mx: MatrixClient): ImagePack[] {
|
||||
const emoteRoomsContent = getAccountData(mx, AccountDataEvent.PoniesEmoteRooms)?.getContent() as
|
||||
| EmoteRoomsContent
|
||||
| undefined;
|
||||
const emoteRoomsContent = getAccountData(mx, AccountDataEvent.PoniesEmoteRooms)?.getContent();
|
||||
if (typeof emoteRoomsContent !== 'object') return [];
|
||||
|
||||
const { rooms: roomIdToPackInfo } = emoteRoomsContent;
|
||||
|
||||
Vendored
+1
-3
@@ -11,9 +11,7 @@ declare module 'browser-encrypt-attachment' {
|
||||
ext: boolean;
|
||||
};
|
||||
iv: string;
|
||||
hashes: {
|
||||
[alg: string]: string;
|
||||
};
|
||||
hashes: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface EncryptedAttachment {
|
||||
|
||||
Reference in new issue
Block a user