decord/source/modules/threads/LazyLoadedThreadManager.tsx

209 lines
7 KiB
TypeScript
Raw Normal View History

// Module ID: 7387
// Function ID: 7388
// Name: LazyLoadedThreadManager
// Dependencies: [5328, 1961, 1957, 2011, 1074, 1964, 573, 7294, 4433, 4446, 1272, 2]
2026-07-20 16:05:17 +00:00
// Module 7387 (LazyLoadedThreadManager)
import DispatcherDefault from "Dispatcher" /* 573 */;
import GatewayConnectionStore from "GatewayConnectionStore" /* 5328 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2011 */;
2026-07-23 10:11:24 +00:00
const require = fn;
2026-07-20 16:05:17 +00:00
function initialize() {
2026-07-23 10:11:24 +00:00
if (!c12) {
c12 = true;
const subscription = DispatcherDefault.subscribe("CONNECTION_OPEN", () => {
2026-08-24 06:08:38 +00:00
closure_11 = {};
2026-07-29 08:29:29 +00:00
channelId = channelId.getChannelId();
2026-07-20 16:05:17 +00:00
if (tmp2) {
loadThread(channelId);
2026-07-20 16:05:17 +00:00
}
});
}
}
function dispatchLoadedThread(nextResult, arg1) {
const tmp = React4(nextResult);
DispatcherDefault.dispatch({ type: "THREAD_CREATE", channel: tmp, messageId: undefined });
2026-07-20 16:05:17 +00:00
}
function loadThread(channelId) {
_require = channelId;
2026-07-20 16:05:17 +00:00
if (null == channelId) {
return Promise.resolve();
} else if (channelId === require("FakePlaceholderPrivateChannel").FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID) {
2026-07-20 16:05:17 +00:00
return Promise.resolve();
} else if (isStaticChannelRoute(channelId)) {
return Promise.resolve();
} else if (null != ChannelStore.getChannel(channelId)) {
2026-07-20 16:05:17 +00:00
return Promise.resolve();
} else {
2026-07-29 08:29:29 +00:00
if (!c12) {
c12 = true;
const subscription = DispatcherDefault.subscribe("CONNECTION_OPEN", () => {
2026-08-24 06:08:38 +00:00
closure_11 = {};
2026-07-29 08:29:29 +00:00
channelId = channelId.getChannelId();
if (tmp2) {
loadThread(channelId);
2026-07-29 08:29:29 +00:00
}
});
}
if (GatewayConnectionStore.isConnected()) {
2026-07-23 10:11:24 +00:00
if (null != dependencyMap[channelId]) {
2026-07-29 08:29:29 +00:00
if ("LOADING" === tmp7.type) {
let resolved = tmp7.promise;
2026-07-20 16:05:17 +00:00
} else {
resolved = Promise.resolve();
}
return resolved;
} else {
const _location = location;
let obj2 = { path: null, exact: true };
const RouteParam = tmp13(4446).RouteParam;
const tmp13Result = tmp13(4433);
const RouteParam2 = tmp13(4446).RouteParam;
obj2.path = closure_9.CHANNEL(RouteParam.guildId(), RouteParam2.channelId(), ":messageId");
importDefault = tmp13Result.matchPath(location.pathname, obj2);
const HTTP = tmp13(1272).HTTP;
const obj3 = { url: closure_8.CHANNEL(channelId), rejectWithError: null };
2026-07-29 08:29:29 +00:00
const guildIdResult = RouteParam.guildId();
obj3.rejectWithError = tmp13(1272).rejectWithMigratedError();
value = HTTP.get(obj3);
const tmp13Result2 = tmp13(1272);
2026-07-20 16:05:17 +00:00
const catchPromise = value.then((body) => {
body = body.body;
closure_11[closure_0] = { type: "LOADED" };
if (set.has(body.type)) {
2026-07-20 16:05:17 +00:00
let messageId;
if (closure_1 != null) {
const params = closure_1.params;
2026-07-29 08:29:29 +00:00
if (params != null) {
2026-07-20 16:05:17 +00:00
messageId = params.messageId;
}
}
const tmp4 = React4(body);
const obj2 = { type: "THREAD_CREATE", channel: tmp4, messageId };
DispatcherDefault.dispatch(obj2);
2026-07-20 16:05:17 +00:00
}
}).catch(() => {
closure_11[id] = { type: "NOT_FOUND" };
const obj2 = { id, guild_id: null, parent_id: "Array" };
2026-07-20 16:05:17 +00:00
let guildId;
if (closure_1 != null) {
const params = closure_1.params;
2026-07-29 08:29:29 +00:00
if (params != null) {
2026-07-20 16:05:17 +00:00
guildId = params.guildId;
}
}
obj2.guild_id = guildId;
DispatcherDefault.dispatch({ type: "CHANNEL_DELETE", channel: obj2 });
2026-07-20 16:05:17 +00:00
});
const obj4 = { type: "LOADING", promise: catchPromise };
dependencyMap[channelId] = obj4;
2026-07-20 16:05:17 +00:00
return catchPromise;
}
} else {
return Promise.resolve();
}
}
}
const ChannelRecord = fn(1961);
({ createChannelRecordFromServer: closure_4, THREAD_CHANNEL_TYPES: hasOwnProperty } = ChannelRecord);
const Constants = fn(1074);
({ Endpoints: closure_8, Routes: closure_9 } = Constants);
const isStaticChannelRoute = fn(1964).isStaticChannelRoute;
const dependencyMap = {};
2026-07-23 10:11:24 +00:00
let c12 = false;
const size = fn(2);
const result = size.fileFinishedImporting("modules/threads/LazyLoadedThreadManager.tsx");
2026-07-23 10:11:24 +00:00
export default {
2026-07-29 08:29:29 +00:00
getLoadState(key10013) {
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (dependencyMap[key10013] != null) {
2026-07-20 16:05:17 +00:00
type = tmp.type;
}
return type;
},
loadThread,
loadThreadsBulk(arr) {
initialize();
if (GatewayConnectionStore.isConnected()) {
2026-07-20 16:05:17 +00:00
const items = [];
const items1 = [];
2026-07-29 08:29:29 +00:00
let iter = arr[Symbol.iterator]();
let nextResult = iter.next();
while (iter !== undefined) {
let tmp9 = nextResult;
if (nextResult !== items1(7294).FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID) {
2026-07-29 08:29:29 +00:00
if (!isStaticChannelRoute(tmp9)) {
if (null == ChannelStore.getChannel(tmp9)) {
2026-07-29 08:29:29 +00:00
let tmp18 = dependencyMap[tmp9];
let tmp19 = tmp18;
if (null == tmp18) {
arr = items1.push(tmp9);
} else if ("LOADING" === tmp19.type) {
let arr2 = items.push(tmp19.promise);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
if (0 === items1.length) {
return Promise.all(items).then(() => {
});
} else {
const HTTP = items1(1272).HTTP;
const request = { url: closure_8.THREADS_BULK, body: null, rejectWithError: null };
const obj2 = { thread_ids: items1 };
request.body = obj2;
request.rejectWithError = items1(1272).rejectWithMigratedError();
const obj4 = items1(1272);
const postResult = HTTP.post(request);
const catchPromise = HTTP.post(request).then((result) => {
set = new Set();
const iter = result.body.items[Symbol.iterator]();
2026-07-29 08:29:29 +00:00
const nextResult = iter.next();
while (iter !== undefined) {
let id = nextResult.id;
let addResult = set.add(id);
closure_11[id] = { type: "LOADED" };
let tmp5 = dispatchLoadedThread(nextResult);
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
for (const item10029 of items1) {
let tmp6 = item10029;
if (!set.has(item10029)) {
closure_11[tmp6] = { type: "NOT_FOUND" };
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
}).catch(() => {
2026-07-29 08:29:29 +00:00
for (const item10005 of items1) {
delete tmp[tmp2];
continue;
2026-07-20 16:05:17 +00:00
}
});
2026-07-29 08:29:29 +00:00
for (const item10052 of items1) {
let obj = { type: "LOADING", promise: catchPromise };
2026-07-29 08:29:29 +00:00
dependencyMap[item10052] = obj;
continue;
2026-07-20 16:05:17 +00:00
}
let nextPromise1 = catchPromise;
if (0 !== items.length) {
const items2 = [];
2026-07-29 08:29:29 +00:00
items2[HermesBuiltin.arraySpread(items, 0)] = catchPromise;
2026-07-20 16:05:17 +00:00
nextPromise1 = Promise.all(items2).then(() => {
});
const allPromises1 = Promise.all(items2);
}
return nextPromise1;
}
} else {
return Promise.resolve();
}
}
};