Files
discord-decomp/sources/modules/forums/ForumPostDataLoader.tsx
T
2026-07-27 16:20:00 +03:00

716 lines
24 KiB
TypeScript

/* Metro module 6896; source: modules/forums/ForumPostDataLoader.tsx; dependencies: [5, 6, 7, 1379, 6897, 6865, 6901, 661, 22, 21, 566, 507, 694, 2] */
function _fun54746(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#54746, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:6, offset: 0x0136d3e3, size: 370 bytes, params: 8, frame: 19
const env0_0 = require;
const _shouldRequestFirstMessage = function(a0, a1) {
return !a0 && a1 == null;
};
const loadForumPostData = function() {
return _loadForumPostData.apply(this, arguments);
};
const loadForumPostDataForChannelId = function() {
return _loadForumPostDataForChannelId.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(5) /* metro dependency 5 */;
const env0_4 = importDefault(6) /* metro dependency 6 */;
const env0_5 = importDefault(7) /* metro dependency 7 */;
const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */;
const env0_7 = (require(6897) /* metro dependency 6897: ForumActivePostStore */).computeThreadIdsSnapshot;
const forumPostMessagesStore = importDefault(6865) /* metro dependency 6865: ForumPostMessagesStore */;
const forumPostRecentMessageStore = importDefault(6901) /* metro dependency 6901: ForumPostRecentMessageStore */;
const env0_10 = (require(661) /* metro dependency 661: Constants */).Endpoints;
const env0_11 = _fun54758();
let value = _fun54764();
value = new value();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/forums/ForumPostDataLoader.tsx');
exports.useFirstForumPostMessage = useFirstForumPostMessage;
exports.useMostRecentForumMessage = useMostRecentForumMessage;
exports.preloadForumThreads = preloadForumThreads;
}
function loadMultipleForumPostData(a0, a1) { // fn#54748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:1456, offset: 0x0136d569, size: 89 bytes, params: 3, frame: 14
const env0_0 = a0;
const env0_1 = false;
a1.forEach(_fun54749);
if (env0_1 && env0_13 == null) {
env0_13 = global.setTimeout(loadForumPostData, 0);
}
}
function _loadForumPostData() { // fn#54751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:1748, offset: 0x0136d616, size: 48 bytes, params: 1, frame: 14
return env0_3(_fun54753).apply(this, arguments);
}
function _loadForumPostDataForChannelId() { // fn#54755, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2030, offset: 0x0136d6bf, size: 48 bytes, params: 1, frame: 14
return env0_3(_fun54757).apply(this, arguments);
}
function _fun54758() { // fn#54758, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:215, offset: 0x0136d87c, size: 124 bytes, params: 1, frame: 15
return env0_5(DefaultDict, [{key: 'get', value: function(a0) {
if (!this._set.hasOwnProperty(a0)) {
this._set[a0] = this._defaultValueFunc();
}
return this._set[a0];
}}, {key: 'delete', value: function(a0) {
delete this._set[a0];
}}, {key: 'hasNext', value: value_54762}, {key: 'next', value: value_54763}]);
}
function _fun54764() { // fn#54764, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:639, offset: 0x0136d9d8, size: 220 bytes, params: 1, frame: 15
return env0_5(RequestQueue, [{key: 'request', value: function(a0, a1) {
this.requested.get(a0).add(a1);
}}, {key: 'hasRequested', value: function(a0, a1) {
return this.requested.get(a0).has(a1);
}}, {key: 'finishRequesting', value: value_54769}, {key: 'getRequested', value: function(a0) {
return this.requested.get(a0);
}}, {key: 'getNextBatch', value: function(a0, a1) {
var Array = global.Array;
return Array.from(this.requested.get(a0)).slice(0, a1);
}}, {key: 'hasNext', value: function() {
return this.requested.hasNext();
}}, {key: 'next', value: function() {
return this.requested.next();
}}, {key: 'compact', value: function(a0) {
var property = this.requested;
property = property.get(a0).size;
if (property === 0) {
this.requested.delete(a0);
}
}}]);
}
function useFirstForumPostMessage(a0) { // fn#54776, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2598, offset: 0x0136dc34, size: 238 bytes, params: 2, frame: 22
const value = a1;
const env0_0 = a0;
const r1 = value !== undefined ? value : {};
let enabled = r1.enabled;
enabled = enabled === undefined || enabled;
let allowArchived = r1.allowArchived;
allowArchived = !(allowArchived === undefined) && allowArchived;
const {loaded,
firstMessage} = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ForumPostMessagesStore],
_fun54777);
const channel = (require(566) /* metro dependency 566: flux */).useStateFromStores([ChannelStore], _fun54778);
if (enabled && channel != null && _shouldRequestFirstMessage(loaded, firstMessage)) {
if (allowArchived) {
loadMultipleForumPostData(channel, [a0.id]);
} else {
preloadForumPostDataFrom(channel, a0.id);
}
}
return {loaded: loaded, firstMessage: enabled ? firstMessage : null};
}
function useMostRecentForumMessage(a0, a1) { // fn#54782, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:3198, offset: 0x0136de13, size: 88 bytes, params: 3, frame: 14
const env0_0 = a1;
const value = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ForumPostRecentMessageStore],
function() {
return ForumPostRecentMessageStore.getMessageState(require.id);
});
return {loaded: value.loaded, mostRecentMessage: value.message};
}
function preloadForumThreads(a0) { // fn#54784, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:3389, offset: 0x0136de8b, size: 50 bytes, params: 2, frame: 16
const loadMultipleForumPostDataBinding = loadMultipleForumPostData;
const threadIdsSnapshot = computeThreadIdsSnapshot(a0.id);
loadMultipleForumPostDataBinding(a0, threadIdsSnapshot.slice(0, 10));
}
function _fun54749(a0) { // fn#54749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:1516, offset: 0x0136d5c2, size: 84 bytes, params: 2, frame: 15
var binding;
const message = ForumPostMessagesStore.getMessage(a0);
if (_shouldRequestFirstMessage(message.loaded, message.firstMessage)) {
binding = env1_12;
binding.request(env0_0.id, a0);
}
}
function* _fun54753() { // fn#54753, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:1807, offset: 0x0136d64f, size: 112 bytes, params: 1, frame: 14
var binding;
var hasNext;
var hasNext2;
var binding2;
var next;
var value3;
var value4;
var value5;
var value6;
var hasNext3;
var error;
if (true) {
value = environment.__proto__.__proto__;
try {
binding = env2_12;
} catch (error) {
env2_13 = null;
throw error;
}
try {
hasNext = binding.hasNext;
} catch (error) {
env2_13 = null;
throw error;
}
try {
hasNext2 = Reflect.apply(hasNext, binding, []);
} catch (error) {
env2_13 = null;
throw error;
}
if (hasNext2) {
while (true) {
try {
binding = env2_18;
} catch (error) {
env2_13 = null;
throw error;
}
try {
binding2 = env2_12;
} catch (error) {
env2_13 = null;
throw error;
}
try {
next = binding2.next;
} catch (error) {
env2_13 = null;
throw error;
}
try {
value3 = Reflect.apply(next, binding2, []);
} catch (error) {
env2_13 = null;
throw error;
}
try {
value4 = binding(value3);
} catch (error) {
env2_13 = null;
throw error;
}
yield value4;
try {
value5 = undefined;
value6 = false;
} catch (error) {
env2_13 = null;
throw error;
}
if (value6) {
env2_13 = null;
return value5;
}
try {
binding = env2_12;
} catch (error) {
env2_13 = null;
throw error;
}
try {
hasNext = binding.hasNext;
} catch (error) {
env2_13 = null;
throw error;
}
try {
hasNext3 = Reflect.apply(hasNext, binding, []);
} catch (error) {
env2_13 = null;
throw error;
}
if (hasNext3) {
continue;
}
break;
}
}
}
}
function* _fun54757(a0) { // fn#54757, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2113, offset: 0x0136d6f8, size: 388 bytes, params: 2, frame: 21
var guild_id;
var value;
var value2;
var value3;
var binding;
var getNextBatch;
var value4;
var length;
var value5;
var getChannel;
var value6;
var value7;
var value8;
var binding2;
var property;
var value9;
var HTTP;
var post;
var object3;
var FORUM_POSTS;
var value10;
var object4;
var value11;
var value12;
var value13;
var body;
var threads;
var binding3;
var value14;
var dispatch;
var finishRequesting;
var error;
exceptionLanding59: while (true) {
value = undefined;
value2 = false;
if (value2) {
return value;
}
value = undefined;
value3 = environment.__proto__.__proto__;
binding = env2_12;
getNextBatch = binding.getNextBatch;
value4 = Reflect.apply(getNextBatch, binding, [a0, 10]);
reducibleJoin4: while (true) {
reduciblePort58: while (true) {
exceptionLanding57: while (true) {
try {
try {
length = value4.length;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
break reducibleJoin4;
}
break reduciblePort58;
}
binding = env2_12;
finishRequesting = binding.finishRequesting;
Reflect.apply(finishRequesting, binding, [a0, value4]);
return value;
}
try {
try {
value5 = length === 0;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
if (value5) {
binding = env2_12;
binding.finishRequesting(a0, value4);
return value;
}
try {
try {
binding = env2_6;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
getChannel = binding.getChannel;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value6 = Reflect.apply(getChannel, binding, [a0]);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value7 = value6 == null;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
reducibleJoin14: while (true) {
if (value7) {
guild_id = value;
break reducibleJoin14;
}
try {
try {
guild_id = value6.guild_id;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
break reducibleJoin14;
}
try {
try {
value8 = guild_id == null;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
if (value8) {
binding = env2_12;
binding.finishRequesting(a0, value4);
return value;
}
try {
try {
binding = env2_0;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
binding2 = env2_2;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
property = binding2[11];
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value9 = binding(property);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
HTTP = value9.HTTP;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
post = HTTP.post;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3 = {};
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
binding = env2_10;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
FORUM_POSTS = binding.FORUM_POSTS;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value10 = Reflect.apply(FORUM_POSTS, binding, [a0]);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.url = value10;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object4 = {};
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object4.thread_ids = value4;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.body = object4;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.rejectWithError = true;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value11 = Reflect.apply(post, HTTP, [object3]);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
yield value11;
try {
try {
value12 = undefined;
value13 = false;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
if (value13) {
binding = env2_12;
binding.finishRequesting(a0, value4);
return value12;
}
try {
try {
body = value12.body;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
threads = body.threads;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
binding = env2_1;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
binding3 = env2_2;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
property = binding3[12];
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
value14 = binding(property);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
dispatch = value14.dispatch;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3 = {};
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.type = 'LOAD_FORUM_POSTS';
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.guildId = guild_id;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
object3.threads = threads;
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
try {
try {
Reflect.apply(dispatch, value14, [object3]);
} catch (error) {
break exceptionLanding57;
}
} catch (error) {
break exceptionLanding59;
}
binding = env2_12;
finishRequesting = binding.finishRequesting;
Reflect.apply(finishRequesting, binding, [a0, value4]);
return value;
}
env2_12.finishRequesting(a0, value4);
throw error;
}
function DefaultDict(a0) { // fn#54759, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:236, offset: 0x0136d8f8, size: 44 bytes, params: 2, frame: 13
env1_4(this, DefaultDict);
this._set = {};
this._defaultValueFunc = a0;
}
function value_54762() { // fn#54762, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:516, offset: 0x0136d972, size: 50 bytes, params: 1, frame: 11
let value = environment.__proto__;
value = importDefault(22) /* metro dependency 22 */;
return !value.isEmpty(this._set);
}
function value_54763() { // fn#54763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:581, offset: 0x0136d9a4, size: 52 bytes, params: 1, frame: 11
let value = environment.__proto__;
value = Reflect.apply((importDefault(21) /* metro dependency 21: SnowflakeUtils */).keys, value, [this._set]);
return value[0];
}
function RequestQueue() { // fn#54765, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:660, offset: 0x0136dab4, size: 64 bytes, params: 1, frame: 14
var environment;
let value = environment.__proto__;
env1_4(this, RequestQueue);
this.requested = new env1_11(function() {
var Set = global.Set;
var value = Object.create(Set.prototype, {constructor: {value: Set}});
var value2 = new Set();
return value2 instanceof Object ? value2 : value;
});
}
function value_54769(a0, a1) { // fn#54769, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:918, offset: 0x0136db40, size: 68 bytes, params: 3, frame: 13
const env0_0 = this.requested.get(a0);
a1.forEach(_fun54770);
env1_12.compact(a0);
}
function _fun54777() { // fn#54777, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2717, offset: 0x0136dd22, size: 32 bytes, params: 1, frame: 11
return ForumPostMessagesStore.getMessage(env0_0.id);
}
function _fun54778() { // fn#54778, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2805, offset: 0x0136dd42, size: 32 bytes, params: 1, frame: 11
return ChannelStore.getChannel(env0_0.parent_id);
}
function preloadForumPostDataFrom(a0, a1) { // fn#54779, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:2928, owner: useFirstForumPostMessage.preloadForumPostDataFrom, offset: 0x0136dd62, size: 122 bytes, params: 3, frame: 17
const env0_0 = a0;
const env0_1 = a1;
const binding = env1_12;
if (!binding.hasRequested(a0.id, a1)) {
var threadIdsSnapshot = computeThreadIdsSnapshot(a0.id);
var index = threadIdsSnapshot.findIndex(function(a0) {
return a0 === require;
});
loadMultipleForumPostData(a0, threadIdsSnapshot.slice(index, index + 5).filter(_fun54781));
}
}
function _fun54781(a0) { // fn#54781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7074:3065, offset: 0x0136ddec, size: 39 bytes, params: 2, frame: 13
const binding = env2_12;
return !binding.hasRequested(env0_0.id, a0);
}