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

199 lines
5.1 KiB
TypeScript

// Metro module 7689 (f7690).
import { Endpoints } from "../../Constants";
import Dispatcher from "../../Dispatcher";
import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest";
function $mk79200($env) {
return () => {
let r15;
let env26017;
const r9 = $env.$parent;
const code4 = $env[0];
const r3 = env26017 = {
$parent: r9
};
env26017[0] = code4;
const r8 = r9[1];
const r4 = r9[2];
if (r8(r4[1]).isDispatching()) {
r15 = Promise.resolve().then($mk79200(r3));
} else {
const r6 = r9[5];
r15 = r6.get(code4);
if (r15 == null) {
r8(r4[1]).dispatch({
type: "GUILD_TEMPLATE_RESOLVE",
code: code4
});
const r29 = (0, r9[0])(r4[2]).HTTP.get({
url: r9[3].UNRESOLVED_GUILD_TEMPLATE(code4),
oldFormErrors: true,
rejectWithError: true
});
const r31 = $mk79202(r3);
const r36 = r29.then($mk79201(r3), r31).finally($mk79203(r3));
r6.set(code4, r36);
r15 = r36;
}
}
return r15;
};
}
function $mk79201($env) {
return ({ body }) => {
const r10 = $env.$parent;
const r5 = r10[1];
const r3 = r10[2];
const r8 = r5(r3[3]);
const GUILD_TEMPLATE_RESOLVED = r10[4].GUILD_TEMPLATE_RESOLVED;
const guild_template_code = $env[0];
r8.track(GUILD_TEMPLATE_RESOLVED, {
resolved: true,
guild_template_code,
guild_template_name: body.name,
guild_template_description: body.description,
guild_template_guild_id: body.source_guild_id
});
r5(r3[1]).dispatch({
type: "GUILD_TEMPLATE_RESOLVE_SUCCESS",
guildTemplate: body,
code: guild_template_code
});
return {
guildTemplate: r5(r3[4])(body),
code: guild_template_code
};
};
}
function $mk79202($env) {
return () => {
const r2 = $env.$parent;
const r3 = r2[1];
const r1 = r2[2];
const r7 = r3(r1[3]);
const GUILD_TEMPLATE_RESOLVED = r2[4].GUILD_TEMPLATE_RESOLVED;
const guild_template_code = $env[0];
r7.track(GUILD_TEMPLATE_RESOLVED, {
resolved: false,
guild_template_code
});
r3(r1[1]).dispatch({
type: "GUILD_TEMPLATE_RESOLVE_FAILURE",
code: guild_template_code
});
return {
guildTemplate: null,
code: guild_template_code
};
};
}
function $mk79203($env) {
return () => {
$env.$parent[5].delete($env[0]);
};
}
let env4832 = {};
const c4832_5 = new Map();
const r25 = {
resolveGuildTemplate: function resolveGuildTemplate(a0) {
let env15962;
const r2 = env15962 = {
$parent: env4832
};
env15962[0] = a0;
if (Dispatcher.isDispatching()) {
return Promise.resolve().then($mk79200(r2));
}
const r14 = c4832_5.get(a0);
if (r14 != null) {
return r14;
}
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_RESOLVE",
code: a0
});
const r28 = HTTP.get({
url: Endpoints.UNRESOLVED_GUILD_TEMPLATE(a0),
oldFormErrors: true,
rejectWithError: true
});
const r30 = $mk79202(r2);
const r35 = r28.then($mk79201(r2), r30).finally($mk79203(r2));
c4832_5.set(a0, r35);
return r35;
},
loadTemplatesForGuild: (a0) => HTTP.get({
url: Endpoints.GUILD_TEMPLATES(a0),
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then((result) => {
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_LOAD_FOR_GUILD_SUCCESS",
guildTemplates: result.body
});
return result;
}),
createGuildTemplate: (a0, a1, a2) => HTTP.post({
url: Endpoints.GUILD_TEMPLATES(a0),
body: {
name: a1,
description: a2
},
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then((result) => {
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_CREATE_SUCCESS",
guildTemplate: result.body,
code: result.body.code
});
}),
syncGuildTemplate: (a0, a1) => {
const code = a1;
return HTTP.put({
url: Endpoints.GUILD_TEMPLATE(a0, a1),
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then((result) => {
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_SYNC_SUCCESS",
guildTemplate: result.body,
code
});
});
},
updateGuildTemplate: (a0, a1, a2, a3) => {
const code2 = a1;
return HTTP.patch({
url: Endpoints.GUILD_TEMPLATE(a0, a1),
body: {
name: a2,
description: a3
},
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then((result) => {
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_SYNC_SUCCESS",
guildTemplate: result.body,
code: code2
});
});
},
deleteGuildTemplate: (a0, a1) => {
const guildId = a0;
const code3 = a1;
return HTTP.del({
url: Endpoints.GUILD_TEMPLATE(a0, a1),
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
}).then(() => {
Dispatcher.dispatch({
type: "GUILD_TEMPLATE_DELETE_SUCCESS",
guildId,
code: code3
});
});
}
};
export default r25;