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

151 lines
6.4 KiB
TypeScript

// Metro module 10932 (f10933).
import { useRef, useCallback } from "react";
import { View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import MessageStore from "../../../stores/MessageStore";
import SummaryStore from "../SummaryStore";
import { AnalyticsSections, MessageFlags } from "../../../Constants";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { computeCanStartPublicThread } from "../../threads/ThreadHooks";
import { presentFailedToast, presentError } from "../../toast/native/ToastUtils";
import { intl, t } from "../../../intl/index.native";
import { getChannelPermalink } from "../../../utils/ChannelUtils";
import { showShareActionSheet } from "../../action_sheet/native/showShareActionSheet";
import ThreadActionCreators from "../../threads/ThreadActionCreators";
import DraftActionCreators from "../../../actions/DraftActionCreators";
import { navigateToCreateThread } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
import { transitionToGuild } from "../../routing/router_utils";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView";
import { TopicsIcon } from "../../../design/components/Icon/native/redesign/generated/TopicsIcon";
import { Text } from "../../../design/components/Text/native/Text";
import { SummaryActionSheetButton } from "./SummaryActionSheetButton";
import Share from "../../icons/native/Share";
import Module10122 from "../../../_bundle/Module10122";
import Module7732 from "../../../_bundle/Module7732";
const useStyles = createStyles({
summaryContainer: {
padding: 16,
margin: 16,
marginBottom: 24,
justifyContent: "center",
alignItems: "center"
},
summaryContent: {
textAlign: "center"
},
summaryIconContainer: {
marginBottom: 8,
borderRadius: Module712.radii.round,
border: 1,
overflow: "hidden",
alignItems: "center",
justifyContent: "center",
backgroundColor: Module712.colors.BACKGROUND_BRAND
},
summaryIcon: {
margin: 8,
width: 20,
height: 20,
tintColor: Module712.colors.WHITE
},
summaryTopic: {
marginBottom: 4
},
divider: {
height: 1,
backgroundColor: Module712.colors.BORDER_SUBTLE
},
actionsContainer: {
flexDirection: "row",
justifyContent: "space-evenly",
marginBottom: 16
}
});
export default function SummaryActionSheet(props) {
const summary = props.summary;
const styles = useStyles();
const ref = useRef(null);
const channel = ChannelStore.getChannel(summary.channelId);
const message = MessageStore.getMessage(summary.channelId, summary.startId);
let r13 = message != null && message.hasFlag(MessageFlags.HAS_THREAD);
let r36 = channel != null && message != null && !message.hasFlag(MessageFlags.HAS_THREAD) && computeCanStartPublicThread(channel, message);
const callback = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
if (channel?.guild_id != null) {
ActionSheetActionCreators.openLazy(import("../../notifications/native/GuildHighlightsNotificationsActionSheet"), "GuildHighlightsNotifications", {
guildId: channel?.guild_id
});
}
}, [channel?.guild_id]);
const callback3 = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
if (channel != null) {
showShareActionSheet({
message: intl.formatToPlainString(t.I3yTDn, {
topic: summary.topic,
url: getChannelPermalink(channel.guild_id, channel.id, summary.startId, summary.id)
}),
subject: summary.topic
}, AnalyticsSections.SUMMARY_ACTION_SHEET);
} else {
presentFailedToast(intl.string(t.gvkcQl));
}
}, [summary, channel]);
const callback4 = useCallback(() => {
L5: {
ActionSheetActionCreators.hideActionSheet();
if (channel != null && message != null) {
ThreadActionCreators.openThreadCreationForMobile(channel, summary.startId, AnalyticsSections.SUMMARY_ACTION_SHEET);
DraftActionCreators.changeThreadSettings(channel.id, {
name: summary.topic
});
if (navigateToCreateThread(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message.id))) {
break L5;
}
transitionToGuild(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message.id));
} else {
presentError(intl.string(t["/+DWeQ"]));
}
}
}, [summary, channel, message]);
const callback2 = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
if (channel != null && message != null) {
transitionToGuild(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message.id));
}
}, [channel, message]);
const r95 = [<View style={styles.summaryContainer}>
<View style={styles.summaryIconContainer}>
<TopicsIcon style={styles.summaryIcon} size="custom" />
</View>
<Text style={[styles.summaryContent, styles.summaryTopic]} variant="heading-md/extrabold" color="mobile-text-heading-primary">{summary.topic}</Text>
<Text style={[styles.summaryContent]} variant="heading-md/medium" color="text-default">{summary.summShort}</Text>
</View>, <View style={styles.divider} />, ,];
const r118 = [<SummaryActionSheetButton label={intl.string(t["NY/nlb"])} iconSource={Share} onPress={callback3} />, , , ,];
if (r36) {
r36 = <SummaryActionSheetButton label={intl.string(t.rBIGBL)} iconSource={Module10122} onPress={callback4} />;
}
r118[1] = r36;
if (r13) {
r13 = <SummaryActionSheetButton label={intl.string(t["39d0Wj"])} iconSource={Module10122} onPress={callback2} />;
}
r118[2] = r13;
r118[3] = <SummaryActionSheetButton label={intl.string(t.QLkZ39)} iconSource={Module7732} onPress={callback} />;
r95[2] = <View style={styles.actionsContainer}>{r118}</View>;
return <BottomSheet ref={ref}>
<SafeAreaPaddingView bottom>{r95}</SafeAreaPaddingView>
</BottomSheet>;
};
export function openSummaryDividerActionSheet(a0, a1) {
const summary2 = SummaryStore.findSummary(a0, a1);
if (summary2 != null) {
ActionSheetActionCreators.openLazy(import("./SummaryActionSheet"), `SummaryDivider${a1}`, {
summary: summary2
});
}
}