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

123 lines
5.3 KiB
TypeScript

// Metro module 15389 (f15390).
import { useEffect, useCallback } from "react";
import { View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import GuildStore from "../../../stores/GuildStore";
import { createICYMIStyles } from "./createICYMIStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import GuildActionCreators from "../../../actions/GuildActionCreators";
import ICYMIActionCreators from "../ICYMIActionCreators";
import { navigateToPost } from "./ICYMIShared";
import { openChannelLongPressActionSheet } from "../../channel/native/openChannelLongPressActionSheet";
import { useGravityMessage } from "../ICYMIUtils";
import useChannelName from "../../channel/useChannelName";
import ICYMICardInCard from "./ICYMICardInCard";
import { intl, t } from "../../../intl/index.native";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import { Text } from "../../../design/components/Text/native/Text";
import MarkupUtils from "../../markup/MarkupUtils";
import ICYMIMediaMosaic from "./media/ICYMIMediaMosaic";
import ICYMICardInteractionRow from "./ICYMICardInteractionRow";
let styles;
const ICYMIForumThreadRow = function ICYMIForumThreadRow(props) {
let author;
const { channel, message, visible } = props;
author = void 0;
const r17 = styles();
const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(channel == null ? void 0 : channel.getGuildId()));
author = message.author;
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channel.parent_id));
const r39 = [author.id, ,];
const id = stateFromStores?.id;
const r40 = () => {
if (stateFromStores?.id != null) {
GuildActionCreators.requestMembersById(stateFromStores?.id, [author.id]);
}
};
r39[1] = id;
useEffect(r40, r39);
const callback = useCallback(() => {
ICYMIActionCreators.itemInteracted(message.id, "forum_thread", "press_forum_thread");
ICYMIActionCreators.feedItemActioned({
itemId: message.id,
itemType: "forum_thread",
actionParameters: {
actionGestureType: "press",
actionTargetElement: "item_container",
actionIntentType: "navigate",
actionDestinationType: "channel"
}
});
if (channel != null && stateFromStores != null) {
navigateToPost(channel.id, stateFromStores.id, message.id);
}
}, [channel, stateFromStores, message.id]);
const callback2 = useCallback(() => {
if (channel.parent_id != null) {
ICYMIActionCreators.itemInteracted(message.id, "forum_thread", "long_press_forum_thread");
ICYMIActionCreators.feedItemActioned({
itemId: message.id,
itemType: "forum_thread",
actionParameters: {
actionGestureType: "long_press",
actionTargetElement: "item_container",
actionIntentType: "open",
actionDestinationType: null
}
});
openChannelLongPressActionSheet(channel.parent_id);
}
}, [channel.parent_id, message.id]);
const gravityMessage = useGravityMessage(message);
const channelName = useChannelName(channel);
return channel == null ? null : channel.guild_id == null ? null : stateFromStores == null ? null : author == null ? null : stateFromStores2 == null ? null : <ICYMICardInCard actionLabel={intl.string(t.bYNuVx)} id={gravityMessage.id} interactionType="forum_thread" channelId={channel.parent_id} timestamp={SnowflakeUtils.extractTimestamp(gravityMessage.id)} onHeaderPress={callback} onHeaderLongPress={callback2} message={gravityMessage} shouldFeatureUser>
<PressableHighlight onPress={callback} onLongPress={callback2} accessibilityRole="button" unstable_pressDelay={130} style={r17.pressable}>
<View style={r17.container}>
<Text variant="text-lg/semibold" color="mobile-text-heading-primary">{channelName}</Text>
<Text variant="text-md/normal" color="text-subtle" style={r17.subtitle} lineClamp={5}>
{MarkupUtils.parseInlineReply(message.content, true)}
</Text>
<ICYMIMediaMosaic message={message} visible={visible} itemType="forum_thread" />
</View>
</PressableHighlight>
<View style={r17.footer}>
<View style={r17.ICYMICardInteractionRow}>
<ICYMICardInteractionRow message={gravityMessage} channel={channel} guild={stateFromStores} backgroundVariant="base" id={gravityMessage.id} itemType="forum_thread" />
</View>
</View>
</ICYMICardInCard>;
};
styles = createICYMIStyles((a0) => ({
pressable: {
flex: 1,
paddingLeft: a0.inset
},
container: {
marginHorizontal: a0.margin
},
subtitle: {
marginTop: Module712.space.PX_8,
marginBottom: a0.margin
},
footer: {
justifyContent: "flex-end",
paddingLeft: a0.inset,
marginTop: a0.margin,
gap: a0.margin
},
threadAsComments: {
marginHorizontal: a0.margin
},
ICYMICardInteractionRow: {
marginHorizontal: a0.margin,
marginBottom: a0.margin
}
}));
export default function ForumThreadRowWrapper(props) {
return <ICYMIForumThreadRow message={props.message} channel={props.threadChannel} visible={props.visible} />;
};
export const MAX_AVATARS_IN_PILE = 3;
export { ICYMIForumThreadRow };