Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4759.js (118.4 MB)
423 lines
12 KiB
TypeScript
423 lines
12 KiB
TypeScript
// Module ID: 7318
|
|
// Function ID: 7319
|
|
// Name: ForumPostDataLoader
|
|
// Dependencies: [5, 1957, 7319, 7291, 7322, 1074, 12, 11, 504, 1272, 573, 2]
|
|
// Exports: preloadForumThreads, useFirstForumPostMessage, useMostRecentForumMessage
|
|
|
|
// Module 7318 (ForumPostDataLoader)
|
|
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
|
|
import _modDef12 from "module_12" /* 12 */;
|
|
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
|
|
import ChannelStore from "ChannelStore" /* 1957 */;
|
|
import ForumPostMessagesStore from "ForumPostMessagesStore" /* 7291 */;
|
|
import ForumPostRecentMessageStore from "ForumPostRecentMessageStore" /* 7322 */;
|
|
|
|
const require = globalThis.__r;
|
|
|
|
const require = fn;
|
|
function loadForumPostData() {
|
|
const self = this;
|
|
const apply = closure_13.apply;
|
|
if (typeof apply === "unknown") {
|
|
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
|
|
} else {
|
|
applyArgumentsResult = apply(self, arguments);
|
|
}
|
|
return applyArgumentsResult;
|
|
}
|
|
let closure_13 = async function _loadForumPostData(arg0, value) {
|
|
if (c4 === 2) {
|
|
c4 = 3;
|
|
throw new TypeError("Generator functions may not be called on executing generators");
|
|
} else if (tmp6 === 3) {
|
|
if (arg0 === 1) {
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
const obj2 = { value, done: true };
|
|
return obj2;
|
|
} else {
|
|
return { value: "HermesInternal", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
c4 = 2;
|
|
if (0 === c1) {
|
|
if (arg0 === 1) {
|
|
c4 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c4 = 3;
|
|
obj3 = { value, done: true };
|
|
return obj3;
|
|
} else {
|
|
closure_0 = tmp3;
|
|
c3 = 1;
|
|
if (closure_2_10.hasNext()) {
|
|
c1 = 2;
|
|
c4 = 1;
|
|
const obj4 = { value: closure_128_14(closure_128_10.next()), done: false };
|
|
return obj4;
|
|
} else {
|
|
c3 = 0;
|
|
closure_128_11 = null;
|
|
c4 = 3;
|
|
}
|
|
}
|
|
} else if (1 === tmp7) {
|
|
c3 = 0;
|
|
closure_128_11 = null;
|
|
throw closure_2;
|
|
} else if (arg0 === 1) {
|
|
c4 = 3;
|
|
throw value;
|
|
}
|
|
c3 = 0;
|
|
closure_128_11 = null;
|
|
c4 = 3;
|
|
const obj = { value, done: true };
|
|
return obj;
|
|
} catch (tmp19) {
|
|
closure_2 = tmp19;
|
|
if (tmp4 === c3) {
|
|
c4 = tmp2;
|
|
throw tmp19;
|
|
} else {
|
|
c1 = tmp;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
function loadForumPostDataForChannelId() {
|
|
const self = this;
|
|
const apply = closure_15.apply;
|
|
if (typeof apply === "unknown") {
|
|
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
|
|
} else {
|
|
applyArgumentsResult = apply(self, arguments);
|
|
}
|
|
return applyArgumentsResult;
|
|
}
|
|
let closure_15 = async function _loadForumPostDataForChannelId(arg0, value) {
|
|
if (c6 === 2) {
|
|
c6 = 3;
|
|
throw new TypeError("Generator functions may not be called on executing generators");
|
|
} else if (tmp8 === 3) {
|
|
if (arg0 === 1) {
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
const obj2 = { value, done: true };
|
|
return obj2;
|
|
} else {
|
|
return { value: "HermesInternal", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
c6 = 2;
|
|
if (0 === c5) {
|
|
if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c6 = 3;
|
|
obj3 = { value, done: true };
|
|
return obj3;
|
|
} else {
|
|
closure_2 = tmp4;
|
|
closure_1 = tmp6;
|
|
closure_129_0 = closure_0;
|
|
closure_129_1 = undefined;
|
|
closure_129_2 = undefined;
|
|
let threads;
|
|
const nextBatch = closure_2_10.getNextBatch(closure_0, 10);
|
|
closure_129_1 = nextBatch;
|
|
c4 = 2;
|
|
if (0 === nextBatch.length) {
|
|
c4 = 0;
|
|
closure_2_10.finishRequesting(tmp54, nextBatch);
|
|
c6 = 3;
|
|
return { value: "HermesInternal", done: null };
|
|
} else {
|
|
channel = channel.getChannel(tmp54);
|
|
let guild_id;
|
|
if (channel != null) {
|
|
guild_id = channel.guild_id;
|
|
}
|
|
closure_129_2 = guild_id;
|
|
if (null == guild_id) {
|
|
c4 = 0;
|
|
closure_2_10.finishRequesting(tmp54, nextBatch);
|
|
c6 = 3;
|
|
return { value: "HermesInternal", done: null };
|
|
} else {
|
|
const HTTP = require("HTTPUtils").HTTP;
|
|
const request = { url: Endpoints.FORUM_POSTS(tmp54), body: null, rejectWithError: true };
|
|
const obj4 = { thread_ids: nextBatch };
|
|
request.body = obj4;
|
|
c5 = 3;
|
|
c6 = 1;
|
|
const obj5 = { value: HTTP.post(request), done: false };
|
|
return obj5;
|
|
}
|
|
}
|
|
}
|
|
} else if (1 === tmp9) {
|
|
c4 = 0;
|
|
closure_130_10.finishRequesting(closure_129_0, closure_129_1);
|
|
throw closure_3;
|
|
} else {
|
|
if (2 === tmp9) {
|
|
c4 = 1;
|
|
c4 = 0;
|
|
closure_130_10.finishRequesting(closure_129_0, closure_129_1);
|
|
c6 = 3;
|
|
} else if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw value;
|
|
} else if (arg0 !== 2) {
|
|
threads = value.body.threads;
|
|
const obj6 = { type: "LOAD_FORUM_POSTS", guildId: closure_129_2, threads };
|
|
closure_130_1(closure_130_2[10]).dispatch(obj6);
|
|
c4 = 1;
|
|
const obj = closure_130_1(closure_130_2[10]);
|
|
}
|
|
c4 = 0;
|
|
closure_130_10.finishRequesting(closure_129_0, closure_129_1);
|
|
c6 = 3;
|
|
const obj7 = { value, done: true };
|
|
return obj7;
|
|
}
|
|
} catch (tmp46) {
|
|
closure_3 = tmp46;
|
|
if (tmp5 === c4) {
|
|
c6 = tmp3;
|
|
throw tmp46;
|
|
} else if (tmp2 === tmp48) {
|
|
c5 = tmp2;
|
|
} else {
|
|
c5 = tmp;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const computeThreadIdsSnapshot = fn(7319).computeThreadIdsSnapshot;
|
|
const Endpoints = fn(1074).Endpoints;
|
|
class DefaultDict {
|
|
constructor(arg0) {
|
|
obj = Object.create(new.target.prototype);
|
|
obj._set = {};
|
|
obj._defaultValueFunc = global;
|
|
return obj;
|
|
}
|
|
}
|
|
const prototype = DefaultDict.prototype;
|
|
prototype["get"] = function get(key10009) {
|
|
const self = this;
|
|
const _set = this._set;
|
|
if (!_set.hasOwnProperty(key10009)) {
|
|
self._set[key10009] = self._defaultValueFunc();
|
|
}
|
|
return self._set[key10009];
|
|
};
|
|
prototype["delete"] = function delete(arg0) {
|
|
delete tmp2[tmp];
|
|
};
|
|
prototype["hasNext"] = function hasNext() {
|
|
return !_modDef12.isEmpty(this._set);
|
|
};
|
|
prototype["next"] = function next() {
|
|
return SnowflakeUtilsDefault.keys(this._set)[0];
|
|
};
|
|
class RequestQueue {
|
|
constructor() {
|
|
if (typeof DefaultDict === "function") {
|
|
obj = Object.create(new.target.prototype);
|
|
fn = () => new Set();
|
|
obj1 = Object.create(tmp.prototype);
|
|
obj1._set = {};
|
|
obj1._defaultValueFunc = fn;
|
|
obj.requested = obj1;
|
|
return obj;
|
|
} else {
|
|
str = "Trying to call a non-function";
|
|
throw new TypeError("Trying to call a non-function");
|
|
}
|
|
}
|
|
}
|
|
const prototype2 = RequestQueue.prototype;
|
|
prototype2["request"] = function request(arg0, arg1) {
|
|
const requested = this.requested;
|
|
value = requested.get(arg0);
|
|
value.add(arg1);
|
|
};
|
|
prototype2["hasRequested"] = function hasRequested(id, id2) {
|
|
const requested = this.requested;
|
|
value = requested.get(id);
|
|
return value.has(id2);
|
|
};
|
|
prototype2["finishRequesting"] = function finishRequesting(arg0, nextBatch) {
|
|
const requested = this.requested;
|
|
requested.get(arg0);
|
|
const item = nextBatch.forEach((item) => set.delete(item));
|
|
obj3.compact(arg0);
|
|
};
|
|
prototype2["getRequested"] = function getRequested(arg0) {
|
|
const requested = this.requested;
|
|
return requested.get(arg0);
|
|
};
|
|
prototype2["getNextBatch"] = function getNextBatch(arg0, arg1) {
|
|
const requested = this.requested;
|
|
return Array.from(requested.get(arg0)).slice(0, arg1);
|
|
};
|
|
prototype2["hasNext"] = function hasNext() {
|
|
const requested = this.requested;
|
|
return requested.hasNext();
|
|
};
|
|
prototype2["next"] = function next() {
|
|
return this.requested.next();
|
|
};
|
|
prototype2["compact"] = function compact(arg0) {
|
|
const requested = this.requested;
|
|
if (0 === requested.get(arg0).size) {
|
|
const requested2 = this.requested;
|
|
requested2.delete(arg0);
|
|
}
|
|
};
|
|
let obj3 = Object.create(RequestQueue.prototype);
|
|
let obj4 = Object.create(DefaultDict.prototype);
|
|
obj4._set = {};
|
|
obj4._defaultValueFunc = () => new Set();
|
|
obj3.requested = obj4;
|
|
let c11 = null;
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/forums/ForumPostDataLoader.tsx");
|
|
|
|
export const BATCH_SIZE = 10;
|
|
export const useFirstForumPostMessage = function useFirstForumPostMessage(stateFromStores, arg1) {
|
|
_require = stateFromStores;
|
|
let obj = arg1;
|
|
if (arg1 === undefined) {
|
|
obj = {};
|
|
}
|
|
let flag = obj.enabled;
|
|
if (flag === undefined) {
|
|
flag = true;
|
|
}
|
|
let flag2 = obj.allowArchived;
|
|
if (flag2 === undefined) {
|
|
flag2 = false;
|
|
}
|
|
const items = [ForumPostMessagesStore];
|
|
const stateFromStoresObject = require("initialize").useStateFromStoresObject(items, () => ForumPostMessagesStore.getMessage(stateFromStores.id));
|
|
({ loaded, firstMessage } = stateFromStoresObject);
|
|
obj3 = require("initialize");
|
|
const items1 = [ChannelStore];
|
|
stateFromStores = obj3.useStateFromStores(items1, () => ChannelStore.getChannel(stateFromStores.parent_id));
|
|
let tmp3 = flag;
|
|
if (flag) {
|
|
tmp3 = null != stateFromStores;
|
|
}
|
|
if (tmp3) {
|
|
let tmp5 = !loaded;
|
|
if (!loaded) {
|
|
tmp5 = null == firstMessage;
|
|
}
|
|
tmp3 = tmp5;
|
|
}
|
|
if (tmp3) {
|
|
const id = stateFromStores.id;
|
|
if (flag2) {
|
|
const items2 = [id];
|
|
closure_131_0 = stateFromStores;
|
|
closure_131_1 = false;
|
|
const item = items2.forEach((item) => {
|
|
const message = ForumPostMessagesStore.getMessage(item);
|
|
const loaded = message.loaded;
|
|
let tmp3 = !loaded;
|
|
if (!loaded) {
|
|
tmp3 = null == tmp2;
|
|
}
|
|
if (tmp3) {
|
|
obj3.request(id.id, item);
|
|
c1 = true;
|
|
}
|
|
});
|
|
let tmp17 = closure_131_1;
|
|
if (closure_131_1) {
|
|
tmp17 = null == timeout;
|
|
}
|
|
if (tmp17) {
|
|
const _setTimeout2 = setTimeout;
|
|
timeout = setTimeout(loadForumPostData, 0);
|
|
}
|
|
} else {
|
|
closure_129_0 = stateFromStores;
|
|
closure_129_1 = id;
|
|
if (!obj3.hasRequested(stateFromStores.id, id)) {
|
|
const arr3 = computeThreadIdsSnapshot(stateFromStores.id);
|
|
const findIndexResult = arr3.findIndex((item) => item === importDefault);
|
|
const substr = arr3.slice(findIndexResult, findIndexResult + 5);
|
|
const found = substr.filter((item) => !obj3.hasRequested(stateFromStores.id, item));
|
|
closure_130_0 = stateFromStores;
|
|
closure_130_1 = false;
|
|
const item1 = found.forEach((item) => {
|
|
const message = ForumPostMessagesStore.getMessage(item);
|
|
const loaded = message.loaded;
|
|
let tmp3 = !loaded;
|
|
if (!loaded) {
|
|
tmp3 = null == tmp2;
|
|
}
|
|
if (tmp3) {
|
|
obj3.request(id.id, item);
|
|
c1 = true;
|
|
}
|
|
});
|
|
let tmp11 = closure_130_1;
|
|
if (closure_130_1) {
|
|
tmp11 = null == timeout;
|
|
}
|
|
if (tmp11) {
|
|
const _setTimeout = setTimeout;
|
|
timeout = setTimeout(loadForumPostData, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const obj4 = { loaded, firstMessage: null };
|
|
let tmp22 = null;
|
|
if (flag) {
|
|
tmp22 = firstMessage;
|
|
}
|
|
obj4.firstMessage = tmp22;
|
|
return obj4;
|
|
};
|
|
export const useMostRecentForumMessage = function useMostRecentForumMessage(arg0, arg1) {
|
|
_require = arg1;
|
|
const items = [ForumPostRecentMessageStore];
|
|
const stateFromStoresObject = require("initialize").useStateFromStoresObject(items, () => ForumPostRecentMessageStore.getMessageState(id.id));
|
|
return { loaded: stateFromStoresObject.loaded, mostRecentMessage: stateFromStoresObject.message };
|
|
};
|
|
export const preloadForumThreads = function preloadForumThreads(channel) {
|
|
const substr = computeThreadIdsSnapshot(channel.id).slice(0, 10);
|
|
const id = channel;
|
|
c1 = false;
|
|
const item = substr.forEach((item) => {
|
|
const message = ForumPostMessagesStore.getMessage(item);
|
|
const loaded = message.loaded;
|
|
let tmp3 = !loaded;
|
|
if (!loaded) {
|
|
tmp3 = null == tmp2;
|
|
}
|
|
if (tmp3) {
|
|
obj3.request(id.id, item);
|
|
c1 = true;
|
|
}
|
|
});
|
|
let tmp2 = c1;
|
|
if (c1) {
|
|
tmp2 = null == timeout;
|
|
}
|
|
if (tmp2) {
|
|
const _setTimeout = setTimeout;
|
|
timeout = setTimeout(loadForumPostData, 0);
|
|
}
|
|
};
|