115 lines
5.1 KiB
TypeScript
115 lines
5.1 KiB
TypeScript
// Metro module 10035 (f10036).
|
|
import { useState, useContext, useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelRTCStore from "../../calls/ChannelRTCStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import { VoicePanelControlsModes } from "../../voice_panel/native/controls/VoicePanelControlsConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import useChannelName from "../../channel/useChannelName";
|
|
import VoicePanelStateContext from "../../voice_panel/native/VoicePanelStateContext";
|
|
import ChannelRTCActionCreators from "../../../actions/ChannelRTCActionCreators";
|
|
import GuildActionCreators from "../../../actions/GuildActionCreators";
|
|
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
|
|
import { getChannelIconComponent } from "../../../utils/native/ChannelUtils";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { Stack } from "../../../design/components/Stack/native/Stack.native";
|
|
import MarkupUtils from "../../markup/MarkupUtils";
|
|
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
|
|
import GatedContent from "../../../components_native/warnings/GatedContent";
|
|
import { NsfwSpaceWarningModalType } from "../../age_assurance/AgeVerificationAnalyticsUtils";
|
|
const useStyles = createStyles({
|
|
subtitle: {
|
|
textAlign: "center",
|
|
lineHeight: 22
|
|
},
|
|
subtitleContainer: {
|
|
alignItems: "center"
|
|
},
|
|
divider: {
|
|
height: 1,
|
|
width: "100%",
|
|
backgroundColor: Module712.colors.BORDER_SUBTLE,
|
|
marginVertical: 16
|
|
},
|
|
subtitleMeasure: {
|
|
position: "absolute",
|
|
opacity: 0,
|
|
left: 0,
|
|
right: 0
|
|
}
|
|
});
|
|
export default function ChannelSpoiler(props) {
|
|
let isVocal, setControlsMode;
|
|
let c17641_0 = props;
|
|
const stateFromStores2 = useStateFromStores([GuildStore], () => GuildStore.getGuild(c17641_0.guildId));
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(c17641_0.channelId));
|
|
const styles = useStyles();
|
|
const [state, setState] = useState(false);
|
|
const channelName = useChannelName(stateFromStores);
|
|
isVocal = stateFromStores == null ? void 0 : stateFromStores.isVocal();
|
|
setControlsMode = useContext(VoicePanelStateContext).setControlsMode;
|
|
const callback3 = useCallback(() => {
|
|
if (isVocal) {
|
|
if (ChannelRTCStore.getChatOpen(c17641_0.channelId)) {
|
|
ChannelRTCActionCreators.updateChatOpen(c17641_0.channelId, false);
|
|
setControlsMode({
|
|
mode: VoicePanelControlsModes.FLOATING_DEFAULT
|
|
});
|
|
return void 0;
|
|
}
|
|
}
|
|
GuildActionCreators.nsfwReturnToSafety(c17641_0.guildId);
|
|
}, [props.guildId, props.channelId, setControlsMode, isVocal]);
|
|
const callback2 = useCallback((a0) => {
|
|
setState(a0.nativeEvent.lines.length > 3);
|
|
}, []);
|
|
const callback = useCallback(() => {
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if (rootNavigationRef != null) {
|
|
rootNavigationRef.navigate("sidebar", {
|
|
channelId: c17641_0.channelId,
|
|
expandTopic: true
|
|
});
|
|
}
|
|
}, [props.channelId]);
|
|
const Component = stateFromStores != null ? getChannelIconComponent(stateFromStores) : null;
|
|
return <GatedContent modalType={NsfwSpaceWarningModalType.SPOILER_CHANNEL} onAgree={function onAgree() {
|
|
GuildActionCreators.spoilerAgree(c17641_0.channelId);
|
|
}} onDisagree={callback3} title={Component != null ? <View style={{
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: 4,
|
|
flexShrink: 1
|
|
}}>
|
|
<Component size="lg" color="mobile-text-heading-primary" />
|
|
<Text variant="heading-xxl/bold" color="mobile-text-heading-primary" lineClamp={1} style={{
|
|
flexShrink: 1
|
|
}}>{channelName}</Text>
|
|
</View> : intl.string(t["q38/ae"])} subtitle={stateFromStores?.topic != null ? stateFromStores.topic.trim() !== "" ? <Stack spacing={4} style={styles.subtitleContainer}>
|
|
<View style={styles.subtitleMeasure} pointerEvents="none">
|
|
<Text variant="text-md/medium" maxFontSizeMultiplier={2} onTextLayout={callback2}>
|
|
{MarkupUtils.parseTopic(stateFromStores.topic, true, {
|
|
channelId: stateFromStores.id
|
|
})}
|
|
</Text>
|
|
</View>
|
|
<Text color="text-muted" variant="text-md/medium" style={styles.subtitle} maxFontSizeMultiplier={2} lineClamp={3}>
|
|
{MarkupUtils.parseTopic(stateFromStores.topic, true, {
|
|
channelId: stateFromStores.id
|
|
})}
|
|
</Text>
|
|
{state ? <PressableHighlight onPress={callback} accessibilityRole="button">
|
|
<Text variant="text-sm/medium" color="text-brand" style={{
|
|
textDecorationLine: "underline"
|
|
}}>
|
|
{intl.string(t["/QvRak"])}
|
|
</Text>
|
|
</PressableHighlight> : null}
|
|
<View style={styles.divider} />
|
|
</Stack> : null : null} description={intl.string(t["08bm2Z"])} agreement={intl.string(t.KmRwcW)} disagreement={intl.string(t["/g10LC"])} guildId={stateFromStores2?.id} channelId={props.channelId} />;
|
|
};
|