Files
discord-decomp/modules/messages/native/renderer/transformReactions.tsx
T
2026-11-01 12:12:55 +02:00

66 lines
2.2 KiB
TypeScript

// Metro module 7739 (f7740).
import * as _AccessibilityLabelOptimizationExperiment from "../../../a11y/native/AccessibilityLabelOptimizationExperiment";
import EmojiUtils from "../../../../utils/EmojiUtils";
import AvatarUtils from "../../../../utils/AvatarUtils";
import { getAccessibleEmojiDisplayName } from "../../../reactions/ReactionUtils";
import { buildPlatformedThemedEmojiColorPalette } from "../../../emojis/utils/EmojiColorUtils";
import { isIOS } from "../../../../utils/PlatformUtils";
import SentryUtils_native from "../../../../utils/SentryUtils.native";
export default function transformReactions({ reactions, animateEmoji }) {
const shouldSkipAccessibilityLabels = _AccessibilityLabelOptimizationExperiment.shouldSkipAccessibilityLabels();
return reactions.flatMap(({ emoji, ...rest }) => {
let displayName;
if (rest.count_details?.vote != null) {
return [];
}
let animated = animateEmoji;
if (animateEmoji) {
animated = emoji.animated;
}
const src = emoji.id == null ? EmojiUtils.getURL(emoji.name) : AvatarUtils.getEmojiURL({
id: emoji.id,
animated,
size: 48
});
if (shouldSkipAccessibilityLabels) {
let name = emoji.name;
if (name == null) {
name = "";
}
displayName = name;
} else {
displayName = getAccessibleEmojiDisplayName(rest.me, rest.count, emoji, rest.burst_count > 0);
}
const r54 = {
...rest,
emoji: {
...emoji,
id: emoji.id == null ? null : `${emoji.id}`,
src,
displayName,
animated
}
};
if (Array.isArray(r54.burst_colors) && r54.burst_colors.length > 0) {
r54.themedBurstColors = (0, buildPlatformedThemedEmojiColorPalette)({
colors: r54.burst_colors,
shouldProcessMobileColors: isIOS()
});
}
return r54;
}).map(({ burst_count, ...rest }) => {
let burst_count2 = burst_count;
if (burst_count2 === null) {
SentryUtils_native.captureMessage(`Null burst_count while transforming reaction: ${{
burst_count,
...rest
}}`);
burst_count2 = 0;
}
return {
...rest,
burst_count: burst_count2
};
});
};