Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions src/components/views/dialogs/ForwardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
import { OverflowTileView } from "../rooms/OverflowTileView";
import { attachMentions } from "../rooms/SendMessageComposer";

const AVATAR_SIZE = 30;

Expand Down Expand Up @@ -178,7 +179,7 @@ const Entry: React.FC<IEntryProps<any>> = ({ room, type, content, matrixClient:
);
};

const transformEvent = (event: MatrixEvent): { type: string; content: IContent } => {
const transformEvent = (event: MatrixEvent, userId: string): { type: string; content: IContent } => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was just about squeaking by without doc as an internal function, although it still wasn't super clear in what way it's transforming it. Now it has another param, I think it really does need doc as I have absolutely no guesses as to what this function might do with the user ID it's been given.

const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
"m.relates_to": _, // strip relations - in future we will attach a relation pointing at the original event
Expand Down Expand Up @@ -213,6 +214,9 @@ const transformEvent = (event: MatrixEvent): { type: string; content: IContent }
};
}

// Force an empty m.mentions property as there is no EditorModel to parse pills from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are explicitly forwarding an event here, I'd make this comment closer to what you have in the PR description, ie. talking about the fact we're stripping mentions from a forwarded message and why.

attachMentions(userId, content, null, undefined);

return { type, content };
};

Expand All @@ -223,7 +227,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
cli.getProfileInfo(userId).then((info) => setProfileInfo(info));
}, [cli, userId]);

const { type, content } = transformEvent(event);
const { type, content } = transformEvent(event, userId);

// For the message preview we fake the sender as ourselves
const mockEvent = new MatrixEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ describe("ForwardDialog", () => {

await userEvent.keyboard("[Enter]");
expect(mockClient.sendEvent).toHaveBeenCalledWith("A", "m.room.message", {
body: "Hello world!",
msgtype: "m.text",
"body": "Hello world!",
"msgtype": "m.text",
"m.mentions": {},
});
});

Expand Down
Loading