// Metro module 11848 (f11849). import { useState, useLayoutEffect, useCallback } from "react"; import { ScrollView, View } from "react-native"; import GuildChannelStore from "../../../../stores/GuildChannelStore"; import GuildStore from "../../../../stores/GuildStore"; import { createStyles } from "../../../../design/components/Styles/native/createStyles"; import { NAV_BAR_HEIGHT } from "../../../../design/components/Navigator/native/NavigatorConstants.native"; import { useStateFromStores } from "../../../../_bundle/Module589"; import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native"; import { getHeaderBackButton, getHeaderTextButton } from "../../../../design/components/Navigator/native/NavigatorHeader.native"; import { intl, t } from "../../../../intl/index.native"; import ChannelActionCreators from "../../../../actions/ChannelActionCreators"; import { APIError } from "../../../../errors/index"; import { SafeAreaPaddingView } from "../../../../components_native/common/SafeAreaView"; import GuildIcon from "../../../guild/native/GuildIcon"; import AvatarUtils from "../../../../utils/AvatarUtils"; import { Text } from "../../../../design/components/Text/native/Text"; import FreeFormInputGroup from "../../../../design/void/Form/native/FreeFormInputGroup"; import { Button } from "../../../../design/components/Button/native/Button.native"; import FreeFormErrorLabel from "../../../../design/void/Form/native/FreeFormErrorLabel"; const useStyles = createStyles({ flex: { flex: 1 }, safePadding: { marginTop: NAV_BAR_HEIGHT, flex: 1 }, contentContainer: { paddingHorizontal: 16 }, guildIcon: { alignSelf: "center" }, guildName: { marginTop: 8, textAlign: "center" }, title: { marginTop: 16, textAlign: "center" }, subTitle: { marginTop: 8, textAlign: "center" }, topicInput: { marginTop: 24 }, buttonWrapper: { marginTop: 8 }, error: { marginTop: 4 } }); export default function ChannelPrompt(props) { let state, setState, setState2, navigation; const { guildId, buttonText, hasBack, hasSkip, onCancel, onSuccess } = props; state = void 0; setState = void 0; setState2 = void 0; navigation = void 0; const styles = useStyles(); const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(guildId)); let onChangeText; [state, onChangeText] = useState(""); let loading; [loading, setState] = useState(false); let state2; [state2, setState2] = useState(null); navigation = useNavigation(); useLayoutEffect(() => { navigation.setOptions({ headerLeft: hasBack ? getHeaderBackButton(onCancel) : () => null, headerRight: hasSkip ? getHeaderTextButton(intl.string(t["5Wxrcd"]), onSuccess) : () => null }); }, [navigation, hasBack, hasSkip, onCancel, onSuccess]); const callback = useCallback(async () => { let c27196_2; let c27196_3 = 0; let c30470_0; L12: { try { setState2(null); setState(true); const defaultChannel = GuildChannelStore.getDefaultChannel(guildId); c27196_3 = 1; await ChannelActionCreators.createTextChannel(guildId, state, defaultChannel?.parent_id, intl.formatToPlainString(t.V4lepJ, { topic: state })); (0, onSuccess)(); c27196_3 = 0; (0, setState)(false); } catch ($e) { const r34 = $e; let r7 = r34; c27196_2 = r34; if (c27196_3 !== 0) { while (true) { try { const r94 = c27196_2; c27196_3 = 0; c30470_0 = r94; setState2(new APIError(c30470_0)); (0, setState)(false); break L12; } catch (r90) { r7 = r90; c27196_2 = r90; if (c27196_3 === 0) { break; } } } } throw r7; } } }, [guildId, onSuccess, state]); return stateFromStores == null ? null : {stateFromStores.name} {intl.string(t["8VRa7d"])} {intl.string(t["+855Pm"])}