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

Commit 40f0379

Browse files
committed
Put custom reaction images behind a labs flag
Signed-off-by: Sumner Evans <sumner@beeper.com>
1 parent c0822da commit 40f0379

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/components/views/messages/ReactionsRowButton.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import dis from "../../../dispatcher/dispatcher";
2525
import ReactionsRowButtonTooltip from "./ReactionsRowButtonTooltip";
2626
import AccessibleButton from "../elements/AccessibleButton";
2727
import MatrixClientContext from "../../../contexts/MatrixClientContext";
28+
import SettingsStore from "../../../settings/SettingsStore";
2829
interface IProps {
2930
// The event we're displaying reactions for
3031
mxEvent: MatrixEvent;
@@ -106,14 +107,15 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
106107
}
107108

108109
const room = this.context.getRoom(mxEvent.getRoomId());
110+
const customReactionImagesEnabled = SettingsStore.getValue("feature_render_reaction_images");
109111
let label: string | undefined;
110112
let customReactionName: string | undefined;
111113
if (room) {
112114
const senders: string[] = [];
113115
for (const reactionEvent of reactionEvents) {
114116
const member = room.getMember(reactionEvent.getSender()!);
115117
senders.push(member?.name || reactionEvent.getSender()!);
116-
if (reactionEvent.event.content?.["com.beeper.reaction.shortcode"]) {
118+
if (customReactionImagesEnabled && reactionEvent.event.content?.["com.beeper.reaction.shortcode"]) {
117119
customReactionName = reactionEvent.event.content?.["com.beeper.reaction.shortcode"];
118120
}
119121
}
@@ -134,7 +136,7 @@ export default class ReactionsRowButton extends React.PureComponent<IProps, ISta
134136
{content}
135137
</span>
136138
);
137-
if (content.startsWith("mxc://")) {
139+
if (customReactionImagesEnabled && content.startsWith("mxc://")) {
138140
const imageSrc = mediaFromMxc(content).srcHttp;
139141
if (imageSrc) {
140142
reactionContent = (

src/components/views/messages/ReactionsRowButtonTooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { _t } from "../../../languageHandler";
2222
import { formatCommaSeparatedList } from "../../../utils/FormattingUtils";
2323
import Tooltip from "../elements/Tooltip";
2424
import MatrixClientContext from "../../../contexts/MatrixClientContext";
25+
import SettingsStore from "../../../settings/SettingsStore";
2526
interface IProps {
2627
// The event we're displaying reactions for
2728
mxEvent: MatrixEvent;
@@ -42,13 +43,14 @@ export default class ReactionsRowButtonTooltip extends React.PureComponent<IProp
4243
const room = this.context.getRoom(mxEvent.getRoomId());
4344
let tooltipLabel: JSX.Element | undefined;
4445
if (room) {
46+
const customReactionImagesEnabled = SettingsStore.getValue("feature_render_reaction_images");
4547
const senders: string[] = [];
4648
let customReactionName: string | undefined;
4749
for (const reactionEvent of reactionEvents) {
4850
const member = room.getMember(reactionEvent.getSender()!);
4951
const name = member?.name ?? reactionEvent.getSender()!;
5052
senders.push(name);
51-
if (reactionEvent.event.content?.["com.beeper.reaction.shortcode"]) {
53+
if (customReactionImagesEnabled && reactionEvent.event.content?.["com.beeper.reaction.shortcode"]) {
5254
customReactionName = reactionEvent.event.content?.["com.beeper.reaction.shortcode"];
5355
}
5456
}

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,8 @@
10041004
"Enable new native OIDC flows (Under active development)": "Enable new native OIDC flows (Under active development)",
10051005
"Rust cryptography implementation": "Rust cryptography implementation",
10061006
"Font size": "Font size",
1007+
"Render custom images in reactions": "Render custom images in reactions",
1008+
"Sometimes referred to as \"custom emojis\".": "Sometimes referred to as \"custom emojis\".",
10071009
"Use custom size": "Use custom size",
10081010
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
10091011
"Show stickers button": "Show stickers button",

src/settings/Settings.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ export const SETTINGS: { [setting: string]: ISetting } = {
486486
default: "",
487487
controller: new FontSizeController(),
488488
},
489+
"feature_render_reaction_images": {
490+
isFeature: true,
491+
labsGroup: LabGroup.Messaging,
492+
displayName: _td("Render custom images in reactions"),
493+
description: _td('Sometimes referred to as "custom emojis".'),
494+
supportedLevels: LEVELS_FEATURE,
495+
default: false,
496+
},
489497
/**
490498
* With the transition to Compound we are moving to a base font size
491499
* of 16px. We're taking the opportunity to move away from the `baseFontSize`

0 commit comments

Comments
 (0)