// Metro module 10001 (f10002). import { useEffect, useCallback } from "react"; import CategoryCollapseStore from "../../stores/CategoryCollapseStore"; import UserGuildSettingsStore from "../../stores/UserGuildSettingsStore"; import { AnalyticsSections } from "../../Constants"; import Dispatcher from "../../Dispatcher"; import { useStateFromStores } from "../../_bundle/Module589"; import { updateOptInChannelsBatched, updateOptInChannelsImmediate } from "./OptInChannelsActionCreators"; import { categoryExpand } from "../../actions/CategoryCollapseActionCreators"; import { hasNotSetUpChannelOptIn, optIntoAllChannelsForExistingMember } from "./OptInOnboardingUtils"; export default function useBatchUpdateChannelSettings(a0) { const guildId = a0; const stateFromStores = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.getPendingChannelUpdates(guildId)); useEffect(() => { Dispatcher.dispatch({ type: "CLEAR_PENDING_CHANNEL_AND_ROLE_UPDATES", guildId }); return () => { Dispatcher.dispatch({ type: "CLEAR_PENDING_CHANNEL_AND_ROLE_UPDATES", guildId }); }; }, [a0]); useEffect(() => { if (stateFromStores != null) { updateOptInChannelsBatched(guildId, stateFromStores); } }, [a0, stateFromStores]); return { onChannelClick: useCallback((a0, a1, a2) => { const isChannelOptedIn = UserGuildSettingsStore.isChannelOptedIn(a0, a1); if ((isChannelOptedIn ? !isChannelOptedIn : CategoryCollapseStore.isCollapsed(a2)) && a2 != null) { categoryExpand(a2); } if (hasNotSetUpChannelOptIn(a0)) { if (a1 === a2) { optIntoAllChannelsForExistingMember(a0, { include: new Set([a1]) }); } else { optIntoAllChannelsForExistingMember(a0, { exclude: new Set([a1]) }); } } else { updateOptInChannelsImmediate(a0, a1, !isChannelOptedIn, { section: AnalyticsSections.CHANNEL_BROWSER }); } }, []) }; };