decord/source/modules/notifications/settings/utils/notficationSettingsChannelFlagUtils.tsx

111 lines
6.2 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 9981
// Function ID: 9982
2026-07-20 16:05:17 +00:00
// Name: useChannelPresetSettings
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 1391, 4589, 676, 4590, 685, 647, 4592, 9979, 5368, 9982, 5363, 2]
2026-07-20 16:05:17 +00:00
// Exports: updateChannelNotificationSetting, updateChannelPreset, updateChannelToGuildDefault, updateChannelUnreadSetting, useChannelPresetInheritance, useChannelPresetSettings
2026-08-25 06:04:03 +00:00
// Module 9981 (useChannelPresetSettings)
import Presets from "Presets" /* 4592 */;
import UserNotificationSettings2 from "UserNotificationSettings" /* 5363 */;
import _modDef5368 from "module_5368" /* 5368 */;
import resetGuildUnreadFlags from "resetGuildUnreadFlags" /* 9982 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "ensureGuildLoaded" /* 1391 */;
2026-08-25 06:04:03 +00:00
import closure_5 from "updateUserGuildSettingsInternal" /* 4589 */;
2026-08-24 06:08:38 +00:00
import { UserNotificationSettings } from "ME" /* 676 */;
2026-08-25 06:04:03 +00:00
import { UnreadSetting } from "ReadStateTypes" /* 4590 */;
2026-08-24 06:08:38 +00:00
import { ChannelNotificationSettingsFlags as closure_8 } from "MAX_FAVORITES" /* 685 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
let result = require("set").fileFinishedImporting("modules/notifications/settings/utils/notficationSettingsChannelFlagUtils.tsx");
2026-07-20 16:05:17 +00:00
export const useChannelPresetSettings = function useChannelPresetSettings(channel) {
2026-07-23 10:11:24 +00:00
const _require = channel;
2026-07-29 08:29:29 +00:00
let obj = _require(647);
2026-08-24 06:08:38 +00:00
const items = [closure_5];
const stateFromStores = obj.useStateFromStores(items, () => closure_1_5.resolveUnreadSetting(closure_0));
const items1 = [closure_5];
const stateFromStores1 = _require(647).useStateFromStores(items1, () => closure_1_5.resolvedMessageNotifications(closure_0));
2026-07-29 08:29:29 +00:00
obj = { unread: stateFromStores, notification: stateFromStores1, preset: null };
const obj2 = _require(647);
2026-08-25 06:04:03 +00:00
obj[2] = _require(4592).presetFromSettings(stateFromStores, stateFromStores1);
2026-07-20 16:05:17 +00:00
return obj;
};
export const useChannelPresetInheritance = function useChannelPresetInheritance(channel) {
2026-07-23 10:11:24 +00:00
const _require = channel;
2026-07-29 08:29:29 +00:00
let obj = _require(647);
2026-08-24 06:08:38 +00:00
let items = [closure_5];
const stateFromStoresArray = obj.useStateFromStoresArray(items, () => channel(closure_1_2[8]).filterOverrides(closure_1_5.getChannelOverrides(channel.guild_id), { ignoreMute: true, ignoreUnreadSetting: false, ignoreNotificationSetting: false }));
let items1 = [closure_5, closure_4];
2026-07-20 16:05:17 +00:00
const items2 = [, , ];
({ guild_id: arr3[0], parent_id: arr3[1] } = channel);
items2[2] = stateFromStoresArray;
2026-07-29 08:29:29 +00:00
let obj3 = _require(647);
2026-07-20 16:05:17 +00:00
obj = { inherited: !stateFromStoresArray.includes(channel.id), inheritedFrom: tmp2, inheritedPreset: tmp3 };
2026-07-29 08:29:29 +00:00
[tmp2, tmp3] = callback(_require(647).useStateFromStoresArray(items1, () => {
2026-08-24 06:08:38 +00:00
channel = closure_1_4.getChannel(channel.parent_id);
2026-07-20 16:05:17 +00:00
if (null != channel) {
if (stateFromStoresArray.includes(channel.id)) {
2026-08-24 06:08:38 +00:00
const obj3 = channel(closure_1_2[7]);
const unreadSetting = closure_1_5.resolveUnreadSetting(channel);
const items = ["parent", obj3.presetName(channel(closure_1_2[7]).presetFromSettings(unreadSetting, closure_1_5.resolvedMessageNotifications(channel)))];
2026-07-20 16:05:17 +00:00
let items1 = items;
2026-08-24 06:08:38 +00:00
const obj4 = channel(closure_1_2[7]);
2026-07-20 16:05:17 +00:00
}
return items1;
}
2026-08-24 06:08:38 +00:00
const obj = channel(closure_1_2[7]);
const guildUnreadSetting = closure_1_5.getGuildUnreadSetting(tmp.guild_id);
items1 = ["guild", obj.presetName(channel(closure_1_2[7]).presetFromSettings(guildUnreadSetting, closure_1_5.getMessageNotifications(channel.guild_id)))];
2026-07-20 16:05:17 +00:00
}, items2), 2);
return obj;
};
export const updateChannelPreset = function updateChannelPreset(guild_id, id, arg2) {
const channelIdFlags = store.getChannelIdFlags(guild_id, id);
2026-08-24 06:08:38 +00:00
if (arg2 === Presets.Presets.ALL_MESSAGES) {
2026-08-25 06:04:03 +00:00
const obj4 = _modDef5368;
2026-07-29 08:29:29 +00:00
let obj = { message_notifications: null, flags: null };
obj[0] = UserNotificationSettings.ALL_MESSAGES;
2026-08-25 06:04:03 +00:00
let tmp2Result = tmp2(9982);
2026-07-29 08:29:29 +00:00
obj[1] = tmp2Result.withChannelUnreadFlags(channelIdFlags, constants.UNREADS_ALL_MESSAGES);
2026-08-25 06:04:03 +00:00
const result = obj4.updateChannelOverrideSettings(guild_id, id, obj, tmp2(5363).NotificationLabels.PresetAll);
} else if (arg2 === tmp2(4592).Presets.MENTIONS) {
obj = _modDef5368;
2026-07-29 08:29:29 +00:00
obj = { message_notifications: null, flags: null };
obj[0] = UserNotificationSettings.ONLY_MENTIONS;
2026-08-25 06:04:03 +00:00
tmp2Result = tmp2(9982);
2026-07-29 08:29:29 +00:00
obj[1] = tmp2Result.withChannelUnreadFlags(channelIdFlags, constants.UNREADS_ONLY_MENTIONS);
2026-08-25 06:04:03 +00:00
const result1 = obj.updateChannelOverrideSettings(guild_id, id, obj, tmp2(5363).NotificationLabels.PresetMentions);
} else if (arg2 === tmp2(4592).Presets.NOTHING) {
const obj7 = _modDef5368;
2026-08-24 06:08:38 +00:00
obj1 = { message_notifications: null, flags: null };
2026-07-29 08:29:29 +00:00
obj1[0] = UserNotificationSettings.NO_MESSAGES;
2026-08-25 06:04:03 +00:00
obj1[1] = tmp2(9982).withChannelUnreadFlags(channelIdFlags, constants.UNREADS_ONLY_MENTIONS);
const result2 = obj7.updateChannelOverrideSettings(guild_id, id, obj1, tmp2(5363).NotificationLabels.PresetNothing);
const tmp2Result1 = tmp2(9982);
2026-07-20 16:05:17 +00:00
}
};
export const updateChannelToGuildDefault = function updateChannelToGuildDefault(guild_id, id) {
2026-08-25 06:04:03 +00:00
let obj = _modDef5368;
2026-08-24 06:08:38 +00:00
obj = { message_notifications: UserNotificationSettings.NULL, flags: resetGuildUnreadFlags.resetChannelUnreadFlags(store.getChannelIdFlags(guild_id, id)) };
const result = obj.updateChannelOverrideSettings(guild_id, id, obj, UserNotificationSettings2.NotificationLabels.PresetDefault);
2026-07-20 16:05:17 +00:00
};
export const updateChannelUnreadSetting = function updateChannelUnreadSetting(guild_id, id, ALL_MESSAGES) {
const channelIdFlags = store.getChannelIdFlags(guild_id, id);
2026-08-25 06:04:03 +00:00
let obj = _modDef5368;
2026-07-20 16:05:17 +00:00
if (ALL_MESSAGES === UnreadSetting.ALL_MESSAGES) {
let UNREADS_ONLY_MENTIONS = constants.UNREADS_ALL_MESSAGES;
} else {
UNREADS_ONLY_MENTIONS = constants.UNREADS_ONLY_MENTIONS;
}
2026-08-24 06:08:38 +00:00
obj = { flags: resetGuildUnreadFlags.withChannelUnreadFlags(channelIdFlags, UNREADS_ONLY_MENTIONS) };
const NotificationLabel = UserNotificationSettings2.NotificationLabel;
2026-07-20 16:05:17 +00:00
const result = obj.updateChannelOverrideSettings(guild_id, id, obj, NotificationLabel.unreads(ALL_MESSAGES));
};
export const updateChannelNotificationSetting = function updateChannelNotificationSetting(guildId, id, message_notifications) {
2026-08-25 06:04:03 +00:00
let obj = _modDef5368;
2026-07-20 16:05:17 +00:00
obj = { message_notifications };
2026-08-24 06:08:38 +00:00
const NotificationLabel = UserNotificationSettings2.NotificationLabel;
2026-07-20 16:05:17 +00:00
const result = obj.updateChannelOverrideSettings(guildId, id, obj, NotificationLabel.notifications(message_notifications));
};