Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render image reactions #22

Open
wants to merge 3 commits into
base: sc
Choose a base branch
from
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
16 changes: 13 additions & 3 deletions src/components/views/messages/ReactionsRowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from "react";
import classNames from "classnames";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";

import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { _t } from "../../../languageHandler";
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
import dis from "../../../dispatcher/dispatcher";
Expand Down Expand Up @@ -130,9 +131,18 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
onMouseOver={this.onMouseOver}
onMouseLeave={this.onMouseLeave}
>
<span className="mx_ReactionsRowButton_content" aria-hidden="true">
{content}
</span>
{content.startsWith("mxc://") ? (
<img
className="mx_ReactionsRowButton_content"
src={MatrixClientPeg.get().mxcUrlToHttp(content)}
width="20"
height="20"
/>
) : (
<span className="mx_ReactionsRowButton_content" aria-hidden="true">
{content}
</span>
)}
<span className="mx_ReactionsRowButton_count" aria-hidden="true">
{count}
</span>
Expand Down
12 changes: 11 additions & 1 deletion src/components/views/messages/ReactionsRowButtonTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ interface IProps {
visible: boolean;
}

const getCustomReactionName = (reactionEvents: Set<MatrixEvent>) => {
for (const event of reactionEvents) {
if (event.event.content?.["com.beeper.reaction.shortcode"]) {
return event.event.content?.["com.beeper.reaction.shortcode"];
}
}

return '';
};

export default class ReactionsRowButtonTooltip extends React.PureComponent<IProps> {
public static contextType = MatrixClientContext;
public context!: React.ContextType<typeof MatrixClientContext>;
Expand All @@ -48,7 +58,7 @@ export default class ReactionsRowButtonTooltip extends React.PureComponent<IProp
const name = member?.name ?? reactionEvent.getSender()!;
senders.push(name);
}
const shortName = unicodeToShortcode(content);
const shortName = unicodeToShortcode(content) || getCustomReactionName(reactionEvents);
tooltipLabel = (
<div>
{_t(
Expand Down