Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 77 additions & 18 deletions src/app/features/room/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
Avatar,
Box,
Chip,
Button,

Check failure on line 5 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Button' is defined but never used
Dialog,

Check failure on line 6 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Dialog' is defined but never used
Header,

Check failure on line 7 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Header' is defined but never used
Icon,
IconButton,
Icons,
Input,

Check failure on line 11 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Input' is defined but never used
Line,
Menu,
MenuItem,
Modal,
Overlay,
OverlayBackdrop,
OverlayCenter,
PopOut,
RectCords,
Spinner,

Check failure on line 21 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Spinner' is defined but never used
Text,
as,
color,

Check failure on line 24 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

'color' is defined but never used
config,
} from 'folds';
import {
Expand Down Expand Up @@ -57,6 +67,7 @@
import { nicknamesAtom, setNicknameAtom } from '$state/nicknames';
import { useMatrixClient } from '$hooks/useMatrixClient';
import { useRecentEmoji } from '$hooks/useRecentEmoji';
import { EventReaders } from '../../../components/event-readers';

Check failure on line 70 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

`../../../components/event-readers` import should occur after import of `$hooks/usePerMessageProfile`
import { EmojiBoard } from '$components/emoji-board';
import { UserAvatar } from '$components/user-avatar';
import { copyToClipboard } from '$utils/dom';
Expand All @@ -75,7 +86,6 @@
import { useSetting } from '$state/hooks/settings';
import { useBlobCache } from '$hooks/useBlobCache';
import { MessageAllReactionItem } from '$components/message/modals/MessageReactions';
import { MessageReadReceiptItem } from '$components/message/modals/MessageReadRecipts';
import { MessageEditHistoryItem } from '$components/message/modals/MessageEditHistory';
import { MessageSourceCodeItem } from '$components/message/modals/MessageSource';
import { MessageForwardItem } from '$components/message/modals/MessageForward';
Expand Down Expand Up @@ -134,9 +144,59 @@
<Line size="300" />
</>
);
}
},

Check failure on line 147 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `,`
);

export const MessageReadReceiptItem = as<
'button',
{
room: Room;
eventId: string;
onClose?: () => void;
}
>(({ room, eventId, onClose, ...props }, ref) => {
const [open, setOpen] = useState(false);

const handleClose = () => {
setOpen(false);
onClose?.();
};

return (
<>
<Overlay open={open} backdrop={<OverlayBackdrop />}>
<OverlayCenter>
<FocusTrap
focusTrapOptions={{
initialFocus: false,
onDeactivate: handleClose,
clickOutsideDeactivates: true,
escapeDeactivates: stopPropagation,
}}
>
<Modal variant="Surface" size="300">
<EventReaders room={room} eventId={eventId} requestClose={handleClose} />
</Modal>
</FocusTrap>
</OverlayCenter>
</Overlay>
<MenuItem
size="300"
after={<Icon size="100" src={Icons.CheckTwice} />}
radii="300"
onClick={() => setOpen(true)}
{...props}
ref={ref}
aria-pressed={open}
>
<Text className={css.MessageMenuItemText} as="span" size="T300" truncate>
Read Receipts
</Text>
</MenuItem>
</>
);
});

export const MessageCopyLinkItem = as<
'button',
{
Expand Down Expand Up @@ -242,7 +302,7 @@
onUsernameClick: MouseEventHandler<HTMLButtonElement>;
onReplyClick: (
ev: Parameters<MouseEventHandler<HTMLButtonElement>>[0],
startThread?: boolean
startThread?: boolean,

Check failure on line 305 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `,`
) => void;
onEditId?: (eventId?: string) => void;
onReactionToggle: (targetEventId: string, key: string, shortcode?: string) => void;
Expand Down Expand Up @@ -282,7 +342,7 @@
lastTapRef.current = now;
}
},
[callback, delay]
[callback, delay],

Check failure on line 345 in src/app/features/room/message/Message.tsx

View workflow job for this annotation

GitHub Actions / Lint

Delete `,`
);
}

Expand Down Expand Up @@ -315,7 +375,7 @@
const visiblePronouns = filterPronounsByLanguage(
pronouns,
languageFilterEnabled,
selectedLanguages
selectedLanguages,
);

const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str);
Expand Down Expand Up @@ -377,7 +437,7 @@
msc2723ForwardedMessageProps,
...props
}: MessageProps & { className?: string; children?: ReactNode },
ref: any
ref: any,
) {
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
Expand All @@ -396,11 +456,6 @@
triggerTimelineRegroup();
};

if (mEvent.getClearContent()) {
setContentVersion((v) => (v === 0 ? 1 : v));
triggerTimelineRegroup();
}

mEvent.on(MatrixEventEvent.Decrypted, onUpdate);
mEvent.on(MatrixEventEvent.Replaced, onUpdate);
return () => {
Expand Down Expand Up @@ -666,7 +721,7 @@
evt.stopPropagation();
onResend?.(mEvent);
},
[mEvent, onResend]
[mEvent, onResend],
);

const handleDeleteFailedSendClick: MouseEventHandler<HTMLButtonElement> = useCallback(
Expand All @@ -675,7 +730,7 @@
evt.stopPropagation();
onDeleteFailedSend?.(mEvent);
},
[mEvent, onDeleteFailedSend]
[mEvent, onDeleteFailedSend],
);

const MSG_CONTENT_STYLE = { maxWidth: '100%' };
Expand Down Expand Up @@ -989,7 +1044,7 @@
`sticker-${mEvent.getId()}`,
mEvent.getContent().url ?? mEvent.getContent().file?.url ?? '',
mEvent.getContent().body,
mEvent.getContent().info
mEvent.getContent().info,
);
closeMenu();
}}
Expand Down Expand Up @@ -1062,7 +1117,11 @@
</MenuItem>
)}
{!hideReadReceipts && (
<MessageReadReceiptItem room={room} eventId={mEvent.getId() ?? ''} />
<MessageReadReceiptItem
room={room}
eventId={mEvent.getId() ?? ''}
onClose={closeMenu}
/>
)}
{isEdited && (
<MessageEditHistoryItem
Expand Down Expand Up @@ -1237,7 +1296,7 @@
canDelete?: boolean;
onReplyClick: (
ev: Parameters<MouseEventHandler<HTMLButtonElement>>[0],
startThread?: boolean
startThread?: boolean,
) => void;
messageSpacing: MessageSpacing;
hideReadReceipts?: boolean;
Expand All @@ -1261,7 +1320,7 @@
children,
...props
},
ref
ref,
) => {
const mx = useMatrixClient();
const stateEvent = typeof mEvent.getStateKey() === 'string';
Expand Down Expand Up @@ -1457,5 +1516,5 @@
</div>
</MessageBase>
);
}
},
);
Loading