126 lines
5.8 KiB
TypeScript
126 lines
5.8 KiB
TypeScript
// Metro module 15359 (f15360).
|
|
import { memo, useEffect, useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { ITEM_PADDING } from "./DesignConstants";
|
|
import { createICYMIStyles } from "./createICYMIStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import GuildActionCreators from "../../../actions/GuildActionCreators";
|
|
import ICYMIActionCreators from "../ICYMIActionCreators";
|
|
import { openChannelLongPressActionSheet } from "../../channel/native/openChannelLongPressActionSheet";
|
|
import { showLongPressMessageActionSheet } from "../../messages/native/long_press/showLongPressMessageActionSheet";
|
|
import { navigateToPost } from "./ICYMIShared";
|
|
import { useGravityMessage } from "../ICYMIUtils";
|
|
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 getChannelA11yLabel, { getChannelA11yHint } from "../../channel/getChannelA11yLabel";
|
|
import { MessageRowContent } from "./ICYMIMessageRow";
|
|
import ICYMICardInteractionRow from "./ICYMICardInteractionRow";
|
|
let Component;
|
|
const styles = createICYMIStyles((a0) => ({
|
|
pressable: {
|
|
flex: 1,
|
|
paddingLeft: a0.inset
|
|
},
|
|
footer: {
|
|
marginVertical: a0.margin,
|
|
gap: Module712.space.PX_8,
|
|
paddingHorizontal: ITEM_PADDING,
|
|
marginLeft: a0.inset
|
|
}
|
|
}));
|
|
Component = memo(function({ unread, message, guild, channel, visible }) {
|
|
const stateFromStores2 = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.isChannelMuted(channel.getGuildId(), channel.id));
|
|
const r14 = styles();
|
|
useEffect(() => {
|
|
if (guild?.id != null) {
|
|
GuildActionCreators.requestMembersById(guild?.id, message.author.id);
|
|
}
|
|
}, [guild?.id, message.author.id]);
|
|
const callback3 = useCallback(() => {
|
|
ICYMIActionCreators.itemInteracted(message.id, "announcement", "long_press_channel");
|
|
ICYMIActionCreators.feedItemActioned({
|
|
itemId: message.id,
|
|
itemType: "announcement",
|
|
actionParameters: {
|
|
actionGestureType: "long_press",
|
|
actionTargetElement: "item_header",
|
|
actionIntentType: "open",
|
|
actionDestinationType: "channel"
|
|
}
|
|
});
|
|
openChannelLongPressActionSheet(channel.id);
|
|
}, [channel.id, message.id]);
|
|
const callback = useCallback(() => {
|
|
ICYMIActionCreators.itemInteracted(message.id, "announcement", "long_press_message");
|
|
ICYMIActionCreators.feedItemActioned({
|
|
itemId: message.id,
|
|
itemType: "announcement",
|
|
actionParameters: {
|
|
actionGestureType: "long_press",
|
|
actionTargetElement: "item_container",
|
|
actionIntentType: "open",
|
|
actionDestinationType: "channel"
|
|
}
|
|
});
|
|
showLongPressMessageActionSheet({
|
|
channel,
|
|
message,
|
|
user: UserStore.getUser(message.author.id)
|
|
});
|
|
}, [channel, message]);
|
|
const callback2 = useCallback(() => {
|
|
ICYMIActionCreators.itemInteracted(message.id, "announcement", "press_message");
|
|
ICYMIActionCreators.feedItemActioned({
|
|
itemId: message.id,
|
|
itemType: "announcement",
|
|
actionParameters: {
|
|
actionGestureType: "press",
|
|
actionTargetElement: "item_container",
|
|
actionIntentType: "navigate",
|
|
actionDestinationType: "channel"
|
|
}
|
|
});
|
|
if (message != null) {
|
|
ICYMIActionCreators.ackGravityItems([{
|
|
id: message.id,
|
|
timestamp: Date.now()
|
|
}]);
|
|
navigateToPost(channel.id, guild.id, message.id);
|
|
}
|
|
}, [message, channel.id, guild.id]);
|
|
const gravityMessage = useGravityMessage(message);
|
|
return <ICYMICardInCard actionLabel={intl.string(t["8P08G9"])} id={message.id} interactionType="announcement" channelId={channel.id} timestamp={SnowflakeUtils.extractTimestamp(message.id)} onHeaderPress={callback2} onHeaderLongPress={callback3} message={gravityMessage} shouldFeatureUser>
|
|
<PressableHighlight onPress={callback2} onLongPress={callback} accessibilityRole="button" accessibilityLabel={getChannelA11yLabel({
|
|
channel,
|
|
unread
|
|
})} accessibilityHint={getChannelA11yHint({
|
|
channel,
|
|
muted: stateFromStores2
|
|
})} unstable_pressDelay={130} style={r14.pressable}>
|
|
<MessageRowContent message={message} channel={channel} guild={guild} lineClamp={5} visible={visible} />
|
|
</PressableHighlight>
|
|
<View style={r14.footer}>
|
|
<ICYMICardInteractionRow message={message} channel={channel} guild={guild} backgroundVariant="base" id={message.id} itemType="announcement" />
|
|
</View>
|
|
</ICYMICardInCard>;
|
|
});
|
|
export default function AnnouncementMessageRowWrapper(props) {
|
|
let author;
|
|
const { unread, message: message2, visible } = props;
|
|
author = void 0;
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(message2.getChannelId()));
|
|
const stateFromStores2 = useStateFromStores([GuildStore], () => GuildStore.getGuild(stateFromStores?.guild_id));
|
|
const gravityMessage = useGravityMessage(message2);
|
|
author = gravityMessage?.author;
|
|
const stateFromStores3 = useStateFromStores([RelationshipStore], () => RelationshipStore.isBlockedOrIgnored(author?.id));
|
|
return stateFromStores == null ? null : stateFromStores2 == null ? null : gravityMessage == null ? null : author == null ? null : stateFromStores3 ? null : <Component unread={unread} message={gravityMessage} channel={stateFromStores} guild={stateFromStores2} visible={visible} />;
|
|
};
|