// Metro module 11726 (f11727). import { useState, useCallback } from "react"; import ChannelStore from "../../../stores/ChannelStore"; import { Routes } from "../../../Constants"; import ToastActionCreators from "../../toast/native/ToastActionCreators"; import { intl, t } from "../../../intl/index.native"; import safeTransitionTo_native from "../../links/safeTransitionTo.native"; import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators"; import GuildJoinRequestActionCreators from "../GuildJoinRequestActionCreators"; import { GuildJoinRequestApplicationStatuses } from "../MemberVerificationTypes"; import { CircleCheckIcon } from "../../../design/components/Icon/native/redesign/generated/CircleCheckIcon"; import Module712 from "../../../_bundle/Module712"; function $mk116287($env) { return () => ; } export function useJoinRequestButtonActions(a0, a1, a2) { const joinRequest = a0; const onDismiss = a2; const r3 = a0 == null ? {} : a0; const { guildId, userId, joinRequestId } = r3; const [state, setState] = useState(false); const callback = useCallback(() => { ToastActionCreators.open({ key: "JOIN_REQUEST_ERROR", content: intl.string(t.R0RpRX) }); }, []); const callback2 = useCallback(async () => { let c27134_2; let c27134_3 = 0; let c30435_0; L25: { L20: { L24: { try { c30435_0 = void 0; if (state) { break L25; } if (guildId == null) { break L25; } if (userId == null) { break L25; } if (joinRequestId == null) { break L25; } const channel = ChannelStore.getChannel(a1); if (channel != null) { await safeTransitionTo_native(Routes.CHANNEL(null, channel.id), { openChannel: true, navigationReplace: false }); ActionSheetActionCreators.hideActionSheet(); break L24; } setState(true); c27134_3 = 2; c30435_0 = await GuildJoinRequestActionCreators.createOrEnterJoinRequestInterview(joinRequestId, false); if (c30435_0 != null) { await safeTransitionTo_native(Routes.CHANNEL(null, c30435_0), { openChannel: true, navigationReplace: false }); } c27134_3 = 1; c27134_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); break L20; } catch ($e) { const r33 = $e; let r7 = r33; c27134_2 = r33; let r34 = c27134_3; if (r34 !== 0) { while (true) { if (r34 === 1) { try { const r178 = c27134_2; c27134_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); throw r178; } catch (r176) { r7 = r176; c27134_2 = r176; r34 = c27134_3; if (r34 === 0) { break; } } } else { try { c27134_3 = 1; (0, callback)(); c27134_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); break L20; } catch (r159) { r7 = r159; c27134_2 = r159; r34 = c27134_3; if (r34 === 0) { break; } } } } } throw r7; } } return void 0; } return void 0; } }, [guildId, joinRequestId, a1, callback, state, userId]); return { approveRequest: useCallback(async () => { let c27135_0, c27135_1, c27135_2; let c27135_3 = 0; const r10 = void 0; L17: { L16: { try { c27135_1 = r10; c27135_0 = r10; if (state) { break L17; } if (guildId == null) { break L17; } if (userId == null) { break L17; } if (joinRequestId == null) { break L17; } setState(true); c27135_3 = 2; await GuildJoinRequestActionCreators.updateGuildJoinRequest(guildId, userId, joinRequestId, GuildJoinRequestApplicationStatuses.APPROVED); ToastActionCreators.open({ key: "JOIN_REQUEST_APPROVE", content: intl.string(t.WXHcq5), icon: $mk116287(void 0) }); c27135_3 = 1; c27135_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); } catch ($e) { const r33 = $e; let r7 = r33; c27135_2 = r33; let r34 = c27135_3; if (r34 !== 0) { while (true) { if (r34 === 1) { try { const r123 = c27135_2; c27135_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); throw r123; } catch (r121) { r7 = r121; c27135_2 = r121; r34 = c27135_3; if (r34 === 0) { break; } } } else { try { c27135_3 = 1; (0, callback)(); c27135_3 = 0; (0, setState)(false); ActionSheetActionCreators.hideActionSheet(); break L16; } catch (r104) { r7 = r104; c27135_2 = r104; r34 = c27135_3; if (r34 === 0) { break; } } } } } throw r7; } } return void 0; } }, [guildId, joinRequestId, callback, state, userId]), rejectRequest: useCallback(() => { if (joinRequest != null && guildId != null && userId != null && joinRequestId != null) { ActionSheetActionCreators.openLazy(import("./components/JoinRequestRejectionReasonActionSheet"), `RejectionReason-${joinRequestId}`, { joinRequest, onError: callback, onDismiss }); } }, [guildId, joinRequestId, a0, a2, callback, userId]), submitting: state, handleOpenInterview: callback2 }; }