Files
discord-decomp/sources/modules/message_request/hooks/useMessageRequestPreview.tsx
T
2026-07-28 01:06:53 +03:00

750 lines
28 KiB
TypeScript

/* Metro module 11942; source: modules/message_request/hooks/useMessageRequestPreview.tsx; dependencies: [5, 4814, 4605, 11943, 661, 566, 22, 507, 694, 2] */
import Module00005 from '../../../by-id/module-00005.js'; /* Metro dependency 5 */
import ReadStateStore from '../../../stores/ReadStateStore.tsx'; /* Metro dependency 4605 */
import MessageStore from '../../../stores/MessageStore.tsx'; /* Metro dependency 4814 */
import MessageRequestPreviewStore from '../MessageRequestPreviewStore.tsx'; /* Metro dependency 11943 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
function _fun91648(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91648, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:6, offset: 0x0206cc7b, size: 290 bytes, params: 8, frame: 20
const env0_0 = require;
const _arrayLikeToArray_91651 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const loadMessageRequestData = function() {
return _loadMessageRequestData.apply(this, arguments);
};
const loadMessageRequestDataHelper = function() {
return _loadMessageRequestDataHelper.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const Set = global.Set;
const set = new Set();
(FileImportTrackerModule).fileFinishedImporting('modules/message_request/hooks/useMessageRequestPreview.tsx');
exports.useMessageRequestPreview = useMessageRequestPreview;
function _createForOfIteratorHelperLoose_91649(a0, a1) { // fn#91649, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:161, offset: 0x0206cd9d, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun91650;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_91651(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_91651(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_91651(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun91650;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun91650() { // fn#91650, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:732, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function _loadMessageRequestData() { // fn#91653, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:1179, offset: 0x0206cf11, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun91655).apply(this, arguments);
function* _fun91655() { // fn#91655, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:1248, offset: 0x0206cf4e, size: 142 bytes, params: 1, frame: 16
var binding;
var binding2;
var property;
var value3;
var isEmpty;
var isEmpty2;
var value4;
var value5;
var value6;
var binding3;
var value7;
var isEmpty3;
var error;
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
try {
binding = env2_1;
} catch (error) {
env2_9 = null;
throw error;
}
try {
binding2 = env2_2;
} catch (error) {
env2_9 = null;
throw error;
}
try {
property = binding2[6];
} catch (error) {
env2_9 = null;
throw error;
}
try {
value3 = binding(property);
} catch (error) {
env2_9 = null;
throw error;
}
try {
isEmpty = value3.isEmpty;
} catch (error) {
env2_9 = null;
throw error;
}
try {
binding = env2_8;
} catch (error) {
env2_9 = null;
throw error;
}
try {
isEmpty2 = Reflect.apply(isEmpty, value3, [binding]);
} catch (error) {
env2_9 = null;
throw error;
}
if (isEmpty2) {
return undefined;
}
while (true) {
try {
binding = env2_14;
} catch (error) {
env2_9 = null;
throw error;
}
try {
value4 = binding();
} catch (error) {
env2_9 = null;
throw error;
}
yield value4;
try {
value5 = undefined;
value6 = false;
} catch (error) {
env2_9 = null;
throw error;
}
if (value6) {
break;
}
try {
binding = env2_1;
} catch (error) {
env2_9 = null;
throw error;
}
try {
binding3 = env2_2;
} catch (error) {
env2_9 = null;
throw error;
}
try {
property = binding3[6];
} catch (error) {
env2_9 = null;
throw error;
}
try {
value7 = binding(property);
} catch (error) {
env2_9 = null;
throw error;
}
try {
isEmpty = value7.isEmpty;
} catch (error) {
env2_9 = null;
throw error;
}
try {
binding = env2_8;
} catch (error) {
env2_9 = null;
throw error;
}
try {
isEmpty3 = Reflect.apply(isEmpty, value7, [binding]);
} catch (error) {
env2_9 = null;
throw error;
}
if (isEmpty3) {
env2_9 = null;
return undefined;
}
}
return value5;
}
}
function _loadMessageRequestDataHelper() { // fn#91657, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:1468, offset: 0x0206cfdc, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun91659).apply(this, arguments);
function* _fun91659() { // fn#91659, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:1549, offset: 0x0206d019, size: 476 bytes, params: 1, frame: 20
var r5;
var value;
var value2;
var Array;
var from;
var value3;
var slice;
var value4;
var binding;
var binding2;
var property;
var value5;
var HTTP;
var get;
var object;
var MESSAGE_REQUESTS_SUPPLEMENTAL_DATA;
var object2;
var value6;
var value7;
var value8;
var binding3;
var value9;
var dispatch;
var body;
var value10;
var value11;
var done;
var value12;
var value13;
var error;
var binding4;
var value14;
var value15;
var value16;
var value17;
var value18;
var value21;
var value22;
exceptionLanding57: while (true) {
value = undefined;
value2 = false;
if (value2) {
return value;
}
Array = global.Array;
from = Array.from;
value = environment.__proto__.__proto__;
value3 = Reflect.apply(from, Array, [env2_8]);
slice = value3.slice;
value4 = Reflect.apply(slice, value3, [0, 25]);
reducibleJoin3: while (true) {
reduciblePort54: while (true) {
exceptionLanding41: while (true) {
try {
try {
binding = env2_0;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
break reducibleJoin3;
}
try {
binding = env2_1;
} catch (error) {
break exceptionLanding57;
}
try {
binding4 = env2_2;
} catch (error) {
break exceptionLanding57;
}
try {
property = binding4[8];
} catch (error) {
break exceptionLanding57;
}
try {
value14 = binding(property);
} catch (error) {
break exceptionLanding57;
}
try {
dispatch = value14.dispatch;
} catch (error) {
break exceptionLanding57;
}
try {
object = {};
} catch (error) {
break exceptionLanding57;
}
try {
object.type = 'LOAD_MESSAGE_REQUESTS_SUPPLEMENTAL_DATA_ERROR';
} catch (error) {
break exceptionLanding57;
}
try {
object.requestedChannelIds = value4;
} catch (error) {
break exceptionLanding57;
}
try {
Reflect.apply(dispatch, value14, [object]);
} catch (error) {
break exceptionLanding57;
}
break reduciblePort54;
}
value15 = env2_10(value4);
value16 = value15();
done = value16.done;
if (!done) {
r5 = value16;
reducibleLoop55: while (true) {
value17 = r5.value;
binding = env2_8;
binding.delete(value17);
value18 = value15();
done = value18.done;
if (done) {
break reducibleLoop55;
}
r5 = value18;
continue reducibleLoop55;
}
}
return undefined;
}
try {
try {
binding2 = env2_2;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
property = binding2[7];
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
value5 = binding(property);
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
HTTP = value5.HTTP;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
get = HTTP.get;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object = {};
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
binding = env2_7;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
MESSAGE_REQUESTS_SUPPLEMENTAL_DATA = binding.MESSAGE_REQUESTS_SUPPLEMENTAL_DATA;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.url = MESSAGE_REQUESTS_SUPPLEMENTAL_DATA;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object2 = {};
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object2.channel_ids = value4;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.query = object2;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.rejectWithError = true;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
value6 = Reflect.apply(get, HTTP, [object]);
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
yield value6;
try {
try {
value7 = undefined;
value8 = false;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
if (value8) {
value10 = env2_10(value4);
value11 = value10();
done = value11.done;
if (!done) {
r5 = value11;
reducibleLoop39: while (true) {
value12 = r5.value;
binding = env2_8;
binding.delete(value12);
value13 = value10();
done = value13.done;
if (done) {
break reducibleLoop39;
}
r5 = value13;
continue reducibleLoop39;
}
}
return value7;
}
try {
try {
binding = env2_1;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
binding3 = env2_2;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
property = binding3[8];
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
value9 = binding(property);
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
dispatch = value9.dispatch;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object = {};
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.type = 'LOAD_MESSAGE_REQUESTS_SUPPLEMENTAL_DATA_SUCCESS';
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.requestedChannelIds = value4;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
body = value7.body;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
object.supplementalData = body;
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
try {
try {
Reflect.apply(dispatch, value9, [object]);
} catch (error) {
break exceptionLanding41;
}
} catch (error) {
break exceptionLanding57;
}
value15 = env2_10(value4);
value16 = value15();
done = value16.done;
if (!done) {
r5 = value16;
reducibleLoop55: while (true) {
value17 = r5.value;
binding = env2_8;
binding.delete(value17);
value18 = value15();
done = value18.done;
if (done) {
break reducibleLoop55;
}
r5 = value18;
continue reducibleLoop55;
}
}
return undefined;
}
const value19 = env2_10(value4);
const value20 = value19();
done = value20.done;
if (!done) {
r5 = value20;
reducibleLoop58: while (true) {
value21 = r5.value;
binding = env2_8;
binding.delete(value21);
value22 = value19();
done = value22.done;
if (done) {
break reducibleLoop58;
}
r5 = value22;
continue reducibleLoop58;
}
}
throw error;
}
}
function useMessageRequestPreview({id}) { // fn#91660, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:2183, offset: 0x0206d1f5, size: 264 bytes, params: 2, frame: 24
const value = a1;
let enabled = (value !== undefined ? value : {}).enabled;
enabled = enabled === undefined || enabled;
const useStateFromStoresObject = FluxModule.useStateFromStoresObject;
const messageRequestPreviewStoreBinding = MessageRequestPreviewStore;
const {loaded, message, error} = Reflect.apply(useStateFromStoresObject, FluxModule,
[[messageRequestPreviewStoreBinding, MessageStore, ReadStateStore], _fun91661, [id]]);
if (enabled && !loaded && message == null && FluxModule.useStateFromStores([messageRequestPreviewStoreBinding],
function() {
return MessageRequestPreviewStore.shouldLoadMessageRequestPreview(id);
}, [id])) {
env0_8.add(id);
if (env0_9 == null) {
env0_9 = global.setTimeout(loadMessageRequestData, 0);
}
}
return {loaded: loaded, error: error, message: message};
function _fun91661() { // fn#91661, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12128:2292, offset: 0x0206d2fd, size: 103 bytes, params: 1, frame: 15
let value = environment.__proto__;
const readStateStoreBinding = ReadStateStore;
const lastMessageId = readStateStoreBinding.lastMessageId;
const idBinding = id;
const value3 = Reflect.apply(lastMessageId, readStateStoreBinding, [idBinding]);
const messageRequestPreview = MessageRequestPreviewStore.getMessageRequestPreview(idBinding);
if (messageRequestPreview.message == null) {
if (value3 == null) {
return messageRequestPreview;
}
value = MessageStore.getMessage(id, value3);
if (value != null) {
return {'loaded': true, 'error': false, message: value};
}
}
return messageRequestPreview;
}
}
}
global.__d(_fun91648, 11942, [5, 4814, 4605, 11943, 661, 566, 22, 507, 694,
2]) /* metro module 11942, dependencies: [5, 4814, 4605, 11943, 661, 566, 22, 507, 694, 2] */;