Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e97a2c1

Browse files
tulirsumnerevans
authored andcommitted
Add support for rendering custom emojis in reactions
Signed-off-by: Sumner Evans <sumner@beeper.com>
1 parent 2ea8a03 commit e97a2c1

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/components/views/messages/ReactionsRowButton.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from "react";
1818
import classNames from "classnames";
1919
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
2020

21+
import { mediaFromMxc } from "../../../customisations/Media";
2122
import { _t } from "../../../languageHandler";
2223
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
2324
import dis from "../../../dispatcher/dispatcher";
@@ -121,6 +122,26 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
121122
}
122123
}
123124

125+
let reactionContent = (
126+
<span className="mx_ReactionsRowButton_content" aria-hidden="true">
127+
{content}
128+
</span>
129+
);
130+
if (content.startsWith("mxc://")) {
131+
const imageSrc = mediaFromMxc(content).srcHttp;
132+
if (imageSrc) {
133+
reactionContent = (
134+
<img
135+
className="mx_ReactionsRowButton_content"
136+
alt={content}
137+
src={imageSrc}
138+
width="16"
139+
height="16"
140+
/>
141+
);
142+
}
143+
}
144+
124145
return (
125146
<AccessibleButton
126147
className={classes}
@@ -130,9 +151,7 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
130151
onMouseOver={this.onMouseOver}
131152
onMouseLeave={this.onMouseLeave}
132153
>
133-
<span className="mx_ReactionsRowButton_content" aria-hidden="true">
134-
{content}
135-
</span>
154+
{reactionContent}
136155
<span className="mx_ReactionsRowButton_count" aria-hidden="true">
137156
{count}
138157
</span>

0 commit comments

Comments
 (0)