Files
discord-decomp/modules/notifications/settings/utils/notificationSettingsGuildFlagUtils.tsx
T
2026-11-01 12:12:55 +02:00

38 lines
2.2 KiB
TypeScript

// Metro module 10318 (f10319).
import UserGuildSettingsStore from "../../../../stores/UserGuildSettingsStore";
import { UserNotificationSettings } from "../../../../Constants";
import { GuildNotificationSettingsFlags } from "../../../user_settings/UserSettingsConstants";
import { Presets, presetFromSettings } from "./notificationSettingsPresetUtils";
import NotificationSettingsModalActionCreators from "../../../../actions/NotificationSettingsModalActionCreators";
import { withGuildUnreadFlags } from "./notificationSettingsFlagUtils";
import { NotificationLabels } from "../../../../utils/NotificationSettingsUtils";
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
export function updateGuildPreset(a0, a1) {
const guildFlags = UserGuildSettingsStore.getGuildFlags(a0);
if (a1 === Presets.ALL_MESSAGES) {
NotificationSettingsModalActionCreators.updateGuildNotificationSettings(a0, {
message_notifications: UserNotificationSettings.ALL_MESSAGES,
flags: withGuildUnreadFlags(guildFlags, GuildNotificationSettingsFlags.UNREADS_ALL_MESSAGES)
}, NotificationLabels.PresetAll);
} else if (a1 === Presets.MENTIONS) {
NotificationSettingsModalActionCreators.updateGuildNotificationSettings(a0, {
message_notifications: UserNotificationSettings.ONLY_MENTIONS,
flags: withGuildUnreadFlags(guildFlags, GuildNotificationSettingsFlags.UNREADS_ONLY_MENTIONS)
}, NotificationLabels.PresetMentions);
} else if (a1 === Presets.NOTHING) {
NotificationSettingsModalActionCreators.updateGuildNotificationSettings(a0, {
message_notifications: UserNotificationSettings.NO_MESSAGES,
flags: withGuildUnreadFlags(guildFlags, GuildNotificationSettingsFlags.UNREADS_ONLY_MENTIONS)
}, NotificationLabels.PresetNothing);
}
}
export function useGuildPresetSettings(c17866_0) {
const stateFromStores = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.getGuildUnreadSetting(c17866_0));
const stateFromStores2 = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.getMessageNotifications(c17866_0));
return {
unread: stateFromStores,
notification: stateFromStores2,
preset: presetFromSettings(stateFromStores, stateFromStores2)
};
}