This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

+304
View File
@@ -0,0 +1,304 @@
// Metro module 6064 (f6065).
import ChannelStore from "../../stores/ChannelStore";
import { computeThreadIdsSnapshot } from "./ForumActivePostStore";
import ForumPostMessagesStore from "./ForumPostMessagesStore";
import ForumPostRecentMessageStore from "./ForumPostRecentMessageStore";
import { Endpoints } from "../../Constants";
import Module12 from "../../_bundle/Module12";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { useStateFromStoresObject, useStateFromStores } from "../../_bundle/Module589";
import { HTTP } from "../../_bundle/sendRequest";
import Dispatcher from "../../Dispatcher";
function $mk77684($env) {
return (a0) => {
const r3 = $env.$parent;
const message = r3[6].getMessage(a0);
const { loaded, firstMessage } = message;
if (loaded ? !loaded : firstMessage == null) {
const r10 = $env;
r3[10].request(r10[0].id, a0);
r10[1] = true;
}
};
}
function $mk77687() {
return () => new Set();
}
let loadForumPostDataForChannelId, c3845_10;
let env3845 = {};
const loadForumPostData = async function loadForumPostData() {
let c25689_2;
let c25689_3 = 0;
L15: {
try {
c25689_3 = 1;
if (c3845_10.hasNext()) {
await (0, loadForumPostDataForChannelId)(c3845_10.next());
while (true) {
if (!c3845_10.hasNext()) {
c25689_3 = 0;
env3845[11] = null;
break L15;
}
await (0, loadForumPostDataForChannelId)(c3845_10.next());
}
} else {
c25689_3 = 0;
env3845[11] = null;
}
} catch ($e) {
const r25 = $e;
let r8 = r25;
c25689_2 = r25;
if (c25689_3 !== 0) {
while (true) {
try {
const r86 = c25689_2;
c25689_3 = 0;
env3845[11] = null;
throw r86;
} catch (r83) {
r8 = r83;
c25689_2 = r83;
if (c25689_3 === 0) {
break;
}
}
}
}
throw r8;
}
return void 0;
}
};
loadForumPostDataForChannelId = async function loadForumPostDataForChannelId(c25690_0) {
let c25690_3;
let c25690_4 = 0;
let c29654_0, c29654_1, c29654_2, c29654_3;
L18: {
L16: {
try {
c29654_0 = c25690_0;
c29654_1 = void 0;
c29654_2 = void 0;
c29654_3 = void 0;
const nextBatch = c3845_10.getNextBatch(c25690_0, 10);
c29654_1 = nextBatch;
c25690_4 = 2;
if (nextBatch.length === 0) {
c25690_4 = 0;
c3845_10.finishRequesting(c25690_0, nextBatch);
break L18;
}
const guild_id = ChannelStore.getChannel(c25690_0)?.guild_id;
c29654_2 = guild_id;
if (guild_id != null) {
c29654_3 = (await HTTP.post({
url: Endpoints.FORUM_POSTS(c25690_0),
body: {
thread_ids: nextBatch
},
rejectWithError: true
})).body.threads;
Dispatcher.dispatch({
type: "LOAD_FORUM_POSTS",
guildId: c29654_2,
threads: c29654_3
});
c25690_4 = 1;
c25690_4 = 0;
c3845_10.finishRequesting(c29654_0, c29654_1);
break L16;
}
c25690_4 = 0;
c3845_10.finishRequesting(c25690_0, nextBatch);
} catch ($e) {
const r29 = $e;
let r8 = r29;
c25690_3 = r29;
let r30 = c25690_4;
if (r30 !== 0) {
while (true) {
if (r30 === 1) {
try {
const r112 = c25690_3;
c25690_4 = 0;
c3845_10.finishRequesting(c29654_0, c29654_1);
throw r112;
} catch (r109) {
r8 = r109;
c25690_3 = r109;
r30 = c25690_4;
if (r30 === 0) {
break;
}
}
} else {
try {
c25690_4 = 1;
c25690_4 = 0;
c3845_10.finishRequesting(c29654_0, c29654_1);
break L16;
} catch (r97) {
r8 = r97;
c25690_3 = r97;
r30 = c25690_4;
if (r30 === 0) {
break;
}
}
}
}
}
throw r8;
}
return void 0;
}
return void 0;
}
};
class DefaultDict {
_set = {};
constructor(a0) {
this._defaultValueFunc = a0;
}
get(a0) {
if (!this._set.hasOwnProperty(a0)) {
this._set[a0] = this._defaultValueFunc();
}
return this._set[a0];
}
delete(a0) {
delete this._set[a0];
}
hasNext() {
return !Module12.isEmpty(this._set);
}
next() {
return SnowflakeUtils.keys(this._set)[0];
}
}
class RequestQueue {
constructor() {
const prototype = new.target.prototype;
const r9 = {
__proto__: prototype
};
const _defaultValueFunc = $mk77687();
const requested = {
__proto__: DefaultDict.prototype
};
requested._set = {};
requested._defaultValueFunc = _defaultValueFunc;
r9.requested = requested;
return r9;
}
request(a0, a1) {
this.requested.get(a0).add(a1);
}
hasRequested(a0, a1) {
return this.requested.get(a0).has(a1);
}
finishRequesting(a0, a1) {
let c15436_0 = this.requested.get(a0);
a1.forEach((item) => c15436_0.delete(item));
c3845_10.compact(a0);
}
getRequested(a0) {
return this.requested.get(a0);
}
getNextBatch(a0, a1) {
return Array.from(this.requested.get(a0)).slice(0, a1);
}
hasNext() {
return this.requested.hasNext();
}
next() {
return this.requested.next();
}
compact(a0) {
if (this.requested.get(a0).size === 0) {
this.requested.delete(a0);
}
}
}
const r61 = {
__proto__: RequestQueue.prototype
};
const requested = {
__proto__: DefaultDict.prototype
};
requested._set = {};
requested._defaultValueFunc = $mk77687();
r61.requested = requested;
c3845_10 = r61;
env3845[11] = null;
export const BATCH_SIZE = 10;
export function useFirstForumPostMessage(a0) {
let r5 = arguments[1];
if (r5 === void 0) {
r5 = {};
}
const { enabled = true, allowArchived = false } = r5;
const stateFromStoresObject = useStateFromStoresObject([ForumPostMessagesStore], () => ForumPostMessagesStore.getMessage(a0.id));
const { loaded, firstMessage } = stateFromStoresObject;
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(a0.parent_id));
if (enabled && stateFromStores2 != null && (loaded ? !loaded : firstMessage == null)) {
const id2 = a0.id;
if (allowArchived) {
let env15440;
const r61 = [id2];
const r62 = env15440 = {
$parent: env3845
};
env15440[0] = stateFromStores2;
env15440[1] = false;
r61.forEach($mk77684(r62));
if (env15440[1] && env3845[11] == null) {
env3845[11] = setTimeout(loadForumPostData, 0);
}
} else {
const stateFromStores = stateFromStores2;
const id = id2;
if (!c3845_10.hasRequested(stateFromStores.id, id)) {
let env15439;
const r38 = (0, computeThreadIdsSnapshot)(stateFromStores.id);
const r41 = r38.findIndex((item) => item === id);
const r47 = r38.slice(r41, r41 + 5).filter((item) => !c3845_10.hasRequested(stateFromStores.id, item));
const r48 = env15439 = {
$parent: env3845
};
env15439[0] = stateFromStores;
env15439[1] = false;
r47.forEach($mk77684(r48));
if (env15439[1] && env3845[11] == null) {
env3845[11] = setTimeout(loadForumPostData, 0);
}
}
}
}
return {
loaded,
firstMessage: enabled ? firstMessage : null
};
}
export function useMostRecentForumMessage(a0, c15441_0) {
const stateFromStoresObject = useStateFromStoresObject([ForumPostRecentMessageStore], () => ForumPostRecentMessageStore.getMessageState(c15441_0.id));
return {
loaded: stateFromStoresObject.loaded,
mostRecentMessage: stateFromStoresObject.message
};
}
export function preloadForumThreads(a0) {
let env15442;
const r9 = (0, computeThreadIdsSnapshot)(a0.id).slice(0, 10);
const r12 = env15442 = {
$parent: env3845
};
env15442[0] = a0;
env15442[1] = false;
r9.forEach($mk77684(r12));
if (env15442[1] && env3845[11] == null) {
env3845[11] = setTimeout(loadForumPostData, 0);
}
}