// Module ID: 16732 // Function ID: 16733 // Name: ConnectedNotificationSettings // Dependencies: [109, 19, 17, 1376, 1372, 5207, 4176, 1862, 16440, 3892, 4450, 1874, 676, 21, 4255, 712, 3967, 4449, 4223, 9705, 1959, 5215, 5210, 9715, 9719, 9726, 7767, 1236, 7766, 5634, 5635, 4251, 1297, 3952, 1945, 9714, 5300, 9709, 5306, 11992, 3886, 4453, 4715, 4445, 7749, 4663, 9710, 1480, 589, 5208, 5581, 5223, 16733, 9704, 5650, 2] // Exports: default // Module 16732 (ConnectedNotificationSettings) import _objectWithoutProperties from "_objectWithoutProperties"; import importAllResult from "MuteSettings"; import { View } from "collectGuildAnalyticsMetadata"; import { isGuildReadableType } from "createChannelRecord"; import ensureGuildLoaded from "ensureGuildLoaded"; import setIndex from "setIndex"; import handleInviteData from "handleInviteData"; import createGuildRecordFromRust from "createGuildRecordFromRust"; import FormStates from "FormStates"; import upsertRelationship from "upsertRelationship"; import updateUserGuildSettingsInternal from "updateUserGuildSettingsInternal"; import mergeGuildAvatar from "mergeGuildAvatar"; import ME from "ME"; import jsxProd from "module_5215"; import createCacheKey from "createCacheKey"; let closure_16; let closure_17; let closure_18; let closure_19; let closure_20; let closure_21; let closure_22; let closure_23; let closure_24; let closure_25; let closure_26; let closure_27; let closure_28; let require = arg1; function ConnectedNotificationSettings(guildId) { guildId = guildId.guildId; let categories; let obj = guildId(1480); const navigation = obj.useNavigation(); const items = [updateUserGuildSettingsInternal, createGuildRecordFromRust, setIndex, handleInviteData]; const stateFromStoresObject = guildId(589).useStateFromStoresObject(items, () => ({ guild: outer1_11.getGuild(guildId), suppressEveryone: outer1_14.isSuppressEveryoneEnabled(guildId), suppressRoles: outer1_14.isSuppressRolesEnabled(guildId), mobilePush: outer1_14.isMobilePushEnabled(guildId), muteEvents: outer1_14.isMuteScheduledEventsEnabled(guildId), muted: outer1_14.isMuted(guildId), muteConfig: outer1_14.getMuteConfig(guildId), messageNotifications: outer1_14.getMessageNotifications(guildId), channelOverrides: outer1_14.getChannelOverrides(guildId), categories: outer1_9.getCategories(guildId), guildMemberCount: outer1_10.getMemberCount(guildId), notifyHighlights: outer1_14.getNotifyHighlights(guildId) })); categories = stateFromStoresObject.categories; const obj2 = guildId(589); const items1 = [categories]; const memo = importAllResult.useMemo(() => categories(outer1_2[49])(categories._categories, categories, (channel) => { const type = channel.channel.type; let tmp = callback(type); if (!tmp) { tmp = type === constants.GUILD_CATEGORY; } return tmp; }), items1); const tmp3 = callback(stateFromStoresObject, closure_3); obj = { children: null }; obj = { guildId, channels: memo, navigation, shouldUseNewNotificationSystem: guildId(9710).useShouldUseNewNotificationSystem("NotificationSettingsModalNative") }; const merged = Object.assign(tmp3); const items2 = [callback2(NotificationSettings, obj), callback2(guildId(5581).NavScrim, {})]; obj[0] = items2; return callback3(closure_28, obj); } let closure_3 = ["categories"]; let c5 = importAllResult; ({ AnalyticEvents: closure_16, UserNotificationSettings: closure_17, ChannelTypes: closure_18, NotificationSettingsSections: closure_19, SettingsPaneTypes: closure_20, MAX_MEMBERS_NOTIFY_ALL_MESSAGES: closure_21, GuildFeatures: closure_22, HighlightSettings: closure_23, HelpdeskArticles: closure_24, EMPTY_STRING_SNOWFLAKE_ID: closure_25 } = ME); ({ jsx: closure_26, jsxs: closure_27, Fragment: closure_28 } = jsxProd); createCacheKey = { highlightsLearnMore: null, separator: null, formStack: null }; createCacheKey = { fontSize: 12, color: require("Themes").unsafe_rawColors.BLUE_345, marginTop: 4 }; createCacheKey[0] = createCacheKey; createCacheKey[1] = { height: 1, backgroundColor: require("Themes").colors.BORDER_SUBTLE, marginVertical: 24 }; let obj1 = { height: 1, backgroundColor: require("Themes").colors.BORDER_SUBTLE, marginVertical: 24 }; createCacheKey[2] = { paddingHorizontal: require("Themes").modules.mobile.TABLE_ROW_PADDING }; createCacheKey = createCacheKey.createLegacyClassComponentStyles(createCacheKey); const PureComponent = importAllResult.PureComponent; class NotificationSettings extends PureComponent { constructor() { applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target); closure_0 = applyArgumentsResult; applyArgumentsResult.handleMutePress = function handleMutePress() { let guildId; let muted; ({ guildId, muted } = applyArgumentsResult.props); if (muted) { let tmpResult = tmp(tmp2[21]); let obj = { muted: null }; obj[0] = !muted; const NotificationLabel = applyArgumentsResult(outer1_2[22]).NotificationLabel; const result = tmpResult.updateGuildNotificationSettings(guildId, obj, NotificationLabel.muted(!muted)); } else { tmpResult = tmp(tmp2[18]); const _HermesInternal = HermesInternal; obj = { guildId: null }; obj[0] = guildId; tmpResult.openLazy(applyArgumentsResult(outer1_2[20])(outer1_2[19], outer1_2.paths), "muteSettings" + guildId, obj); const tmp7 = applyArgumentsResult(outer1_2[20])(outer1_2[19], outer1_2.paths); } }; applyArgumentsResult.handleToggleChange = function handleToggleChange(mobile_push, arg1, NotificationLabel) { let obj = outer1_1(outer1_2[21]); obj = { [mobile_push]: arg1 }; const result = obj.updateGuildNotificationSettings(applyArgumentsResult.props.guildId, obj, NotificationLabel); }; applyArgumentsResult.handleTypeChange = function handleTypeChange(message_notifications) { let obj = outer1_1(outer1_2[21]); obj = { message_notifications }; const NotificationLabel = applyArgumentsResult(outer1_2[22]).NotificationLabel; const result = obj.updateGuildNotificationSettings(applyArgumentsResult.props.guildId, obj, NotificationLabel.notifications(message_notifications)); }; applyArgumentsResult.handleAddOverride = function handleAddOverride() { const props = applyArgumentsResult.props; const navigation = props.navigation; navigation.push(outer1_19.ADD_OVERRIDE, { guildId: props.guildId }); }; applyArgumentsResult.handleChannelSelect = function handleChannelSelect(channelId) { const navigation = applyArgumentsResult.props.navigation; navigation.push(outer1_19.CHANNEL_OVERRIDE, { channelId }); }; return applyArgumentsResult; } } const prototype = NotificationSettings.prototype; prototype["componentDidMount"] = function componentDidMount() { let obj = importDefault(4449); obj = { settings_type: "guild", destination_pane: constants4.GUILD_NOTIFICATION_SETTINGS }; obj.trackWithMetadata(constants.SETTINGS_PANE_VIEWED, obj); }; prototype["renderServerSettings"] = function renderServerSettings() { let guildMemberCount; let messageNotifications; let muted; let shouldUseNewNotificationSystem; const self = this; const props = this.props; ({ muted, guildMemberCount } = props); ({ messageNotifications, shouldUseNewNotificationSystem } = props); if (shouldUseNewNotificationSystem) { let obj = { children: null }; obj = { children: null }; const obj1 = { guildId: null }; obj1[0] = self.props.guildId; const items = [callback2(require(9715) /* NotificationSettingsPresets */.NotificationSettingsGuildPresets, obj1), , ]; const obj2 = { style: null, guildId: null }; obj2[0] = { marginTop: 24 }; obj2[1] = self.props.guildId; items[1] = callback2(require(9719) /* NotificationSettingsMessageNotification */.NotificationSettingsGuildMessageNotification, obj2); const obj3 = { style: null, guildId: null }; obj3[0] = { marginTop: 24 }; obj3[1] = self.props.guildId; items[2] = callback2(require(9726) /* NotificationSettingsMessageUnread */.NotificationSettingsGuildMessageUnread, obj3); obj[0] = items; const items1 = [tmp2(View, obj), ]; const obj4 = { style: null }; obj4[0] = tmp.separator; items1[1] = callback2(View, obj4); obj[0] = items1; let tmp2Result = tmp2(closure_28, obj); } else { obj = { title: null, value: null, onChange: null, hasIcons: false, children: null }; const intl = require(1236) /* getSystemLocale */.intl; obj[0] = intl.string(require(1236) /* getSystemLocale */.t.lprV7V); obj[1] = messageNotifications; obj[2] = self.handleTypeChange; const obj5 = { label: null, disabled: null, value: null, subLabel: null }; const intl2 = require(1236) /* getSystemLocale */.intl; obj5[0] = intl2.string(require(1236) /* getSystemLocale */.t["n/bTaY"]); obj5[1] = muted; obj5[2] = constants2.ALL_MESSAGES; let stringResult = null; if (null != guildMemberCount) { stringResult = null; if (guildMemberCount >= closure_21) { const intl3 = tmp3(1236).intl; stringResult = intl3.string(tmp3(1236).t.Dh5p5j); } } obj5[3] = stringResult; const items2 = [callback2(require(7766) /* TableRadioRow */.TableRadioRow, obj5), , ]; const obj6 = { label: null, value: null, disabled: null }; const intl4 = tmp3(1236).intl; obj6[0] = intl4.format(require(1236) /* getSystemLocale */.t.L2hmYy, {}); obj6[1] = constants2.ONLY_MENTIONS; obj6[2] = muted; items2[1] = callback2(require(7766) /* TableRadioRow */.TableRadioRow, obj6); const obj7 = { label: null, value: null, disabled: null }; const intl5 = tmp3(1236).intl; obj7[0] = intl5.string(require(1236) /* getSystemLocale */.t.CtVGyQ); obj7[1] = constants2.NO_MESSAGES; obj7[2] = muted; items2[2] = callback2(require(7766) /* TableRadioRow */.TableRadioRow, obj7); obj[4] = items2; tmp2Result = tmp2(require(7767) /* context */.TableRadioGroup, obj); } return tmp2Result; }; prototype["renderNotificationOptions"] = function renderNotificationOptions() { let mobilePush; let muteEvents; let muted; let require; let suppressEveryone; let suppressRoles; const self = this; const props = this.props; ({ muted, suppressEveryone, suppressRoles, mobilePush, muteEvents, guildId: require } = props); let obj = { label: null, value: null, onValueChange: null }; const intl = require(1236) /* getSystemLocale */.intl; obj[0] = intl.format(require(1236) /* getSystemLocale */.t.OWiWAp, {}); if (suppressEveryone == null) { suppressEveryone = false; } obj[1] = suppressEveryone; obj[2] = function onValueChange(arg0) { const NotificationLabel = outer1_0(outer1_2[22]).NotificationLabel; self.handleToggleChange("suppress_everyone", arg0, NotificationLabel.suppressEveryone(arg0)); }; const items = [closure_26(require(5635) /* TableSwitchRow */.TableSwitchRow, obj), , ]; obj = { label: null, value: null, onValueChange: null }; const intl2 = tmp5(1236).intl; obj[0] = intl2.string(require(1236) /* getSystemLocale */.t["O/QdoD"]); if (suppressRoles == null) { suppressRoles = false; } obj[1] = suppressRoles; obj[2] = function onValueChange(arg0) { const NotificationLabel = outer1_0(outer1_2[22]).NotificationLabel; self.handleToggleChange("suppress_roles", arg0, NotificationLabel.suppressRoles(arg0)); }; items[1] = closure_26(require(5635) /* TableSwitchRow */.TableSwitchRow, obj); obj = { disabled: muted, label: null, value: null, onValueChange: null }; const intl3 = tmp5(1236).intl; obj[1] = intl3.string(require(1236) /* getSystemLocale */.t.gPuteJ); let tmp8 = muted; if (!muted) { tmp8 = props.notifyHighlights === constants6.DISABLED; } const obj1 = { children: null }; const obj2 = { hasIcons: false, children: null }; obj[2] = tmp8; obj[3] = function onValueChange(arg0) { let obj = self(outer1_2[21]); obj = { notify_highlights: arg0 ? tmp3.DISABLED : tmp3.ENABLED }; const NotificationLabel = outer1_0(outer1_2[22]).NotificationLabel; const result = obj.updateGuildNotificationSettings(closure_0, obj, NotificationLabel.highlights(!arg0)); }; items[2] = closure_26(require(5635) /* TableSwitchRow */.TableSwitchRow, obj); obj2[1] = items; const items1 = [closure_27(require(5634) /* TableRowGroupTitle */.TableRowGroup, obj2), , ]; const obj3 = { variant: "text-sm/medium", color: "text-muted", style: { marginTop: 8 }, children: null }; const intl4 = tmp5(1236).intl; obj3[3] = intl4.string(require(1236) /* getSystemLocale */.t["Vw/Xn8"]); items1[1] = closure_26(require(4251) /* Text */.Text, obj3); const obj4 = { style: createCacheKey(this.context).highlightsLearnMore, accessibilityRole: "link", onPress() { const obj = self(3952); return obj.openURL(self(1945).getArticleURL(constants.HIGHLIGHTS)); }, children: null }; const intl5 = tmp5(1236).intl; obj4[3] = intl5.string(require(1236) /* getSystemLocale */.t.PRBn9K); items1[2] = closure_26(require(1297) /* Button */.LegacyText, obj4); obj1[0] = items1; const items2 = [closure_27(View, obj1), ]; const obj5 = { label: null, value: null, onValueChange: null }; const intl6 = tmp5(1236).intl; obj5[0] = intl6.string(require(1236) /* getSystemLocale */.t.ONG3Yz); if (muteEvents == null) { muteEvents = false; } obj5[1] = muteEvents; obj5[2] = function onValueChange(arg0) { const NotificationLabel = outer1_0(outer1_2[22]).NotificationLabel; self.handleToggleChange("mute_scheduled_events", arg0, NotificationLabel.mutedEvents(arg0)); }; const items3 = [closure_26(require(5635) /* TableSwitchRow */.TableSwitchRow, obj5), ]; const obj6 = { disabled: muted, label: null, value: null, onValueChange: null }; const intl7 = tmp5(1236).intl; obj6[1] = intl7.string(require(1236) /* getSystemLocale */.t.h1DL66); let tmp10 = !muted; if (!muted) { if (mobilePush == null) { mobilePush = false; } tmp10 = mobilePush; } const obj7 = { children: null }; const obj8 = { hasIcons: false, children: null }; obj6[2] = tmp10; obj6[3] = function onValueChange(arg0) { const NotificationLabel = outer1_0(outer1_2[22]).NotificationLabel; self.handleToggleChange("mobile_push", arg0, NotificationLabel.mobilePush(arg0)); }; items3[1] = closure_26(require(5635) /* TableSwitchRow */.TableSwitchRow, obj6); obj8[1] = items3; items2[1] = closure_27(require(5634) /* TableRowGroupTitle */.TableRowGroup, obj8); obj7[0] = items2; return closure_27(closure_28, obj7); }; prototype["renderMuteSection"] = function renderMuteSection() { let guild; let muteConfig; let muted; const self = this; const props = this.props; ({ muted, muteConfig, guild } = props); if (props.shouldUseNewNotificationSystem) { let tmp15 = null; if (muted) { let obj = { title: null, subtitle: null, style: null, onPressUnmute: null }; const intl3 = require(1236) /* getSystemLocale */.intl; obj[0] = intl3.string(require(1236) /* getSystemLocale */.t.ZSkXJY); obj[1] = require(9714) /* NotificationSettingsMuteBanner */.getMuteBannerSubtitleFromConfig(muteConfig); obj[2] = { marginBottom: 16 }; obj[3] = self.handleMutePress; tmp15 = callback2(require(9714) /* NotificationSettingsMuteBanner */.NotificationSettingsMuteBanner, obj); const obj7 = require(9714) /* NotificationSettingsMuteBanner */; } return tmp15; } else { const intl = require(1236) /* getSystemLocale */.intl; const format = intl.format; const t = require(1236) /* getSystemLocale */.t; if (muted) { let name; if (guild != null) { name = guild.name; } obj = { name: null }; obj[0] = name; let formatResult = format(t.e8hzDQ, obj); let tmp7 = tmp; } else { let name1; if (guild != null) { name1 = guild.name; } obj = { name: null }; obj[0] = name1; formatResult = format(t["J+7D9E"], obj); tmp7 = tmp; } const obj1 = { helperText: null, hasIcons: false, children: null }; const intl2 = tmp7(1236).intl; obj1[0] = intl2.string(tmp7(1236).t["8wbTQ6"]); const obj2 = { label: null, onPress: null, arrow: null }; obj2[0] = formatResult; obj2[1] = self.handleMutePress; obj2[2] = !muted; obj1[2] = callback2(tmp7(5300).TableRow, obj2); const items = [callback2(tmp7(5634).TableRowGroup, obj1, "mute"), ]; let tmp10Result = null; if (muted) { const obj3 = { muteConfig: null, type: null }; obj3[0] = muteConfig; obj3[1] = tmp7(9709).MuteSettingType.SERVER; tmp10Result = callback2(importDefault(9709), obj3, "muted-until"); const tmp14 = importDefault(9709); } items[1] = tmp10Result; return items; } }; prototype["renderChannels"] = function renderChannels() { const self = this; let obj = { title: null, hasIcons: true, children: null }; const intl = self(1236).intl; obj[0] = intl.string(self(1236).t.O4TIvi); obj = { icon: null, label: null, onPress: null }; obj = { IconComponent: null }; obj[0] = self(11992).PlusMediumIcon; obj[0] = callback2(self(5306).TableRowIcon, obj); const intl2 = self(1236).intl; obj[1] = intl2.string(self(1236).t.quib7R); obj[2] = this.handleAddOverride; obj[2] = callback2(self(5300).TableRow, obj); const items = [callback2(self(5634).TableRowGroup, obj, "override-header"), ]; const obj1 = { hasIcons: true, children: null }; const overriddenChannels = this.getOverriddenChannels(); obj1[1] = overriddenChannels.map((parent_id) => self.renderChannel(parent_id)); items[1] = callback2(self(5634).TableRowGroup, obj1, "override-channels"); return items; }; prototype["renderChannel"] = function renderChannel(parent_id) { let self = this; self = this; const _require = parent_id; if (null != parent_id) { let channel; if (null != parent_id.parent_id) { channel = channel.getChannel(parent_id.parent_id); } let obj = _require(3886); if (obj.computeIsMuted(self.props.channelOverrides[parent_id.id])) { const intl3 = tmp4(1236).intl; let stringResult = intl3.string(tmp4(1236).t.fpKdS1); } else { const message_notifications = tmp.message_notifications; if (constants2.ALL_MESSAGES === message_notifications) { const intl2 = tmp4(1236).intl; stringResult = intl2.string(tmp4(1236).t["n/bTaY"]); } else if (tmp6.ONLY_MENTIONS === message_notifications) { const intl = tmp4(1236).intl; stringResult = intl.string(tmp4(1236).t["6fQPhu"]); } else if (tmp6.NO_MESSAGES === message_notifications) { const intl4 = tmp4(1236).intl; stringResult = intl4.string(tmp4(1236).t.CtVGyQ); } } if (self.props.shouldUseNewNotificationSystem) { let tmp4Result = tmp4(4453); tmp4Result = tmp4(4453); const unreadSetting = updateUserGuildSettingsInternal.resolveUnreadSetting(parent_id); stringResult = tmp4Result.presetName(tmp4Result.presetFromSettings(unreadSetting, updateUserGuildSettingsInternal.resolvedMessageNotifications(parent_id))); } obj = { icon: null, label: null, onPress: null, subLabel: null, trailing: null, arrow: true }; obj = { IconComponent: null }; obj[0] = _require(4715).getChannelIconComponent(parent_id); obj[0] = callback2(_require(5306).TableRowIcon, obj); const tmp4Result1 = _require(4715); obj[1] = _require(4445).computeChannelName(parent_id, mergeGuildAvatar, upsertRelationship); obj[2] = function onPress() { return self.handleChannelSelect(parent_id.id); }; let channelName = null; if (null != channel) { channelName = tmp4(4445).computeChannelName(channel, mergeGuildAvatar, upsertRelationship); const tmp4Result3 = tmp4(4445); } obj[3] = channelName; let tmp10Result; if (null != stringResult) { const obj1 = { text: null }; obj1[0] = stringResult; tmp10Result = tmp10(tmp4(5300).TableRow.TrailingText, obj1); } obj[4] = tmp10Result; return callback2(_require(5300).TableRow, obj, parent_id.id); } }; prototype["render"] = function render() { const self = this; const guild = this.props.guild; const tmp = createCacheKey(this.context); let hasItem; if (guild != null) { const features = guild.features; hasItem = features.has(constants5.HUB); } const Form = require(7749) /* Form */.Form; let obj = { contentContainerStyle: { paddingTop: 16 }, children: null }; if (hasItem) { obj = { spacing: null, style: null, children: null }; obj[0] = importDefault(712).space.PX_24; obj[1] = tmp.formStack; obj[2] = self.renderMuteSection(); obj[1] = tmp4(tmp5(4663).Stack, obj); let tmp4Result = tmp4(Form, obj); } else { obj = { spacing: null, style: null, children: null }; obj[0] = importDefault(712).space.PX_24; obj[1] = tmp.formStack; const items = [self.renderMuteSection(), self.renderServerSettings(), self.renderNotificationOptions(), self.renderChannels()]; obj[2] = items; obj[1] = callback3(tmp5(4663).Stack, obj); tmp4Result = tmp4(Form, obj); } return tmp4Result; }; prototype["getOverriddenChannels"] = function getOverriddenChannels() { const props = this.props; const channels = props.channels; let obj = set(9710); obj = { ignoreNotificationSetting: false, ignoreMute: this.props.shouldUseNewNotificationSystem, ignoreUnreadSetting: !this.props.shouldUseNewNotificationSystem }; set = new Set(obj.filterOverrides(props.channelOverrides, obj)); const mapped = channels.map((channel) => { channel = channel.channel; let tmp = null; if (set.has(channel.id)) { tmp = channel; } return tmp; }); return mapped.filter((arg0) => null != arg0); }; NotificationSettings.contextType = require("ManaContext").ThemeContext; let obj2 = { paddingHorizontal: require("Themes").modules.mobile.TABLE_ROW_PADDING }; let result = require("get ActivityIndicator").fileFinishedImporting("modules/notification_settings/native/NotificationSettingsModal.native.tsx"); export default function NotificationSettingsModal() { let obj = require(589) /* initialize */; const items = [FormStates]; let stateFromStores = obj.useStateFromStores(items, () => props.getProps().guildId); const memo = importAllResult.useMemo(() => { let obj = {}; obj = { headerLeft: null, title: null, render: null }; obj[0] = callback(5223).getHeaderCloseButton(callback2(5215).close); const intl = callback(1236).intl; obj[1] = intl.string(callback(1236).t.h850Ss); obj[2] = function render(guildId) { return callback2(closure_31, { guildId: guildId.guildId }); }; obj[constants.OVERVIEW] = obj; obj = { title: null, headerLeft: null, render: null }; const intl2 = callback(1236).intl; obj[0] = intl2.string(callback(1236).t.s7vIQT); const obj3 = callback(5223); obj[1] = callback(5223).getHeaderBackButton(); obj[2] = function render(guildId, navigation) { return callback2(callback(16733), { guildId: guildId.guildId, navigation }); }; obj[constants.ADD_OVERRIDE] = obj; const obj1 = { headerLeft: null, title: null, render: null }; const obj5 = callback(5223); obj1[0] = callback(5223).getHeaderBackButton(); const intl3 = callback(1236).intl; obj1[1] = intl3.string(callback(1236).t.h850Ss); obj1[2] = function render(channelId) { return callback2(callback(9704), { channelId: channelId.channelId, inGuildContext: true }); }; obj[constants.CHANNEL_OVERRIDE] = obj1; return obj; }, []); obj = { screens: memo, initialRouteStack: null }; obj = { name: constants3.OVERVIEW, params: null }; if (stateFromStores == null) { stateFromStores = closure_25; } obj[1] = { guildId: stateFromStores }; const items1 = [obj]; obj[1] = items1; return closure_26(require(5650) /* NavigationStack */.Navigator, obj); }; export { NotificationSettings };