// Module ID: 17979 // Function ID: 17980 // Name: FrecencyUserSettingsManager // Dependencies: [5, 9222, 9221, 5994, 5425, 6036, 6093, 1244, 1095, 1373, 1102, 6804, 2046, 1245, 1246, 12, 2] // Module 17979 (FrecencyUserSettingsManager) import UserSettingsConstants from "UserSettingsConstants" /* 1095 */; import DurationsDefault from "Durations" /* 1102 */; import frecency_user_settings from "frecency_user_settings" /* 1245 */; import user_settings_UserSettingsUtils from "user_settings/UserSettingsUtils" /* 1246 */; import ApplicationConstants from "ApplicationConstants" /* 1373 */; import UserSettingsProtoActionCreators from "UserSettingsProtoActionCreators" /* 2046 */; import FrecencyStore2 from "FrecencyStore" /* 6093 */; import _asyncToGenerator from "_asyncToGenerator" /* 5 */; import ApplicationCommandFrecencyStore from "ApplicationCommandFrecencyStore" /* 9222 */; import ApplicationFrecencyStore from "ApplicationFrecencyStore" /* 9221 */; import EmojiStore from "EmojiStore" /* 5994 */; import SoundboardStore from "SoundboardStore" /* 5425 */; import StickersPersistedStore from "StickersPersistedStore" /* 6036 */; import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1244 */; import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6804 */; import size from "module_2" /* 2 */; const FrecencyStore = FrecencyStore2; let c3, c4; function handleConnectionOpen() { let closure_16; let timeout; c17 = true; let c0 = true; const tmp = closure_14; if (null != timeout) { const _clearTimeout = clearTimeout; clearTimeout(timeout); } timeout = setTimeout(() => saveProtos(c0), tmp); } function handleAppStateUpdate(state) { const tmp = c17 && "active" !== state.state; if (tmp) { const _clearTimeout = clearTimeout; clearTimeout(c16); c16 = null; saveProtos(false); } } function handleConnectionClosed() { const tmp = c17; if (tmp) { const _clearTimeout = clearTimeout; clearTimeout(c16); c16 = null; saveProtos(false); } } function saveProtos() { return obj(...arguments); } let actions = function _saveProtos() { let obj = _asyncToGenerator(async (arg0, value) => { let closure_0 = arg0; if (c4 === 2) { c4 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp3 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj3 = { value, done: true }; return obj3; } else { return { value: "IconComponent", done: null }; } } else { try { c4 = 2; if (0 === c3) { if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c4 = 3; const obj4 = { value, done: true }; return obj4; } else { let closure_2 = tmp; let closure_1 = tmp; resetTimer(closure_2_15, false); const tmp28 = closure_0; if (!UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS)) { let hasPendingUsageResult = StickersPersistedStore.hasPendingUsage() || EmojiStore.hasPendingUsage() || ApplicationCommandFrecencyStore.hasPendingUsage() || ApplicationFrecencyStore.hasPendingUsage() || SoundboardStore.hasPendingUsage(); if (!hasPendingUsageResult) { const hasPendingUsageResult1 = FrecencyStore.hasPendingUsage() && !tmp28; hasPendingUsageResult = hasPendingUsageResult1; } if (hasPendingUsageResult) { const obj2 = UserSettingsProtoActionCreators; let result = obj2.markUserSettingsLoadOkayForDevelopment(); const FrecencyUserSettingsActionCreators = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators; c3 = 1; c4 = 1; const obj5 = { value: FrecencyUserSettingsActionCreators.loadIfNecessary(), done: false }; return obj5; } } } } else if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c4 = 3; const obj = { value, done: true }; return obj; } const arr = closure_130_1(closure_130_2[15]); const item = arr.forEach(closure_130_0(closure_130_2[12]).UserSettingsActionCreatorsByType, (markDirtyIfHasPendingChange) => { const result = markDirtyIfHasPendingChange.markDirtyIfHasPendingChange(); }); c4 = 3; return { value: "IconComponent", done: null }; } catch (tmp24) { c4 = 3; throw tmp24; } } }); return obj(...arguments); }; function resetTimer(arg0, arg1) { let closure_16; let timeout; let c0 = false; if (null != timeout) { const _clearTimeout = clearTimeout; clearTimeout(timeout); } timeout = setTimeout(() => saveProtos(c0), arg0); } const MAX_NUM_SELECTED_ITEMS = FrecencyStore2.MAX_NUM_SELECTED_ITEMS; const UserSettingsTypes = UserSettingsConstants.UserSettingsTypes; const FREQUENCY_ITEM_LIMIT = ApplicationConstants.FREQUENCY_ITEM_LIMIT; const random = Math.random(); let closure_14 = 10 + random * (10 * DurationsDefault.Millis.SECOND); let result = 2 * DurationsDefault.Millis.HOUR; const random1 = Math.random(); let closure_15 = result + floor(random1 * (10 * DurationsDefault.Millis.MINUTE)); let c16 = null; let c17 = false; class FrecencyUserSettingsManager extends AutomaticLifecycleManager { constructor() { const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target); actions = { POST_CONNECTION_OPEN: handleConnectionOpen, CONNECTION_RESUMED: handleConnectionOpen, CONNECTION_CLOSED: handleConnectionClosed, APP_STATE_UPDATE: handleAppStateUpdate }; applyArgumentsResult.actions = actions; return applyArgumentsResult; } _initialize() { let obj = { hasChanges() { return false; }, processProto() { let closure_16; let timeout; let c0 = false; const tmp = closure_15; if (null != timeout) { const _clearTimeout = clearTimeout; clearTimeout(timeout); } timeout = setTimeout(() => saveProtos(c0), tmp); } }; const beforeSendCallbacks = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; beforeSendCallbacks.push(obj); let obj2 = { hasChanges() { const hasPendingUsageResult = StickersPersistedStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(stickerFrecency) { let hasPendingUsageResult = StickersPersistedStore.hasPendingUsage(); const tmp = StickersPersistedStore; if (hasPendingUsageResult) { hasPendingUsageResult = UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); } if (hasPendingUsageResult) { const StickerFrecency = frecency_user_settings.StickerFrecency; stickerFrecency.stickerFrecency = StickerFrecency.create(); stickerFrecency = stickerFrecency.stickerFrecency; const obj = user_settings_UserSettingsUtils; stickerFrecency.stickers = obj.serializeUsageHistory(tmp.stickerFrecencyWithoutFetchingLatest.usageHistory, 100); } } }; const beforeSendCallbacks1 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; beforeSendCallbacks1.push(obj2); const beforeSendCallbacks2 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; const obj3 = { hasChanges() { const hasPendingUsageResult = EmojiStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(emojiFrecency) { const hasPendingUsageResult = EmojiStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); if (hasPendingUsageResult) { const EmojiFrecency = frecency_user_settings.EmojiFrecency; emojiFrecency.emojiFrecency = EmojiFrecency.create(); const EmojiFrecency2 = frecency_user_settings.EmojiFrecency; emojiFrecency.emojiReactionFrecency = EmojiFrecency2.create(); emojiFrecency = emojiFrecency.emojiFrecency; const obj = user_settings_UserSettingsUtils; emojiFrecency.emojis = obj.serializeUsageHistory(EmojiStore.emojiFrecencyWithoutFetchingLatest.usageHistory, 100); const emojiReactionFrecency = emojiFrecency.emojiReactionFrecency; const obj2 = user_settings_UserSettingsUtils; emojiReactionFrecency.emojis = obj2.serializeUsageHistory(EmojiStore.emojiReactionFrecencyWithoutFetchingLatest.usageHistory, 100); } } }; beforeSendCallbacks2.push(obj3); const beforeSendCallbacks3 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; const obj4 = { hasChanges() { const hasPendingUsageResult = SoundboardStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(playedSoundFrecency) { let hasPendingUsageResult = SoundboardStore.hasPendingUsage(); const tmp = SoundboardStore; if (hasPendingUsageResult) { hasPendingUsageResult = UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); } if (hasPendingUsageResult) { const PlayedSoundFrecency = frecency_user_settings.PlayedSoundFrecency; playedSoundFrecency.playedSoundFrecency = PlayedSoundFrecency.create(); playedSoundFrecency = playedSoundFrecency.playedSoundFrecency; const obj = user_settings_UserSettingsUtils; playedSoundFrecency.playedSounds = obj.serializeUsageHistory(tmp.playedSoundFrecencyWithoutFetchingLatest.usageHistory, FREQUENCY_ITEM_LIMIT); } } }; beforeSendCallbacks3.push(obj4); const beforeSendCallbacks4 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; const obj5 = { hasChanges() { const hasPendingUsageResult = ApplicationCommandFrecencyStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(applicationCommandFrecency) { let hasPendingUsageResult = ApplicationCommandFrecencyStore.hasPendingUsage(); const obj = ApplicationCommandFrecencyStore; if (hasPendingUsageResult) { hasPendingUsageResult = UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); } if (hasPendingUsageResult) { const ApplicationCommandFrecency = frecency_user_settings.ApplicationCommandFrecency; applicationCommandFrecency.applicationCommandFrecency = ApplicationCommandFrecency.create(); applicationCommandFrecency = applicationCommandFrecency.applicationCommandFrecency; const obj2 = user_settings_UserSettingsUtils; applicationCommandFrecency.applicationCommands = obj2.serializeUsageHistory(obj.getCommandFrecencyWithoutLoadingLatest().usageHistory, 500); } } }; beforeSendCallbacks4.push(obj5); const beforeSendCallbacks5 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; const obj6 = { hasChanges() { const hasPendingUsageResult = ApplicationFrecencyStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(applicationFrecency) { let hasPendingUsageResult = ApplicationFrecencyStore.hasPendingUsage(); const obj = ApplicationFrecencyStore; if (hasPendingUsageResult) { hasPendingUsageResult = UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); } if (hasPendingUsageResult) { const ApplicationFrecency = frecency_user_settings.ApplicationFrecency; applicationFrecency.applicationFrecency = ApplicationFrecency.create(); applicationFrecency = applicationFrecency.applicationFrecency; const obj2 = user_settings_UserSettingsUtils; applicationFrecency.applications = obj2.serializeUsageHistory(obj.getApplicationFrecencyWithoutLoadingLatest().usageHistory, FREQUENCY_ITEM_LIMIT); } } }; beforeSendCallbacks5.push(obj6); const beforeSendCallbacks6 = UserSettingsProtoActionCreators.FrecencyUserSettingsActionCreators.beforeSendCallbacks; const obj7 = { hasChanges() { const hasPendingUsageResult = FrecencyStore.hasPendingUsage() && UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); return hasPendingUsageResult; }, processProto(guildAndChannelFrecency) { let hasPendingUsageResult = FrecencyStore.hasPendingUsage(); const tmp = FrecencyStore; if (hasPendingUsageResult) { hasPendingUsageResult = UserSettingsProtoStore.hasLoaded(constants.FRECENCY_AND_FAVORITES_SETTINGS); } if (hasPendingUsageResult) { const GuildAndChannelFrecency = frecency_user_settings.GuildAndChannelFrecency; guildAndChannelFrecency.guildAndChannelFrecency = GuildAndChannelFrecency.create(); guildAndChannelFrecency = guildAndChannelFrecency.guildAndChannelFrecency; const obj = user_settings_UserSettingsUtils; guildAndChannelFrecency.guildAndChannels = obj.serializeUsageHistory(tmp.frecencyWithoutFetchingLatest.usageHistory, MAX_NUM_SELECTED_ITEMS); } } }; beforeSendCallbacks6.push(obj7); } } const prototype = FrecencyUserSettingsManager.prototype; const frecencyUserSettingsManager = new FrecencyUserSettingsManager(); const result1 = size.fileFinishedImporting("modules/user_settings/FrecencyUserSettingsManager.tsx"); export default frecencyUserSettingsManager;