diff --git a/src/app/components/RenderReplyContent.tsx b/src/app/components/RenderInlineContent.tsx
similarity index 71%
rename from src/app/components/RenderReplyContent.tsx
rename to src/app/components/RenderInlineContent.tsx
index 3a90ac7e1..8ce4049c1 100644
--- a/src/app/components/RenderReplyContent.tsx
+++ b/src/app/components/RenderInlineContent.tsx
@@ -10,25 +10,21 @@ Please see LICENSE file in root of repository for full details.
import React from 'react';
import { HTMLReactParserOptions } from 'html-react-parser';
import { Opts } from 'linkifyjs';
-import { Text } from 'folds';
+import { Icons, Text } from 'folds';
import {
- MessageAudioContent,
- MessageFileContent,
- MessageImageContent,
- MessageStickerContent,
- MessageVideoContent,
UnsupportedContent,
ReplyMEmote,
ReplyMNotice,
ReplyMText,
ReplyMLocation,
EmptyContent,
+ FallbackContent,
} from './message';
import { MsgType } from '../../types/matrix/common';
import { rContent } from '../../client/reader';
import { MessageEvent } from '../../types/matrix/room';
-type RenderReplyContentProps = {
+type RenderInlineContentProps = {
displayName: string;
eventType: string;
edited?: boolean;
@@ -38,7 +34,7 @@ type RenderReplyContentProps = {
linkifyOpts: Opts;
};
-export function RenderReplyContent({
+export function RenderInlineContent({
displayName,
eventType,
edited,
@@ -46,17 +42,19 @@ export function RenderReplyContent({
highlightRegex,
htmlReactParserOptions,
linkifyOpts,
-}: RenderReplyContentProps) {
+}: RenderInlineContentProps) {
if (eventType === MessageEvent.Sticker) {
return (
-
-
-
+
+
+ Sticker
+
+
);
}
if (eventType !== MessageEvent.RoomMessage) {
- return ;
+ return ;
}
const msgType = rContent.msgtype(content);
@@ -100,33 +98,41 @@ export function RenderReplyContent({
if (msgType === MsgType.Image) {
return (
-
-
-
+
+
+ Image
+
+
);
}
if (msgType === MsgType.Video) {
return (
-
-
-
+
+
+ Video
+
+
);
}
if (msgType === MsgType.Audio) {
return (
-
-
-
+
+
+ Audio
+
+
);
}
if (msgType === MsgType.File) {
return (
-
-
-
+
+
+ File
+
+
);
}
@@ -135,7 +141,7 @@ export function RenderReplyContent({
}
if (Object.keys(content).length === 0) {
- return ;
+ return ;
}
return (
diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx
index cb229192a..289ef351a 100644
--- a/src/app/components/message/MsgTypeRenderers.tsx
+++ b/src/app/components/message/MsgTypeRenderers.tsx
@@ -18,14 +18,9 @@ import {
AudioContent,
FileContent,
ImageContent,
- MessageBadEncryptedContent,
- MessageBrokenContent,
- MessageDeletedContent,
MessageEditedContent,
- UnsupportedMessageEventType,
- MessageUnsupportedContent,
VideoContent,
- MessageEmptyContent,
+ FallbackContent,
} from './content';
import { FALLBACK_MIMETYPE, getBlobSafeMimeType } from '../../utils/mimeTypes';
import { parseGeoUri, scaleYDimension } from '../../utils/common';
@@ -35,56 +30,81 @@ import { RenderBody } from './RenderBody';
import { rContent, rEncryptedFile, rInfo } from '../../../client/reader';
import { UrlPreviewCard, UrlPreviewHolder } from '../url-preview';
import { testMatrixTo } from '../../plugins/matrix-to';
+import { Code } from '../../styles/CustomHtml.css';
type TextProps = {
size?: 'T400' | 'T300';
+ truncate?: boolean;
};
-export function MBadEncrypted({ size }: TextProps) {
- return (
-
-
-
- );
-}
-
type RedactedContentProps = TextProps & {
reason?: string;
};
-export function RedactedContent({ size, reason }: RedactedContentProps) {
+export function RedactedContent({ size, reason, truncate }: RedactedContentProps) {
return (
-
-
-
+
+
+ {reason ? (
+ This message has been deleted. {reason}
+ ) : (
+ This message has been deleted
+ )}
+
+
);
}
-export function UnsupportedContent({ size, eventType }: TextProps & { eventType?: string }) {
+export function UnsupportedContent({
+ size,
+ truncate,
+ eventType,
+}: TextProps & { eventType?: string }) {
return (
-
- {eventType ? (
-
- ) : (
-
- )}
-
+
+
+ {eventType ? (
+ <>
+ Sent {eventType} event
+ >
+ ) : (
+ Unsupported message
+ )}
+
+
);
}
-export function BrokenContent({ size }: TextProps) {
+export function FailedToLoadContent({ size, truncate }: TextProps) {
return (
-
-
-
+
+
+ Failed to load message
+
+
);
}
-export function EmptyContent({ size }: TextProps) {
+export function BrokenContent({ size, truncate }: TextProps) {
return (
-
-
-
+
+
+ Broken message
+
+
+ );
+}
+
+export function EmptyContent({ size, truncate }: TextProps) {
+ return (
+
+
+ Empty message
+
+
);
}
@@ -464,7 +484,7 @@ export function MSticker({ content, mediaAutoLoad, outlineAttachment }: MSticker
const mxcUrl = rEncryptedFile.url(rContent.file(content)) ?? rContent.url(content);
if (typeof mxcUrl !== 'string') {
- return ;
+ return ;
}
const height = scaleYDimension(rInfo.w(imgInfo) || 152, 152, rInfo.h(imgInfo) || 152);
diff --git a/src/app/components/message/MsgTypeReplyRenderers.tsx b/src/app/components/message/MsgTypeReplyRenderers.tsx
index de1b31c09..264327c54 100644
--- a/src/app/components/message/MsgTypeReplyRenderers.tsx
+++ b/src/app/components/message/MsgTypeReplyRenderers.tsx
@@ -135,5 +135,9 @@ export function ReplyMLocation({ content }: ReplyMLocationProps) {
const location = parseGeoUri(geoUri);
if (!location) return ;
- return {geoUri};
+ return (
+
+ {geoUri}
+
+ );
}
diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx
index bd3b66147..288a7c243 100644
--- a/src/app/components/message/Reply.tsx
+++ b/src/app/components/message/Reply.tsx
@@ -14,15 +14,14 @@ import { HTMLReactParserOptions } from 'html-react-parser';
import { Opts } from 'linkifyjs';
import { LinePlaceholder } from './placeholder';
import { randomNumberBetween } from '../../utils/common';
-import { MessageFailedContent } from './content';
import { useRoomEvent } from '../../hooks/useRoomEvent';
import colorMXID from '../../../util/colorMXID';
import { GetMemberPowerTag } from '../../hooks/useMemberPowerTag';
import { GetRoomMemberNameCallback } from '../../hooks/useRoomMembers';
import { rContent, rUnsigned } from '../../../client/reader';
import { TimelineView } from '../../../client/room';
-import { RenderReplyContent } from '../RenderReplyContent';
-import { RedactedContent } from './MsgTypeRenderers';
+import { RenderInlineContent } from '../RenderInlineContent';
+import { FailedToLoadContent, RedactedContent } from './MsgTypeRenderers';
import { HoverUnderline } from '../../styles/Text.css';
import { useObservableValueOptionally } from '../../hooks/useObservableValue';
import { getLatestEditEvent } from '../../utils/room';
@@ -144,7 +143,7 @@ export function Reply({
inline
>
{(contentEvent) => (
-
{replyEvent && renderEventContent(replyEvent)}
- {replyEvent === null && (
-
-
-
- )}
+ {replyEvent === null && }
{replyEvent === undefined && (
(
- ({ reason, ...props }, ref) => (
-
-
- {reason ? (
- This message has been deleted. {reason}
- ) : (
- This message has been deleted
- )}
+type FallbackContentProps = {
+ iconSrc: IconSrc;
+ children?: ReactNode;
+ variant?: ContainerColor;
+};
+export function FallbackContent({ variant, iconSrc, children }: FallbackContentProps) {
+ return (
+
+
+ {children}
- )
-);
-
-export const MessageUnsupportedContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Unsupported message
-
-));
-
-export const UnsupportedMessageEventType = as<'div', { eventType: string; children?: never }>(
- ({ eventType, ...props }, ref) => (
-
-
- Sent {eventType} event
-
- )
-);
-
-export const MessageFailedContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Failed to load message
-
-));
-
-export const MessageBadEncryptedContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Unable to decrypt message
-
-));
-
-export const MessageNotDecryptedContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- This message is not decrypted yet
-
-));
-
-export const MessageBrokenContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Broken message
-
-));
+ );
+}
export const MessageEmptyContent = as<'div', { children?: never }>(({ ...props }, ref) => (
@@ -83,38 +42,3 @@ export const MessageEditedContent = as<'span', { children?: never }>(({ ...props
{' (edited)'}
));
-
-export const MessageStickerContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Sticker
-
-));
-
-export const MessageImageContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Image
-
-));
-
-export const MessageVideoContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Video
-
-));
-
-export const MessageAudioContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- Audio
-
-));
-
-export const MessageFileContent = as<'div', { children?: never }>(({ ...props }, ref) => (
-
-
- File
-
-));
diff --git a/src/app/features/room-nav/ThreadNavItems.tsx b/src/app/features/room-nav/ThreadNavItems.tsx
index 47a2389bd..87415adfb 100644
--- a/src/app/features/room-nav/ThreadNavItems.tsx
+++ b/src/app/features/room-nav/ThreadNavItems.tsx
@@ -21,7 +21,7 @@ import * as css from './styles.css';
import { MessageContent } from '../../components/MessageContent';
import { useClient } from '../../hooks/useClient';
import { NavItemContent } from '../../components/nav/styles.css';
-import { RenderReplyContent } from '../../components/RenderReplyContent';
+import { RenderInlineContent } from '../../components/RenderInlineContent';
import { rContent, rUnsigned } from '../../../client/reader';
import { getLatestEditEvent } from '../../utils/room';
import { RedactedContent } from '../../components/message';
@@ -33,6 +33,7 @@ import {
renderMatrixMention,
} from '../../plugins/react-custom-html-parser';
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
+import { getMxIdLocalPart } from '../../utils/matrix';
type ThreadNavItemProps = {
thread: ThreadTimeline;
@@ -66,7 +67,7 @@ function ThreadNavItem({
redactedEvents?.has(event.event_id) || !!rUnsigned.redactedBecause(event.unsigned);
if (redacted) {
- return ;
+ return ;
}
return (
@@ -78,7 +79,7 @@ function ThreadNavItem({
inline
>
{(contentEvent) => (
- evt.preventDefault()),
- (userId) => userId,
+ (userId) => getMxIdLocalPart(userId) ?? userId,
(roomId) => ct.roomToName.read.get(roomId) ?? roomId
)
),
@@ -160,8 +161,7 @@ export function ThreadNavItems({
getReactCustomHtmlInlineParser(ct, timeline.roomId, {
linkifyOpts,
useAuthentication,
- handleMentionClick: () => undefined,
- getMemberName: (userId) => userId,
+ getMemberName: (userId) => getMxIdLocalPart(userId) ?? userId,
getRoomName: (roomId) => ct.roomToName.read.get(roomId) ?? roomId,
}),
[ct, timeline, linkifyOpts, useAuthentication]