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

96 lines
2.1 KiB
TypeScript

// Metro module 11066 (f11067).
import { Endpoints } from "../../Constants";
import Dispatcher from "../../Dispatcher";
import { HTTP } from "../../_bundle/sendRequest";
import { APIError } from "../../errors/index";
export function dismissMediaPostSharePrompt(a0) {
Dispatcher.dispatch({
type: "DISMISS_MEDIA_POST_SHARE_PROMPT",
threadId: a0
});
}
export async function fetchMediaPostEmbed(threadId) {
let c26928_4 = 0;
let c30340_0, c30340_1;
L10: {
try {
c30340_0 = threadId;
c30340_1 = void 0;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH",
threadId
});
c26928_4 = 1;
c30340_1 = (await HTTP.get({
url: Endpoints.MEDIA_POST_RESHARE_GET_PREVIEW(threadId),
rejectWithError: true
})).body;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH_SUCCESS",
threadId: c30340_0,
mediaPostEmbed: c30340_1
});
c26928_4 = 0;
} catch ($e) {
let r8 = $e;
if (c26928_4 !== 0) {
while (true) {
try {
c26928_4 = 0;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH_FAILURE",
threadId: c30340_0
});
break L10;
} catch ($e) {
r8 = $e;
if (c26928_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function unfurlEmbedUrl(urls) {
let body;
let c26929_3;
let c26929_4 = 0;
let c30341_0;
try {
c26929_4 = 1;
body = (await HTTP.post({
url: Endpoints.UNFURL_EMBED_URLS,
body: {
urls
},
rejectWithError: false
})).body;
c26929_4 = 0;
} catch ($e) {
const r25 = $e;
let r8 = r25;
c26929_3 = r25;
if (c26929_4 !== 0) {
while (true) {
try {
const r60 = c26929_3;
c26929_4 = 0;
c30341_0 = r60;
throw new APIError(c30341_0);
} catch (r56) {
r8 = r56;
c26929_3 = r56;
if (c26929_4 === 0) {
break;
}
}
}
}
throw r8;
}
return body;
}