199 lines
5.1 KiB
TypeScript
199 lines
5.1 KiB
TypeScript
// Metro module 5685 (f5686).
|
|
import FramesStore from "../../frames/FramesStore";
|
|
import VibegrationsProjectStore from "../stores/VibegrationsProjectStore";
|
|
import { Endpoints } from "../../../Constants";
|
|
import FramesActionCreators_native from "../../frames/FramesActionCreators.native";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import { HTTP } from "../../../_bundle/sendRequest";
|
|
const reloadActivityIfRunning = function reloadActivityIfRunning(a0) {
|
|
if (a0 != null && FramesStore.getConnectedFrame()?.applicationId === a0) {
|
|
FramesActionCreators_native.refreshProxyTicket({
|
|
applicationId: a0
|
|
});
|
|
}
|
|
};
|
|
export async function listProjects() {
|
|
let c25537_2 = 0;
|
|
let c29552_0;
|
|
L15: {
|
|
try {
|
|
c29552_0 = void 0;
|
|
if (VibegrationsProjectStore.getProjectsFetchState()?.type !== "loading") {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECTS_FETCH_START"
|
|
});
|
|
c25537_2 = 1;
|
|
c29552_0 = (await HTTP.get({
|
|
url: Endpoints.VIBEGRATIONS_PROJECTS,
|
|
rejectWithError: true
|
|
})).body;
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECTS_FETCH_SUCCESS",
|
|
projects: c29552_0
|
|
});
|
|
c25537_2 = 0;
|
|
break L15;
|
|
}
|
|
} catch ($e) {
|
|
let r24 = $e;
|
|
if (c25537_2 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25537_2 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECTS_FETCH_FAIL"
|
|
});
|
|
break L15;
|
|
} catch ($e) {
|
|
r24 = $e;
|
|
if (c25537_2 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r24;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
export async function createProject(body) {
|
|
let c25538_2;
|
|
c25538_2 = void 0;
|
|
let c29553_0 = (await HTTP.post({
|
|
url: Endpoints.VIBEGRATIONS_PROJECTS,
|
|
body,
|
|
rejectWithError: false
|
|
})).body;
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_CREATE_SUCCESS",
|
|
project: c29553_0
|
|
});
|
|
return c29553_0.id;
|
|
}
|
|
export async function renameProject(c25539_0, name) {
|
|
let c25539_3;
|
|
c25539_3 = void 0;
|
|
let c29554_0 = await HTTP.patch({
|
|
url: Endpoints.VIBEGRATIONS_PROJECT(c25539_0),
|
|
body: {
|
|
name
|
|
},
|
|
rejectWithError: false
|
|
});
|
|
if (c29554_0.ok) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_UPDATE_SUCCESS",
|
|
project: c29554_0.body
|
|
});
|
|
}
|
|
return c29554_0;
|
|
}
|
|
export async function setGuildHints(c25540_0, body2) {
|
|
let c25540_3;
|
|
c25540_3 = void 0;
|
|
let c29555_0 = await HTTP.patch({
|
|
url: Endpoints.VIBEGRATIONS_PROJECT(c25540_0),
|
|
body: body2,
|
|
rejectWithError: false
|
|
});
|
|
if (c29555_0.ok) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_UPDATE_SUCCESS",
|
|
project: c29555_0.body
|
|
});
|
|
}
|
|
return c29555_0;
|
|
}
|
|
export async function deleteProject(c25541_0) {
|
|
let c25541_2;
|
|
c25541_2 = void 0;
|
|
let c29556_0 = c25541_0;
|
|
let c29556_1 = await HTTP.del({
|
|
url: Endpoints.VIBEGRATIONS_PROJECT(c25541_0),
|
|
rejectWithError: false
|
|
});
|
|
if (c29556_1.ok) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_DELETE_SUCCESS",
|
|
projectId: c29556_0
|
|
});
|
|
}
|
|
return c29556_1;
|
|
}
|
|
export function setSelectedProjectForGuild(a0, a1) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_SELECT",
|
|
guildId: a0,
|
|
projectId: a1
|
|
});
|
|
}
|
|
export async function publishProject(c25542_0) {
|
|
let c25542_2;
|
|
let c29557_1, c29557_2, c29557_3;
|
|
c25542_2 = void 0;
|
|
c29557_1 = void 0;
|
|
c29557_2 = void 0;
|
|
c29557_3 = void 0;
|
|
let c29557_0 = await HTTP.post({
|
|
url: Endpoints.VIBEGRATIONS_PROJECT_PUBLISH(c25542_0),
|
|
rejectWithError: false
|
|
});
|
|
if (c29557_0.ok) {
|
|
c29557_1 = c29557_0.body;
|
|
c29557_2 = c29557_1.application;
|
|
c29557_3 = c29557_1.project;
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_UPDATE_SUCCESS",
|
|
project: c29557_3
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_FETCH_SUCCESS",
|
|
application: c29557_2,
|
|
isHydrated: true
|
|
});
|
|
(0, reloadActivityIfRunning)(c29557_2.id);
|
|
}
|
|
return c29557_0;
|
|
}
|
|
export async function publishPreviewProject(c25543_0) {
|
|
let c25543_2;
|
|
let c29558_1, c29558_2, c29558_3;
|
|
c25543_2 = void 0;
|
|
c29558_1 = void 0;
|
|
c29558_2 = void 0;
|
|
c29558_3 = void 0;
|
|
let c29558_0 = await HTTP.post({
|
|
url: Endpoints.VIBEGRATIONS_PROJECT_PUBLISH_PREVIEW(c25543_0),
|
|
rejectWithError: false
|
|
});
|
|
if (c29558_0.ok) {
|
|
c29558_1 = c29558_0.body;
|
|
c29558_2 = c29558_1.application;
|
|
c29558_3 = c29558_1.project;
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_PROJECT_UPDATE_SUCCESS",
|
|
project: c29558_3
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "APPLICATION_FETCH_SUCCESS",
|
|
application: c29558_2,
|
|
isHydrated: true
|
|
});
|
|
(0, reloadActivityIfRunning)(c29558_2.id);
|
|
}
|
|
return c29558_0;
|
|
}
|
|
export function setChatSidebarWidth(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_CHAT_SIDEBAR_WIDTH_SET",
|
|
width: a0
|
|
});
|
|
}
|
|
export function setBuilderPreviewApplicationId(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "VIBEGRATIONS_BUILDER_PREVIEW_APPLICATION_SET",
|
|
applicationId: a0
|
|
});
|
|
}
|