Files
discord-decomp/modules/changelog/useCurrentChangelog.tsx
T
2026-11-01 12:12:55 +02:00

95 lines
3.5 KiB
TypeScript

// Metro module 7866 (f7867).
import { useEffect } from "react";
import LocaleStore from "../user_settings/LocaleStore";
import ChangelogStore from "./ChangelogStore";
import { ChangelogLoadState } from "./ChangelogConstants";
import { useStateFromStoresObject, useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
import ChangeLogActionCreators from "../../actions/ChangeLogActionCreators";
const useChangelog = function useChangelog(a0, stateFromStores) {
let r30;
let c16054_0, c16054_1, changelog, loadState;
L7: {
c16054_0 = a0;
c16054_1 = stateFromStores;
const stateFromStoresObject = useStateFromStoresObject([ChangelogStore], () => {
const changelog2 = c16054_0 != null ? ChangelogStore.getChangelog(c16054_0, c16054_1) : null;
const defaultChangelog = c16054_0 != null ? ChangelogStore.getChangelog(c16054_0, "en-US") : null;
const defaultLoadState = c16054_0 != null && ChangelogStore.getChangelogLoadStatus(c16054_0, "en-US");
return {
changelog: changelog2,
loadState: c16054_0 != null && ChangelogStore.getChangelogLoadStatus(c16054_0, c16054_1),
defaultChangelog,
defaultLoadState
};
}, [a0, stateFromStores]);
changelog = stateFromStoresObject.changelog;
loadState = stateFromStoresObject.loadState;
const { defaultChangelog, defaultLoadState } = stateFromStoresObject;
useEffect(() => {
if (c16054_0 != null && changelog == null && loadState === ChangelogLoadState.NOT_LOADED) {
ChangeLogActionCreators.fetchChangelog(c16054_0, c16054_1);
}
}, [a0, changelog, loadState, stateFromStores]);
if (a0 == null) {
r30 = {
id: a0,
changelog: null,
loaded: false
};
} else {
if (changelog == null && loadState === ChangelogLoadState.LOADED_FAILURE) {
r30 = {
id: a0,
changelog: defaultChangelog,
loaded: defaultLoadState !== ChangelogLoadState.NOT_LOADED
};
break L7;
}
r30 = {
id: a0,
changelog,
loaded: loadState !== ChangelogLoadState.NOT_LOADED
};
}
}
return r30;
};
export { useChangelog };
export function useCurrentChangelog() {
let r53, changelog3, loaded;
const stateFromStores = useStateFromStores([LocaleStore], () => LocaleStore.locale);
const stateFromStores2 = useStateFromStores([ChangelogStore], () => ChangelogStore.latestChangelogId());
const stateFromStores3 = useStateFromStores([ChangelogStore], () => ChangelogStore.getConfig());
const r2 = stateFromStores3 != null && Object.keys(stateFromStores3).length === 0;
const clientTooOld = stateFromStores3 != null && Object.keys(stateFromStores3).length > 0 && stateFromStores2 == null;
L13: {
L10: {
const stateFromStores4 = useStateFromStores([ChangelogStore], () => ChangelogStore.overrideId());
const changelog2 = useChangelog(stateFromStores2, stateFromStores);
changelog3 = changelog2.changelog;
loaded = changelog2.loaded;
const changelog4 = useChangelog(stateFromStores4, stateFromStores);
const { changelog: changelog5, loaded: loaded2 } = changelog4;
if (stateFromStores4 != null) {
if (changelog5 == null && loaded2) {
break L10;
}
r53 = {
id: stateFromStores4,
changelog: changelog5,
loaded: loaded2,
clientTooOld: false
};
break L13;
}
}
r53 = {
id: stateFromStores2,
changelog: changelog3,
loaded: !!r2 || loaded,
clientTooOld
};
}
return r53;
}