// Metro module 4200 (f4201). import LocaleStore from "../user_settings/LocaleStore"; import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore"; import { AssetType, ChangelogLoadState } from "./ChangelogConstants"; import { Storage } from "../../_bundle/Module595"; import { LastReceivedChangelogId } from "../user_settings/UserSettings"; import Module589 from "../../_bundle/Module589"; import Dispatcher from "../../Dispatcher"; let c2420_6, loadedChangelogs, latestChangelogId2, id, config, c2420_11, setting, lastSeenChangelogDate2, c2420_14; const handleUserSettingsProtoStoreChange = function handleUserSettingsProtoStoreChange() { setting = LastReceivedChangelogId.getSetting(); }; c2420_6 = {}; loadedChangelogs = {}; latestChangelogId2 = null; id = null; config = null; c2420_11 = "lastChangeLogDate"; setting = null; lastSeenChangelogDate2 = null; c2420_14 = new Set(); class ChangelogStore extends Module589.Store { static displayName = "ChangelogStore"; initialize() { this.waitFor(LocaleStore, UserSettingsProtoStore); this.syncWith([LocaleStore], () => true); this.syncWith([UserSettingsProtoStore], handleUserSettingsProtoStoreChange); const r7 = Storage.get(c2420_11); if (r7 != null) { try { lastSeenChangelogDate2 = new Date(r7); } catch ($e) { Storage.remove(c2420_11); } } } getChangelog(a0, a1) { const r4 = c2420_6[a0]; let r6 = r4 == null ? void 0 : r4[a1]; if (r6 == null) { r6 = null; } return r6; } latestChangelogId() { return latestChangelogId2; } getChangelogLoadStatus(a0, a1) { const r5 = loadedChangelogs[a0]; let r6 = r5 == null ? void 0 : r5[a1]; if (r6 == null) { r6 = ChangelogLoadState.NOT_LOADED; } return r6; } hasLoadedConfig() { return config != null; } getConfig() { return config; } overrideId() { return id; } lastSeenChangelogId() { return setting; } lastSeenChangelogDate() { return lastSeenChangelogDate2; } getStateForDebugging() { return { changelogConfig: config, loadedChangelogs, lastSeenChangelogId: setting, lastSeenChangelogDate: lastSeenChangelogDate2 }; } isLocked() { return c2420_14.size > 0; } } const changelogStore = new ChangelogStore(Dispatcher, { CHANGE_LOG_LOCK: function handleChangeLogLock({ key }) { if (c2420_14.has(key)) { return false; } const set = new Set(c2420_14); c2420_14 = set; set.add(key); }, CHANGE_LOG_UNLOCK: function handleChangeLogUnlock({ key }) { if (c2420_14.has(key)) { const set = new Set(c2420_14); c2420_14 = set; set.delete(key); return void 0; } return false; }, CHANGE_LOG_SET_CONFIG: function handleConfig(a0) { const config2 = a0.config; latestChangelogId2 = a0.latestChangelogId; config = config2; }, CHANGE_LOG_FETCH_SUCCESS: function handleChangelogFetch({ id: id2, changelog }) { if (c2420_6[id2] == null) { c2420_6[id2] = {}; } const r6 = c2420_6[id2]; const locale = changelog.locale; const r13 = { id: id2, date: changelog.date, body: changelog.content, revision: 1, locale: changelog.locale }; r13[changelog.asset_type === AssetType.YOUTUBE_VIDEO_ID ? "youtube_video_id" : "image"] = changelog.asset; r6[locale] = r13; if (loadedChangelogs[id2] == null) { loadedChangelogs[id2] = {}; } loadedChangelogs[id2][changelog.locale] = ChangelogLoadState.LOADED_SUCCESS; }, CHANGE_LOG_FETCH_FAILED: function handleChangelogFetchFailed({ id: id2, locale }) { if (c2420_6[id2] != null && c2420_6[id2][locale] != null) { return false; } if (loadedChangelogs[id2] == null) { loadedChangelogs[id2] = {}; } loadedChangelogs[id2][locale] = ChangelogLoadState.LOADED_FAILURE; }, CHANGE_LOG_SET_OVERRIDE: function handleChangelogSetOverride(a0) { id = a0.id; }, CHANGE_LOG_MARK_SEEN: function handleDismiss({ changelogDate }) { lastSeenChangelogDate2 = new Date(changelogDate); Storage.set(c2420_11, changelogDate); } }); export default changelogStore;