Fix lint & style issues
This commit is contained in:
1 parent
7e22d86a51
commit
a5d0da94d6
6 files changed
+50
-66
No files matched your search
@@ -126,13 +126,6 @@ import { useImagePackRooms } from '$hooks/useImagePackRooms';
|
||||
import { useComposingCheck } from '$hooks/useComposingCheck';
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
import { createLogger } from '$utils/debug';
|
||||
import { CommandAutocomplete } from './CommandAutocomplete';
|
||||
import {
|
||||
getAudioMsgContent,
|
||||
getFileMsgContent,
|
||||
getImageMsgContent,
|
||||
getVideoMsgContent,
|
||||
} from './msgContent';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
@@ -146,10 +139,17 @@ import {
|
||||
computeDelayMs,
|
||||
cancelDelayedEvent,
|
||||
} from '$utils/delayedEvents';
|
||||
import { SchedulePickerDialog } from './schedule-send';
|
||||
import * as css from './schedule-send/SchedulePickerDialog.css';
|
||||
import { timeHourMinute, timeDayMonthYear } from '$utils/time';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { SchedulePickerDialog } from './schedule-send';
|
||||
import * as css from './schedule-send/SchedulePickerDialog.css';
|
||||
import {
|
||||
getAudioMsgContent,
|
||||
getFileMsgContent,
|
||||
getImageMsgContent,
|
||||
getVideoMsgContent,
|
||||
} from './msgContent';
|
||||
import { CommandAutocomplete } from './CommandAutocomplete';
|
||||
|
||||
const getReplyContent = (replyDraft: IReplyDraft | undefined): IEventRelation => {
|
||||
if (!replyDraft) return {};
|
||||
@@ -506,7 +506,23 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
}
|
||||
resetInput();
|
||||
}
|
||||
}, [mx, roomId, room, editor, replyDraft, sendTypingStatus, setReplyDraft, isMarkdown, commands, scheduledTime, setScheduledTime, isEncrypted, queryClient, editingScheduledDelayId, setEditingScheduledDelayId]);
|
||||
}, [
|
||||
mx,
|
||||
roomId,
|
||||
room,
|
||||
editor,
|
||||
replyDraft,
|
||||
sendTypingStatus,
|
||||
setReplyDraft,
|
||||
isMarkdown,
|
||||
commands,
|
||||
scheduledTime,
|
||||
setScheduledTime,
|
||||
isEncrypted,
|
||||
queryClient,
|
||||
editingScheduledDelayId,
|
||||
setEditingScheduledDelayId,
|
||||
]);
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler = useCallback(
|
||||
(evt) => {
|
||||
|
||||
@@ -24,6 +24,8 @@ import { useOpenRoomSettings } from '$state/hooks/roomSettings';
|
||||
import { useSpaceOptionally } from '$hooks/useSpace';
|
||||
import { RoomSettingsPage } from '$state/roomSettings';
|
||||
import { GlobalModalManager } from '$components/message/modals/GlobalModalManager';
|
||||
import { useDelayedEventsSupport } from '$hooks/useDelayedEventsSupport';
|
||||
import { delayedEventsSupportedAtom } from '$state/scheduledMessages';
|
||||
import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing';
|
||||
import { RoomInput } from './RoomInput';
|
||||
import { RoomTombstone } from './RoomTombstone';
|
||||
@@ -31,8 +33,6 @@ import { RoomViewTyping } from './RoomViewTyping';
|
||||
import { RoomTimeline } from './RoomTimeline';
|
||||
import { RoomInputPlaceholder } from './RoomInputPlaceholder';
|
||||
import { ScheduledMessagesList } from './schedule-send';
|
||||
import { useDelayedEventsSupport } from '$hooks/useDelayedEventsSupport';
|
||||
import { delayedEventsSupportedAtom } from '$state/scheduledMessages';
|
||||
|
||||
const FN_KEYS_REGEX = /^F\d+$/;
|
||||
const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { MouseEventHandler, useState } from 'react';
|
||||
import { MouseEventHandler, useState } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -139,12 +139,7 @@ export function SchedulePickerDialog({
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<TimePicker
|
||||
min={now}
|
||||
max={now + maxDelay}
|
||||
value={ts}
|
||||
onChange={setTs}
|
||||
/>
|
||||
<TimePicker min={now} max={now + maxDelay} value={ts} onChange={setTs} />
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
@@ -185,12 +180,7 @@ export function SchedulePickerDialog({
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<DatePicker
|
||||
min={now}
|
||||
max={now + maxDelay}
|
||||
value={ts}
|
||||
onChange={setTs}
|
||||
/>
|
||||
<DatePicker min={now} max={now + maxDelay} value={ts} onChange={setTs} />
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
@@ -244,8 +234,8 @@ export function SchedulePickerDialog({
|
||||
</Box>
|
||||
{showEncryptionWarning && (
|
||||
<Text size="T300" priority="400">
|
||||
Note: This message will be encrypted with current room keys. Devices that join
|
||||
or are added after scheduling may not be able to decrypt it.
|
||||
Note: This message will be encrypted with current room keys. Devices that join or
|
||||
are added after scheduling may not be able to decrypt it.
|
||||
</Text>
|
||||
)}
|
||||
{(error || isPast) && (
|
||||
@@ -253,12 +243,7 @@ export function SchedulePickerDialog({
|
||||
{error || 'Selected time is in the past'}
|
||||
</Text>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
aria-disabled={isPast}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
<Button type="submit" variant="Primary" aria-disabled={isPast} onClick={handleSubmit}>
|
||||
<Text size="B400">Schedule Send</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Box, Text, Chip, Icon, Icons, IconButton } from 'folds';
|
||||
import { Room } from '$types/matrix-sdk';
|
||||
@@ -91,28 +91,21 @@ export function ScheduledMessagesList({ room, onEditMessage }: ScheduledMessages
|
||||
variant="SurfaceVariant"
|
||||
radii="Pill"
|
||||
before={<Icon size="50" src={Icons.Clock} />}
|
||||
after={
|
||||
<Icon size="50" src={expanded ? Icons.ChevronTop : Icons.ChevronBottom} />
|
||||
}
|
||||
after={<Icon size="50" src={expanded ? Icons.ChevronTop : Icons.ChevronBottom} />}
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
>
|
||||
<Text size="B300">
|
||||
{visibleEvents.length} scheduled{' '}
|
||||
{visibleEvents.length === 1 ? 'message' : 'messages'}
|
||||
{visibleEvents.length} scheduled {visibleEvents.length === 1 ? 'message' : 'messages'}
|
||||
</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
{expanded && (
|
||||
<Box direction="Column" className={css.ScheduledMessagesPanel}>
|
||||
{visibleEvents.map((evt) => {
|
||||
const deliveryTs =
|
||||
'delay' in evt ? evt.running_since + evt.delay : evt.running_since;
|
||||
const deliveryTs = 'delay' in evt ? evt.running_since + evt.delay : evt.running_since;
|
||||
const isEncryptedEvt = evt.type === 'm.room.encrypted';
|
||||
const body = isEncryptedEvt
|
||||
? ''
|
||||
: typeof evt.content.body === 'string'
|
||||
? evt.content.body
|
||||
: '';
|
||||
const body =
|
||||
!isEncryptedEvt && typeof evt.content.body === 'string' ? evt.content.body : '';
|
||||
const formattedBody =
|
||||
!isEncryptedEvt && typeof evt.content.formatted_body === 'string'
|
||||
? evt.content.formatted_body
|
||||
|
||||
@@ -3,9 +3,10 @@ import { atomFamily } from 'jotai/utils';
|
||||
|
||||
export const delayedEventsSupportedAtom = atom<boolean>(false);
|
||||
|
||||
export const roomIdToScheduledTimeAtomFamily = atomFamily<string, ReturnType<typeof atom<Date | null>>>(
|
||||
() => atom<Date | null>(null)
|
||||
);
|
||||
export const roomIdToScheduledTimeAtomFamily = atomFamily<
|
||||
string,
|
||||
ReturnType<typeof atom<Date | null>>
|
||||
>(() => atom<Date | null>(null));
|
||||
|
||||
// Save the delay_id instead of cancelling the message immediately in case
|
||||
// the edit process is cancelled
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
Room,
|
||||
UpdateDelayedEventAction,
|
||||
} from '$types/matrix-sdk';
|
||||
import type {
|
||||
DelayedEventInfo,
|
||||
SendDelayedEventResponse,
|
||||
} from '$types/matrix-sdk';
|
||||
import type { DelayedEventInfo, SendDelayedEventResponse } from '$types/matrix-sdk';
|
||||
|
||||
// Grab types needed for encryption
|
||||
interface EncryptableBackend {
|
||||
@@ -36,7 +33,7 @@ export async function sendDelayedMessage(
|
||||
{ delay: delayMs },
|
||||
threadId ?? null,
|
||||
EventType.RoomMessage,
|
||||
content as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
content as any
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +74,7 @@ export async function sendDelayedMessageE2EE(
|
||||
// event.getWireType() === 'm.room.encrypted'
|
||||
// event.getWireContent() === the Megolm ciphertext object
|
||||
// Pass the pre-encrypted payload directly to the delayed-events API.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
return (mx as any)._unstable_sendDelayedEvent(
|
||||
roomId,
|
||||
{ delay: delayMs },
|
||||
@@ -87,23 +84,15 @@ export async function sendDelayedMessageE2EE(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getDelayedEvents(
|
||||
mx: MatrixClient
|
||||
): Promise<DelayedEventInfo> {
|
||||
export async function getDelayedEvents(mx: MatrixClient): Promise<DelayedEventInfo> {
|
||||
return mx._unstable_getDelayedEvents();
|
||||
}
|
||||
|
||||
export async function cancelDelayedEvent(
|
||||
mx: MatrixClient,
|
||||
delayId: string
|
||||
): Promise<void> {
|
||||
export async function cancelDelayedEvent(mx: MatrixClient, delayId: string): Promise<void> {
|
||||
await mx._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Cancel);
|
||||
}
|
||||
|
||||
export async function sendDelayedEventNow(
|
||||
mx: MatrixClient,
|
||||
delayId: string
|
||||
): Promise<void> {
|
||||
export async function sendDelayedEventNow(mx: MatrixClient, delayId: string): Promise<void> {
|
||||
await mx._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Send);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user