351 lines
16 KiB
JavaScript
351 lines
16 KiB
JavaScript
// Module ID: 5342
|
|
// Function ID: 45614
|
|
// Name: differ
|
|
// Dependencies: []
|
|
// Exports: getManyCurrentChannelSettings, getManyCurrentGuildSettings, trackAccountNotificationSettingUpdated, trackChannelNotificationSettingsUpdate, trackGuildNotificationSettingsUpdate
|
|
|
|
// Module 5342 (differ)
|
|
let UserNotificationSettings;
|
|
function differ(computeResult, computeResult1, RETURN_PREVIOUS_WHEN_CHANGED) {
|
|
computeResult1 = computeResult;
|
|
const importDefault = computeResult1;
|
|
let closure_2 = "RETURN_PREVIOUS_WHEN_CHANGED";
|
|
return (arg0) => {
|
|
if ("RETURN_PREVIOUS_WHEN_CHANGED" === closure_2) {
|
|
let tmp3;
|
|
if (arg0[arg0] !== arg1[arg0]) {
|
|
tmp3 = arg0[arg0];
|
|
}
|
|
return tmp3;
|
|
}
|
|
};
|
|
}
|
|
function muteConfigToTimestamp(muteConfig) {
|
|
let time = null;
|
|
if (null != muteConfig) {
|
|
time = null;
|
|
if (null != muteConfig.end_time) {
|
|
const _Date = Date;
|
|
const date = new Date(muteConfig.end_time);
|
|
time = date.getTime();
|
|
}
|
|
}
|
|
return time;
|
|
}
|
|
function getCurrentGuildSettings(guildId) {
|
|
const muteConfig = store2.getMuteConfig(guildId);
|
|
const obj = { guild_suppress_everyone: store2.isSuppressEveryoneEnabled(guildId), guild_suppress_roles: store2.isSuppressRolesEnabled(guildId), guild_scheduled_events_muted: store2.isMuteScheduledEventsEnabled(guildId), guild_is_muted: store2.isMuted(guildId) };
|
|
let time = null;
|
|
if (null != muteConfig) {
|
|
time = null;
|
|
if (null != muteConfig.end_time) {
|
|
const _Date = Date;
|
|
const date = new Date(muteConfig.end_time);
|
|
time = date.getTime();
|
|
}
|
|
}
|
|
obj.guild_muted_until = time;
|
|
obj.guild_receive_mobile_push = store2.isMobilePushEnabled(guildId);
|
|
obj.guild_message_notification_settings = frozen[closure_6.getMessageNotifications(closure_6, guildId)];
|
|
obj.guild_notify_highlights = store2.getNotifyHighlights(guildId);
|
|
obj.guild_flags = store2.getGuildFlags(guildId);
|
|
return obj;
|
|
}
|
|
function getCurrentChannelSettings(guildId, channelId) {
|
|
const channelMuteConfig = store2.getChannelMuteConfig(guildId, channelId);
|
|
const obj = { channel_is_muted: store2.isChannelMuted(guildId, channelId) };
|
|
let time = null;
|
|
if (null != channelMuteConfig) {
|
|
time = null;
|
|
if (null != channelMuteConfig.end_time) {
|
|
const _Date = Date;
|
|
const date = new Date(channelMuteConfig.end_time);
|
|
time = date.getTime();
|
|
}
|
|
}
|
|
obj.channel_muted_until = time;
|
|
obj.channel_message_notification_settings = frozen[closure_6.getChannelMessageNotifications(closure_6, guildId, channelId)];
|
|
obj.channel_flags = store2.getChannelIdFlags(guildId, channelId);
|
|
return obj;
|
|
}
|
|
let closure_3 = importDefault(dependencyMap[0]);
|
|
let closure_4 = importDefault(dependencyMap[1]);
|
|
let closure_5 = importDefault(dependencyMap[2]);
|
|
let closure_6 = importDefault(dependencyMap[3]);
|
|
({ AnalyticEvents: closure_7, UserNotificationSettings } = arg1(dependencyMap[4]));
|
|
let closure_9 = arg1(dependencyMap[5]).NotificationSettingsUpdateType;
|
|
const UnreadSetting = arg1(dependencyMap[6]).UnreadSetting;
|
|
const tmp2 = arg1(dependencyMap[4]);
|
|
({ ChannelNotificationSettingsFlags: closure_11, GuildNotificationSettingsFlags: closure_12 } = arg1(dependencyMap[7]));
|
|
let obj = { ForumThreadsCreatedOn: "enabled forum thread created notifs", ForumThreadsCreatedOff: "disabled forum thread created notifs", SuppressEveryoneOn: "enabled suppress everyone", SuppressEveryoneOff: "disabled suppress everyone", SuppressRolesOn: "enabled suppress roles", SuppressRolesOff: "disabled suppress roles", HighlightsOn: "enabled highlights", HighlightsOff: "disabled highlights", MobilePushOn: "enabled mobile push notifications", MobilePushOff: "disabled mobile push notifications", UnreadsAll: "unreads set to all messages", UnreadsMentions: "unreads set to mentions", UnreadsDefault: "unreads set to the default", NotificationsAll: "notifications set to all messages", NotificationsMentions: "notifications set to mentions", NotificationsNothing: "notifications set to nothing", NotificationsDefault: "notifications set to the default", PresetAll: "notification preset set to all messages", PresetMentions: "notification preset set to mentions", PresetNothing: "notification preset set to nothing", PresetDefault: "notification preset set to the default", OptedIn: "opted in to entity", OptedOut: "opted out from entity", Favorited: "favorited", UnFavorited: "unfavorited", Muted: "muted", Unmuted: "unmuted", MutedScheduledEvents: "muted scheduled events", UnmutedScheduledEvents: "unmuted scheduled events", OverrideCreated: "channel override created", OverrideDeleted: "channel override deleted", AnnouncementAutoEnable: "announcement channels auto set to all messages" };
|
|
obj = {
|
|
forumThreadsCreated(arg0) {
|
|
return arg0 ? obj.ForumThreadsCreatedOn : obj.ForumThreadsCreatedOff;
|
|
},
|
|
suppressEveryone(arg0) {
|
|
return arg0 ? obj.SuppressEveryoneOn : obj.SuppressEveryoneOff;
|
|
},
|
|
suppressRoles(arg0) {
|
|
return arg0 ? obj.SuppressRolesOn : obj.SuppressRolesOff;
|
|
},
|
|
highlights(arg0) {
|
|
return arg0 ? obj.HighlightsOn : obj.HighlightsOff;
|
|
},
|
|
mobilePush(arg0) {
|
|
return arg0 ? obj.MobilePushOn : obj.MobilePushOff;
|
|
},
|
|
optedIn(optInEnabled) {
|
|
return optInEnabled ? obj.OptedIn : obj.OptedOut;
|
|
},
|
|
favorited(arg0) {
|
|
return arg0 ? obj.Favorited : obj.UnFavorited;
|
|
},
|
|
muted(muted) {
|
|
return muted ? obj.Muted : obj.Unmuted;
|
|
},
|
|
mutedEvents(arg0) {
|
|
return arg0 ? obj.MutedScheduledEvents : obj.UnmutedScheduledEvents;
|
|
},
|
|
unreads(ONLY_MENTIONS) {
|
|
if (ONLY_MENTIONS === UnreadSetting.ALL_MESSAGES) {
|
|
let UnreadsDefault = obj.UnreadsAll;
|
|
} else if (ONLY_MENTIONS === UnreadSetting.ONLY_MENTIONS) {
|
|
UnreadsDefault = obj.UnreadsMentions;
|
|
} else {
|
|
UnreadsDefault = obj.UnreadsDefault;
|
|
}
|
|
return UnreadsDefault;
|
|
},
|
|
notifications(message_notifications) {
|
|
if (message_notifications === UserNotificationSettings.ALL_MESSAGES) {
|
|
let NotificationsDefault = obj.NotificationsAll;
|
|
} else if (message_notifications === UserNotificationSettings.ONLY_MENTIONS) {
|
|
NotificationsDefault = obj.NotificationsMentions;
|
|
} else if (message_notifications === UserNotificationSettings.NO_MESSAGES) {
|
|
NotificationsDefault = obj.NotificationsNothing;
|
|
} else {
|
|
NotificationsDefault = obj.NotificationsDefault;
|
|
}
|
|
return NotificationsDefault;
|
|
}
|
|
};
|
|
const frozen = Object.freeze({ [UserNotificationSettings.ALL_MESSAGES]: "All", [UserNotificationSettings.ONLY_MENTIONS]: "Mentions", [UserNotificationSettings.NO_MESSAGES]: "Nothing", [UserNotificationSettings.NULL]: null });
|
|
const tmp3 = arg1(dependencyMap[7]);
|
|
const result = arg1(dependencyMap[11]).fileFinishedImporting("utils/NotificationSettingsUtils.tsx");
|
|
|
|
export const NotificationLabels = obj;
|
|
export const NotificationLabel = obj;
|
|
export const MessageNotificationSettings = frozen;
|
|
export const trackGuildNotificationSettingsUpdate = function trackGuildNotificationSettingsUpdate(guildId, muteSettings, currentGuildSettings, NotificationLabel, arg4) {
|
|
function compute(currentGuildSettings, muteSettings) {
|
|
let obj = muteSettings;
|
|
if (muteSettings === undefined) {
|
|
obj = {};
|
|
}
|
|
if (null != obj.mute_config) {
|
|
if (null != obj.mute_config.end_time) {
|
|
const _Date = Date;
|
|
const date = new Date(obj.mute_config.end_time);
|
|
let guild_muted_until = date.getTime();
|
|
}
|
|
if (null != obj.message_notifications) {
|
|
let guild_message_notification_settings = closure_14[obj.message_notifications];
|
|
} else {
|
|
guild_message_notification_settings = currentGuildSettings.guild_message_notification_settings;
|
|
}
|
|
obj = { guild_muted_until };
|
|
let guild_flags = obj.flags;
|
|
if (null == guild_flags) {
|
|
guild_flags = currentGuildSettings.guild_flags;
|
|
}
|
|
obj.guild_flags = guild_flags;
|
|
let guild_is_muted = obj.muted;
|
|
if (null == guild_is_muted) {
|
|
guild_is_muted = currentGuildSettings.guild_is_muted;
|
|
}
|
|
obj.guild_is_muted = guild_is_muted;
|
|
obj.guild_message_notification_settings = guild_message_notification_settings;
|
|
let guild_suppress_roles = obj.suppress_roles;
|
|
if (null == guild_suppress_roles) {
|
|
guild_suppress_roles = currentGuildSettings.guild_suppress_roles;
|
|
}
|
|
obj.guild_suppress_roles = guild_suppress_roles;
|
|
let guild_receive_mobile_push = obj.mobile_push;
|
|
if (null == guild_receive_mobile_push) {
|
|
guild_receive_mobile_push = currentGuildSettings.guild_receive_mobile_push;
|
|
}
|
|
obj.guild_receive_mobile_push = guild_receive_mobile_push;
|
|
let guild_notify_highlights = obj.notify_highlights;
|
|
if (null == guild_notify_highlights) {
|
|
guild_notify_highlights = currentGuildSettings.guild_notify_highlights;
|
|
}
|
|
obj.guild_notify_highlights = guild_notify_highlights;
|
|
let guild_suppress_everyone = obj.suppress_everyone;
|
|
if (null == guild_suppress_everyone) {
|
|
guild_suppress_everyone = currentGuildSettings.guild_suppress_everyone;
|
|
}
|
|
obj.guild_suppress_everyone = guild_suppress_everyone;
|
|
let guild_scheduled_events_muted = obj.mute_scheduled_events;
|
|
if (null == guild_scheduled_events_muted) {
|
|
guild_scheduled_events_muted = currentGuildSettings.guild_scheduled_events_muted;
|
|
}
|
|
obj.guild_scheduled_events_muted = guild_scheduled_events_muted;
|
|
return obj;
|
|
}
|
|
guild_muted_until = currentGuildSettings.guild_muted_until;
|
|
}
|
|
const computeResult1 = compute(getCurrentGuildSettings(guildId), muteSettings);
|
|
const tmp3 = differ(compute(currentGuildSettings), computeResult1, "RETURN_PREVIOUS_WHEN_CHANGED");
|
|
const tmp3Result = tmp3("guild_flags");
|
|
let num = 0;
|
|
if (null != tmp3Result) {
|
|
num = tmp3Result;
|
|
}
|
|
const guild_flags = computeResult1.guild_flags;
|
|
let num2 = 0;
|
|
if (null != guild_flags) {
|
|
num2 = guild_flags;
|
|
}
|
|
let obj = muteSettings(dependencyMap[8]);
|
|
const computeResult = compute(currentGuildSettings);
|
|
const tmp5 = num2 ^ num;
|
|
const removeFlagsResult = obj.removeFlags(num2 ^ num, constants4.OPT_IN_CHANNELS_OFF, constants4.OPT_IN_CHANNELS_ON);
|
|
obj = {};
|
|
const merged = Object.assign(computeResult1);
|
|
const merged1 = Object.assign(store.getStats(guildId));
|
|
obj["location"] = arg4;
|
|
obj["guild_id"] = guildId;
|
|
obj["update_type"] = constants2.GUILD;
|
|
obj["label"] = NotificationLabel;
|
|
obj["guild_flags_old"] = tmp3("guild_flags");
|
|
obj["guild_is_muted_old"] = tmp3("guild_is_muted");
|
|
obj["guild_suppress_roles_old"] = tmp3("guild_suppress_roles");
|
|
obj["guild_notify_highlights_old"] = tmp3("guild_notify_highlights");
|
|
obj["guild_suppress_everyone_old"] = tmp3("guild_suppress_everyone");
|
|
obj["guild_receive_mobile_push_old"] = tmp3("guild_receive_mobile_push");
|
|
obj["guild_scheduled_events_muted_old"] = tmp3("guild_scheduled_events_muted");
|
|
obj["guild_message_notification_settings_old"] = tmp3("guild_message_notification_settings");
|
|
obj["is_opt_in_only_change"] = 0 === removeFlagsResult;
|
|
importDefault(dependencyMap[9]).trackWithMetadata(constants.NOTIFICATION_SETTINGS_UPDATED, obj);
|
|
};
|
|
export { muteConfigToTimestamp };
|
|
export const trackChannelNotificationSettingsUpdate = function trackChannelNotificationSettingsUpdate(updateType) {
|
|
let _location;
|
|
let applicationId;
|
|
let change;
|
|
let label;
|
|
let CHANNEL = updateType.updateType;
|
|
if (CHANNEL === undefined) {
|
|
CHANNEL = constants2.CHANNEL;
|
|
}
|
|
const guildId = updateType.guildId;
|
|
const arg1 = guildId;
|
|
const channelId = updateType.channelId;
|
|
function compute(currentChannelSettings, change) {
|
|
let obj = change;
|
|
if (change === undefined) {
|
|
obj = {};
|
|
}
|
|
let muted = obj.muted;
|
|
if (null == muted) {
|
|
let channel_is_muted;
|
|
if (null != currentChannelSettings) {
|
|
channel_is_muted = currentChannelSettings.channel_is_muted;
|
|
}
|
|
muted = channel_is_muted;
|
|
}
|
|
if (null != obj.message_notifications) {
|
|
let channel_message_notification_settings = closure_14[obj.message_notifications];
|
|
} else if (null != currentChannelSettings) {
|
|
channel_message_notification_settings = currentChannelSettings.channel_message_notification_settings;
|
|
}
|
|
obj = { channel_is_muted: muted };
|
|
let tmp3 = null;
|
|
if (null != guildId) {
|
|
tmp3 = true === muted || null != channel_message_notification_settings;
|
|
const tmp4 = true === muted || null != channel_message_notification_settings;
|
|
}
|
|
obj.channel_is_overridden = tmp3;
|
|
let flags = obj.flags;
|
|
if (null == flags) {
|
|
let channel_flags;
|
|
if (null != currentChannelSettings) {
|
|
channel_flags = currentChannelSettings.channel_flags;
|
|
}
|
|
flags = channel_flags;
|
|
}
|
|
obj.channel_flags = flags;
|
|
obj.channel_message_notification_settings = channel_message_notification_settings;
|
|
obj.channel_muted_until = callback(obj.mute_config);
|
|
return obj;
|
|
}
|
|
({ applicationId, change, label, location: _location } = updateType);
|
|
const computeResult1 = compute(getCurrentChannelSettings(guildId, channelId), change);
|
|
const tmp4 = differ(compute(updateType.previous), computeResult1, "RETURN_PREVIOUS_WHEN_CHANGED");
|
|
const channel = channel.getChannel(channelId);
|
|
const tmp4Result = tmp4("channel_flags");
|
|
let num = 0;
|
|
if (null != tmp4Result) {
|
|
num = tmp4Result;
|
|
}
|
|
const channel_flags = computeResult1.channel_flags;
|
|
let num2 = 0;
|
|
if (null != channel_flags) {
|
|
num2 = channel_flags;
|
|
}
|
|
let obj = arg1(dependencyMap[8]);
|
|
const computeResult = compute(updateType.previous);
|
|
const tmp7 = num2 ^ num;
|
|
const lastMessage = lastMessage.getLastMessage(channelId);
|
|
let type;
|
|
if (null != lastMessage) {
|
|
type = lastMessage.type;
|
|
}
|
|
let tmp11 = null;
|
|
if (null != type) {
|
|
tmp11 = type;
|
|
}
|
|
const removeFlagsResult = obj.removeFlags(num2 ^ num, constants3.FAVORITED, constants3.OPT_IN_ENABLED);
|
|
obj = {};
|
|
const merged = Object.assign(computeResult1);
|
|
const merged1 = Object.assign(store.getStats(guildId));
|
|
obj["location"] = _location;
|
|
obj["guild_id"] = guildId;
|
|
obj["channel_id"] = channelId;
|
|
obj["update_type"] = CHANNEL;
|
|
obj["label"] = label;
|
|
let parent_id = null;
|
|
if (null != channel) {
|
|
parent_id = channel.parent_id;
|
|
}
|
|
obj["parent_id"] = parent_id;
|
|
obj["channel_flags_old"] = tmp4("channel_flags");
|
|
obj["channel_is_muted_old"] = tmp4("channel_is_muted");
|
|
obj["channel_muted_until_old"] = tmp4("channel_muted_until");
|
|
obj["channel_is_overridden_old"] = tmp4("channel_is_overridden");
|
|
obj["channel_message_notification_settings_old"] = tmp4("channel_message_notification_settings");
|
|
obj["is_opt_in_only_change"] = 0 === removeFlagsResult;
|
|
obj["last_message_type"] = tmp11;
|
|
obj["application_id"] = applicationId;
|
|
importDefault(dependencyMap[9]).trackWithMetadata(constants.NOTIFICATION_SETTINGS_UPDATED, obj);
|
|
};
|
|
export { getCurrentGuildSettings };
|
|
export const getManyCurrentGuildSettings = function getManyCurrentGuildSettings(arr) {
|
|
const map = new Map();
|
|
const arg1 = map;
|
|
const item = arr.forEach((arg0) => map.set(arg0, callback(arg0)));
|
|
return map;
|
|
};
|
|
export { getCurrentChannelSettings };
|
|
export const getManyCurrentChannelSettings = function getManyCurrentChannelSettings(guildId, keys) {
|
|
keys = guildId;
|
|
const map = new Map();
|
|
const importDefault = map;
|
|
const item = keys.forEach((arg0) => map.set(arg0, callback(arg0, arg0)));
|
|
return map;
|
|
};
|
|
export const trackAccountNotificationSettingUpdated = function trackAccountNotificationSettingUpdated(quietMode, quietMode2) {
|
|
let obj = importDefault(dependencyMap[10]);
|
|
obj = { update_type: constants2.ACCOUNT, quiet_mode_enabled: quietMode.quietMode, quiet_mode_enabled_old: quietMode2.quietMode };
|
|
obj.track(constants.NOTIFICATION_SETTINGS_UPDATED, obj);
|
|
};
|