diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx
index e6d9358c0..321d04296 100644
--- a/src/app/components/RenderMessageContent.tsx
+++ b/src/app/components/RenderMessageContent.tsx
@@ -448,8 +448,11 @@ function RenderMessageContentInternal({
}
/>
);
- if (content['org.matrix.msc3381.poll.start'] && mEvent && mx && room)
- return ;
+ if (content['org.matrix.msc3381.poll.start']) {
+ if (mEvent && mx && room)
+ return ;
+ else return ;
+ }
return (
-
+
{questionBody}
-
+
{answers.map((item) => {
const optionBody = item['org.matrix.msc1767.text'];
const voteCount = votes[item.id];
@@ -210,7 +210,7 @@ export function PollEvent({ content, mEvent, mx, room }: PollEventProps) {
);
})}
-
+
{isDisclosed || isEnded
? `${totalVotes} vote${totalVotes !== 1 ? 's' : ''} ${totalVotes !== voters.size ? `by ${voters.size} voter${voters.size !== 1 ? 's' : ''}` : ''}`
diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx
index 725b5089b..fb418c1d7 100644
--- a/src/app/components/message/Reply.tsx
+++ b/src/app/components/message/Reply.tsx
@@ -44,6 +44,7 @@ import {
} from './content';
import * as css from './Reply.css';
import { LinePlaceholder } from './placeholder';
+import { M_POLL_START } from 'matrix-js-sdk';
const ROOM_REPLY_TIMELINE_EVENT_TYPES = new Set([
EventType.RoomMessage as string,
@@ -203,6 +204,11 @@ export const Reply = as<'div', ReplyProps>(
const mx = useMatrixClient();
const { body, formatted_body: formattedBody, format } = replyEvent?.getContent() ?? {};
+ const extensibleContent = replyEvent?.getContent()['org.matrix.msc1767.text'] as
+ | string
+ | { body: string }
+ | undefined;
+ const extensibleBody = (extensibleContent as { body: string })?.body ?? extensibleContent;
const sender = replyEvent?.getSender();
const eventType = replyEvent?.getType();
@@ -233,7 +239,7 @@ export const Reply = as<'div', ReplyProps>(
const isFormattedReply =
format === 'org.matrix.custom.html' && typeof formattedBody === 'string';
const hasPlainTextReply = typeof body === 'string' && body !== '';
-
+ const hasExtensibleBody = typeof extensibleBody === 'string' && extensibleBody !== '';
// An encrypted event that hasn't been decrypted yet (keys pending) has an
// empty result from getClearContent(). Treat it as still-loading rather
// than a failure so the UI shows a placeholder instead of MessageFailedContent
@@ -267,8 +273,12 @@ export const Reply = as<'div', ReplyProps>(
}),
[mx, room.roomId, mentionClickHandler, nicknames, settingsLinkBaseUrl]
);
-
- if (isFormattedReply && formattedBody !== '') {
+ if(eventType === M_POLL_START.name){
+ const question = (replyEvent?.getContent()[M_POLL_START.name] as {question: {'org.matrix.msc1767.text'?: string, body?: string}})?.question;
+ image = Icons.UnorderList;
+ bodyJSX = `'s poll asking ${question['org.matrix.msc1767.text'] ?? question.body ?? ''}`
+ }
+ else if (isFormattedReply && formattedBody !== '') {
const sanitizedHtml = sanitizeReplyFormattedPreview(formattedBody);
if (shouldParseReplyFormattedPreview(sanitizedHtml)) {
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
@@ -284,10 +294,16 @@ export const Reply = as<'div', ReplyProps>(
} else if (hasPlainTextReply) {
const strippedBody = trimReplyFromBody(body).replaceAll(/(?:\r\n|\r|\n)/g, ' ');
bodyJSX = scaleSystemEmoji(strippedBody);
+ } else if (hasExtensibleBody) {
+ const strippedBody = trimReplyFromBody(extensibleBody).replaceAll(/(?:\r\n|\r|\n)/g, ' ');
+ bodyJSX = scaleSystemEmoji(strippedBody);
}
} else if (hasPlainTextReply) {
const strippedBody = trimReplyFromBody(body).replaceAll(/(?:\r\n|\r|\n)/g, ' ');
bodyJSX = scaleSystemEmoji(strippedBody);
+ } else if (hasExtensibleBody) {
+ const strippedBody = trimReplyFromBody(extensibleBody).replaceAll(/(?:\r\n|\r|\n)/g, ' ');
+ bodyJSX = scaleSystemEmoji(strippedBody);
} else if (eventType === EventType.RoomMember && !!replyEvent) {
const parsedMemberEvent = parseMemberEvent(replyEvent);
image = parsedMemberEvent.icon;
diff --git a/src/app/features/message-search/SearchResultGroup.tsx b/src/app/features/message-search/SearchResultGroup.tsx
index 93e8db401..ff1e72264 100644
--- a/src/app/features/message-search/SearchResultGroup.tsx
+++ b/src/app/features/message-search/SearchResultGroup.tsx
@@ -171,6 +171,8 @@ export function SearchResultGroup({
linkifyOpts={linkifyOpts}
highlightRegex={highlightRegex}
outlineAttachment
+ mx={mx}
+ room={room}
/>
);
},
diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx
index f13fde410..fa1f9ed87 100644
--- a/src/app/features/room/RoomInput.tsx
+++ b/src/app/features/room/RoomInput.tsx
@@ -163,7 +163,7 @@ import { PollDialog } from './add-poll';
// Returns the event ID of the most recent non-reaction/non-edit event in a thread,
// falling back to the thread root if no replies exist yet.
-const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
+export const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
const thread = room.getThread(threadRootId);
const threadEvents: MatrixEvent[] = thread?.events ?? [];
const filtered = threadEvents.filter(
@@ -192,7 +192,10 @@ const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
return threadRootId;
};
-const getReplyContent = (replyDraft: IReplyDraft | undefined, room?: Room): IEventRelation => {
+export const getReplyContent = (
+ replyDraft: IReplyDraft | undefined,
+ room?: Room
+): IEventRelation => {
if (!replyDraft) return {};
const relatesTo: IEventRelation = {};
@@ -1817,7 +1820,13 @@ export const RoomInput = forwardRef(
/>
)}
{showPollPicker && (
- setShowPollPicker(false)} mx={mx} roomId={roomId} />
+ setShowPollPicker(false)}
+ mx={mx}
+ room={room}
+ replyDraft={replyDraft}
+ clearReplyDraft={() => setReplyDraft(undefined)}
+ />
)}
);
diff --git a/src/app/features/room/ThreadBrowser.tsx b/src/app/features/room/ThreadBrowser.tsx
index 766889032..a5dd56382 100644
--- a/src/app/features/room/ThreadBrowser.tsx
+++ b/src/app/features/room/ThreadBrowser.tsx
@@ -247,6 +247,9 @@ function ThreadPreview({ room, thread, onClick, onJump }: ThreadPreviewProps) {
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
outlineAttachment
+ mEvent={rootEvent}
+ mx={mx}
+ room={room}
/>
);
}}
diff --git a/src/app/features/room/add-poll/PollDialog.css.tsx b/src/app/features/room/add-poll/PollDialog.css.tsx
index af6c2373b..3bbf5dbbd 100644
--- a/src/app/features/room/add-poll/PollDialog.css.tsx
+++ b/src/app/features/room/add-poll/PollDialog.css.tsx
@@ -21,11 +21,12 @@ export const PollDialogAnswerBody = style({
export const PollDialogAnswerInput = style({ width: '100%' });
export const PollDialogMaxSelectionNumber = style({ width: toRem(80) });
-export const PollDialogMaxSelectionSlider = style({
- width: '100%',
- cursor: 'pointer',
- appearance: 'none',
- height: toRem(6),
- borderRadius: config.radii.Pill,
- backgroundColor: color.Background.ContainerLine,
- accentColor: color.Primary.Main,});
+export const PollDialogMaxSelectionSlider = style({
+ width: '100%',
+ cursor: 'pointer',
+ appearance: 'none',
+ height: toRem(6),
+ borderRadius: config.radii.Pill,
+ backgroundColor: color.Background.ContainerLine,
+ accentColor: color.Primary.Main,
+});
diff --git a/src/app/features/room/add-poll/PollDialog.tsx b/src/app/features/room/add-poll/PollDialog.tsx
index 813c29ca5..cb66c852c 100644
--- a/src/app/features/room/add-poll/PollDialog.tsx
+++ b/src/app/features/room/add-poll/PollDialog.tsx
@@ -23,18 +23,23 @@ import { randomStr } from '$utils/common';
import { SettingTile } from '$components/setting-tile';
import { SequenceCard } from '$components/sequence-card';
import { SequenceCardStyle } from '$features/settings/styles.css';
-import type { IContent, MatrixClient, TimelineEvents } from 'matrix-js-sdk';
+import type { IContent, MatrixClient, Room, TimelineEvents } from 'matrix-js-sdk';
import { M_POLL_KIND_DISCLOSED, M_POLL_KIND_UNDISCLOSED, M_POLL_START } from 'matrix-js-sdk';
import { isKeyHotkey } from 'is-hotkey';
import * as css from './PollDialog.css';
+import type { IReplyDraft } from '$state/room/roomInputDrafts';
+import { getReplyContent } from '../RoomInput';
type PollDialogProps = {
onCancel: () => void;
mx: MatrixClient;
- roomId: string;
+ room: Room;
+ replyDraft?: IReplyDraft;
+ clearReplyDraft?: () => void;
};
-export function PollDialog({ onCancel, mx, roomId }: PollDialogProps) {
+export function PollDialog({ onCancel, mx, room, replyDraft, clearReplyDraft }: PollDialogProps) {
+ const roomId = room.roomId;
const [isDisclosed, setIsDisclosed] = useState(true);
const [maxSelections, setMaxSelections] = useState(1);
const [inputValue, setInputValue] = useState(1);
@@ -75,6 +80,10 @@ export function PollDialog({ onCancel, mx, roomId }: PollDialogProps) {
},
'org.matrix.msc1767.text': `New poll\n Question: ${title.current}\nAnswers:\n ${answers.map((item) => item['org.matrix.msc1767.text']).join('\n')}`,
};
+ if (replyDraft && clearReplyDraft) {
+ pollContent['m.relates_to'] = getReplyContent(replyDraft, room);
+ clearReplyDraft();
+ }
mx.sendEvent(
roomId,
@@ -113,7 +122,7 @@ export function PollDialog({ onCancel, mx, roomId }: PollDialogProps) {
- New Poll
+ {`New Poll ${replyDraft ? '(reply / thread)' : ''}`}
)}
+
{renderContent(pinnedEvent.getType(), false, pinnedEvent, displayName, getContent)}
+
);
}
@@ -410,6 +413,9 @@ export const RoomPinMenu = forwardRef(
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
outlineAttachment
+ mEvent={event}
+ mx={mx}
+ room={room}
/>
);
},
@@ -474,6 +480,9 @@ export const RoomPinMenu = forwardRef(
urlPreview={urlPreview}
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
+ mx={mx}
+ room={room}
+ mEvent={event}
/>
);
}
@@ -515,6 +524,33 @@ export const RoomPinMenu = forwardRef(
/>
);
},
+ [M_POLL_START.name]: (event, displayName, getContent) => {
+ if (event.isRedacted()) {
+ const unsigned = event.getUnsigned();
+ const redactionContent = unsigned.redacted_because?.content as
+ | { reason?: string }
+ | undefined;
+ return ;
+ }
+
+ return (
+
+ );
+ },
},
undefined,
(event) => {
diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx
index 6f52925fa..750f4c281 100644
--- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx
+++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx
@@ -514,6 +514,8 @@ export function useTimelineEventRenderer({
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
outlineAttachment={messageLayout === MessageLayout.Bubble}
+ mx={mx}
+ room={room}
/>
)}
@@ -682,6 +684,8 @@ export function useTimelineEventRenderer({
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
outlineAttachment={messageLayout === MessageLayout.Bubble}
+ mx={mx}
+ room={room}
/>
);
}
diff --git a/src/app/pages/client/inbox/Notifications.tsx b/src/app/pages/client/inbox/Notifications.tsx
index 892409da7..d7e0c5ab6 100644
--- a/src/app/pages/client/inbox/Notifications.tsx
+++ b/src/app/pages/client/inbox/Notifications.tsx
@@ -286,7 +286,8 @@ function RoomNotificationsGroupComp({
if (event.unsigned?.redacted_because) {
return ;
}
-
+ const evtTimeline = room.getTimelineForEvent(event.event_id);
+ const mEvent = evtTimeline?.getEvents().find((e) => e.getId() === event.event_id);
return (
);
},
@@ -356,6 +360,9 @@ function RoomNotificationsGroupComp({
urlPreview={urlPreview}
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
+ mx={mx}
+ room={room}
+ mEvent={mEvent}
/>
);
}