53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
// Metro module 10991 (f10992).
|
|
import GatewayConnectionStore from "../gateway/GatewayConnectionStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import { Endpoints } from "../../Constants";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest";
|
|
import { transitionToGuild } from "../routing/transitionToGuild.native";
|
|
const r20 = {
|
|
acceptGuildTemplate: (a0, name, icon) => {
|
|
const code = a0;
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_TEMPLATE_ACCEPT",
|
|
code: a0
|
|
});
|
|
return new Promise((c26900_0, c26900_1) => {
|
|
HTTP.post({
|
|
url: Endpoints.UNRESOLVED_GUILD_TEMPLATE(code),
|
|
body: {
|
|
name,
|
|
icon
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then(({ body }) => {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_TEMPLATE_ACCEPT_SUCCESS",
|
|
code,
|
|
guild: body
|
|
});
|
|
if (GatewayConnectionStore.isConnected()) {
|
|
GuildStore.addConditionalChangeListener(() => {
|
|
if (GuildStore.getGuild(body.id) != null) {
|
|
transitionToGuild(body.id);
|
|
c26900_0(body);
|
|
return false;
|
|
}
|
|
});
|
|
} else {
|
|
transitionToGuild(body.id);
|
|
c26900_0(body);
|
|
}
|
|
}, (a0) => {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_TEMPLATE_ACCEPT_FAILURE",
|
|
code
|
|
});
|
|
c26900_1(a0.body);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
export default r20;
|