Files
discord-decomp/actions/ChangeLogActionCreators.tsx
T
2026-11-01 12:12:55 +02:00

122 lines
3.4 KiB
TypeScript

// Metro module 7867 (f7868).
import ChangelogStore from "../modules/changelog/ChangelogStore";
import { Endpoints } from "../Constants";
import { ChangelogPlatforms } from "../modules/changelog/ChangelogConstants";
import Dispatcher from "../Dispatcher";
import { LastReceivedChangelogId } from "../modules/user_settings/UserSettings";
import { HTTP } from "../_bundle/sendRequest";
const cacheBustParam = function cacheBustParam() {
return `x=${Math.floor(new Date().getMinutes() / 5)}`;
};
const r24 = {
lockChangeLog: (a0) => {
Dispatcher.dispatch({
type: "CHANGE_LOG_LOCK",
key: a0
});
},
unlockChangeLog: (a0) => {
Dispatcher.dispatch({
type: "CHANGE_LOG_UNLOCK",
key: a0
});
},
markChangelogAsSeen: (a0, a1) => {
Dispatcher.dispatch({
type: "CHANGE_LOG_MARK_SEEN",
changelogId: a0,
changelogDate: a1
});
LastReceivedChangelogId.updateSetting(a0);
},
setChangelogOverride: function setChangelogOverride(a0) {
Dispatcher.dispatch({
type: "CHANGE_LOG_SET_OVERRIDE",
id: a0
});
if (a0 != null) {
this.sendChangelogMessage(a0);
}
},
sendChangelogMessage: (a0) => {
HTTP.post({
url: Endpoints.CHANGELOG_MESSAGES,
body: {
changelog_id: a0
},
rejectWithError: true
});
},
fetchChangelogConfig: () => HTTP.get({
url: `https://cdn.discordapp.com/changelogs/config_${ChangelogPlatforms.MOBILE}.json?${`x=${Math.floor(new Date().getMinutes() / 5)}`}`,
rejectWithError: true
}),
fetchChangelog: async function fetchChangelog(c16055_0, c16055_1, r7 = false) {
let r129, body, changelog;
let c16055_2 = r7;
let r5 = arguments[3];
if (r5 === void 0) {
r5 = false;
}
let c16055_3 = r5;
const _this = this;
let c26045_2 = 0;
let c29858_0;
L17: {
try {
c29858_0 = void 0;
if (ChangelogStore.getChangelog(c16055_0, c16055_1) != null) {
break L17;
}
const r35 = c16055_2 ? ChangelogPlatforms.DESKTOP : ChangelogPlatforms.MOBILE;
const r34 = c16055_3 ? "" : `?${cacheBustParam()}`;
c26045_2 = 1;
c29858_0 = await HTTP.get({
url: `https://cdn.discordapp.com/changelogs/${r35}/${c16055_0}/${c16055_1}.json${r34}`,
rejectWithError: true
});
Dispatcher.dispatch({
type: "CHANGE_LOG_FETCH_SUCCESS",
id: c16055_0,
changelog: c29858_0.body
});
body = c29858_0.body;
c26045_2 = 0;
} catch ($e) {
let r51 = $e;
if (c26045_2 !== 0) {
while (true) {
L28: {
try {
c26045_2 = 0;
Dispatcher.dispatch({
type: "CHANGE_LOG_FETCH_FAILED",
id: c16055_0,
locale: c16055_1
});
r129 = null;
if (c16055_1 !== "en-US") {
changelog = await _this.fetchChangelog(c16055_0, "en-US");
break L28;
}
} catch ($e) {
r51 = $e;
if (c26045_2 === 0) {
break;
}
continue;
}
return r129;
}
return changelog;
}
}
throw r51;
}
return body;
}
return null;
}
};
export default r24;