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

39 lines
1.2 KiB
TypeScript

// Metro module 13886 (f13887).
import { Endpoints } from "../Constants";
import Dispatcher from "../Dispatcher";
import { intl, t } from "../intl/index.native";
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
let handleRequestFailure;
const handleRequestSuccess = function handleRequestSuccess(a0) {
if (a0 != null && a0.body != null) {
Dispatcher.dispatch({
type: "UPDATE_CONSENTS",
consents: {
...a0.body
}
});
}
return a0.body;
};
handleRequestFailure = function handleRequestFailure(a0) {
throw new Error(a0.status >= 500 && a0.status <= 599 ? intl.string(t.cvJdtg) : a0 != null && (a0.body != null && a0.body.message != null) ? a0.body.message : intl.string(t.cvJdtg));
};
export function fetchConsents() {
return HTTP.get({
url: Endpoints.SETTINGS_CONSENT,
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then(handleRequestSuccess, (a0) => Promise.reject(new Error(a0.body.message)));
}
export function setConsents(a0, a1) {
return HTTP.post({
url: Endpoints.SETTINGS_CONSENT,
body: {
grant: a0,
revoke: a1
},
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then(handleRequestSuccess, handleRequestFailure);
}