Files
discord-decomp/modules/reactions/native/MessageReactions.tsx
T
2026-11-01 12:12:55 +02:00

45 lines
2.0 KiB
TypeScript

// Metro module 9451 (f9452).
import { useMemo } from "react";
import MessageStore from "../../../stores/MessageStore";
import { useStateFromStores } from "../../../_bundle/Module589";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import { MessageReactionsContent, MessageReactionsEmpty } from "./MessageReactionsContent";
let c6231_6 = [];
export default function MessageReactions(props) {
const { channelId: channelId2, messageId: messageId2, emoji, reactions, isSelectedBurst = false, ...props2 } = props;
let c17218_0;
c17218_0 = void 0;
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.MESSAGE_REACTIONS).analyticsLocations;
const channelId = channelId2;
const messageId = messageId2;
const stateFromStores = useStateFromStores([MessageStore], () => {
const message = MessageStore.getMessage(channelId, messageId);
return message != null ? message.reactions : c6231_6;
}, [channelId, messageId]);
const memo = useMemo(() => stateFromStores.filter((stateFromStore) => stateFromStore.count_details?.vote == null), [stateFromStores]);
const r39 = reactions != null ? reactions.length > 0 ? reactions : memo : memo;
const reactions2 = [];
c17218_0 = reactions2;
r39.forEach((item) => {
if (item.burst_count > 0 && item.count > 0) {
c17218_0.push({
...item,
count: 0
});
c17218_0.push({
...item,
burst_count: 0
});
} else {
c17218_0.push({
...item
});
}
});
reactions2.sort((a, b) => (b.burst_count > 0 ? b.burst_count : b.count) - (a.burst_count > 0 ? a.burst_count : a.count));
return <AnalyticsLocationProvider value={analyticsLocations}>
{reactions2.length > 0 ? <MessageReactionsContent channelId={channelId} messageId={messageId} emoji={emoji} reactions={reactions2} isSelectedBurst={isSelectedBurst} {...props2} /> : <MessageReactionsEmpty />}
</AnalyticsLocationProvider>;
};