Files
discord-decomp/sources/modules/messages/native/handlers/handleMessagesTapImage.tsx
T
2026-07-28 01:06:53 +03:00

476 lines
22 KiB
TypeScript

/* Metro module 11348; source: modules/messages/native/handlers/handleMessagesTapImage.tsx; dependencies: [4833, 3793, 1878, 661, 9548, 9877, 679, 9546, 3853, 4633, 9544, 4805, 6647, 2] */
import UserStore from '../../../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import RelationshipStore from '../../../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */
import ReferencedMessageStore from '../../../replies/ReferencedMessageStore.tsx'; /* Metro dependency 4833 */
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../../../Constants.tsx'; /* Metro dependency 661 */
import * as MessageReferenceTypesModule from '../../../../external/discord_common/js/shared/shared-constants/MessageReferenceTypes.tsx'; /* Metro dependency 679 */
function _fun86899(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#86899, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11534:6, offset: 0x01fa6531, size: 172 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/messages/native/handlers/handleMessagesTapImage.tsx');
exports.handleMessagesTapImage = handleMessagesTapImage;
function handleMessagesTapImage({tapImageData, allowWithinModal, message, messageChannel, selectedChannelId, showContextName}) { // fn#86900, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11534:275, offset: 0x01fa65dd, size: 1476 bytes, params: 2, frame: 42
var environment;
var r17;
var r16;
var r26;
var r23;
var components;
var r6;
var r7;
var value2;
var moduleValue;
var markPortalAlive;
var moduleValue2;
var messageReference;
var referencedMessageStoreBinding;
var getMessageByReference;
var message2;
var property;
var length;
var moduleValue3;
var extractMediaFromAttachment;
var guild_id;
var url;
var moduleValue4;
var value6;
var value7;
var moduleValue5;
var flattenSource;
var value8;
var accessoryType;
var mediaViewIndex;
var mediaIndex;
var value9;
var noCarousel;
var moduleValue6;
var setMediaSourcePortal;
var value10;
var object;
var moduleValue7;
var embeds;
var find;
var value11;
var moduleValue8;
var extractMediaSourcesFromComponent;
var moduleValue9;
var asComponentId;
var value12;
var sources;
var initialIndex;
var moduleValue10;
var moduleValue11;
var extractMediaSourcesFromEmbed;
var value13;
var binding;
var moduleValue12;
var some;
var value14;
var moduleValue13;
var openMediaModal;
var id;
var moduleValue14;
var computeChannelName;
var channelName;
var moduleValue15;
var getChannelIcon;
var value15;
var defaultImport;
var Error;
var concat;
const index = tapImageData.index;
const type2 = tapImageData.type;
const layout = tapImageData.layout;
const portal = tapImageData.portal;
const embedIndex = tapImageData.embedIndex;
const componentId = tapImageData.componentId;
const componentMediaIndex = tapImageData.componentMediaIndex;
const embedId = tapImageData.embedId;
const value = undefined;
reducibleJoin2: while (true) {
if (portal == null) {
break reducibleJoin2;
}
value2 = environment;
moduleValue = require(9548) /* metro dependency 9548: NativePortalView */;
markPortalAlive = moduleValue.markPortalAlive;
Reflect.apply(markPortalAlive, moduleValue, [portal]);
break reducibleJoin2;
}
if (allowWithinModal !== true) {
moduleValue2 = require(9877) /* metro dependency 9877: isAlertOrActionSheetOpen */;
reducibleJoin4: while (true) {
if (moduleValue2.isAlertOrActionSheetOpen(selectedChannelId)) {
return value;
}
break reducibleJoin4;
}
}
if (type2 !== 'attachment') {
reducibleJoin8: while (true) {
if (type2 === 'embed') {
break reducibleJoin8;
}
if (type2 === 'sticker') {
break reducibleJoin8;
}
if (type2 !== 'component') {
Error = global.Error;
concat = global.HermesInternal.concat;
throw new Error('Unsupported thumbnail type: ' + type2);
}
break reducibleJoin8;
}
}
let type = message.type;
const THREAD_STARTER_MESSAGE = MessageTypes.THREAD_STARTER_MESSAGE;
reducibleJoin11: while (true) {
if (type !== THREAD_STARTER_MESSAGE) {
r17 = message;
break reducibleJoin11;
}
messageReference = message.messageReference;
if (messageReference == null) {
r17 = message;
break reducibleJoin11;
}
referencedMessageStoreBinding = ReferencedMessageStore;
getMessageByReference = referencedMessageStoreBinding.getMessageByReference;
messageReference = message.messageReference;
message2 = Reflect.apply(getMessageByReference, referencedMessageStoreBinding, [messageReference]).message;
if (message2 == null) {
r17 = message;
break reducibleJoin11;
}
r17 = message2;
break reducibleJoin11;
}
messageReference = r17.messageReference;
reducibleJoin13: while (true) {
if (messageReference == null) {
type = value;
break reducibleJoin13;
}
type = messageReference.type;
break reducibleJoin13;
}
const MessageReferenceTypes = (MessageReferenceTypesModule).MessageReferenceTypes;
const FORWARD = MessageReferenceTypes.FORWARD;
if (type !== FORWARD) {
r16 = r17;
} else {
property = r17.messageSnapshots[0];
reducibleJoin16: while (true) {
if (property == null) {
message = value;
break reducibleJoin16;
}
message = property.message;
break reducibleJoin16;
}
reducibleJoin17: while (true) {
if (message == null) {
return value;
}
r16 = message;
break reducibleJoin17;
}
}
const value5 = r17.attachments.filter(_fun86901);
if (type2 === 'attachment') {
length = value5.length;
reducibleJoin22: while (true) {
if (index < length) {
property = value5[index];
moduleValue3 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
extractMediaFromAttachment = moduleValue3.extractMediaFromAttachment;
guild_id = messageChannel.guild_id;
if (Reflect.apply(extractMediaFromAttachment, moduleValue3, [property, r17, index, guild_id]) != null) {
break reducibleJoin22;
}
url = property.url;
if (url == null) {
break reducibleJoin22;
}
url = property.url;
if (url !== '') {
defaultImport = importDefault(3853) /* metro dependency 3853: Linking */;
defaultImport.openURL(property.url);
return value;
}
break reducibleJoin22;
}
break reducibleJoin22;
}
}
let env0_1 = -1;
if (type2 === 'embed') {
reducibleJoin24: while (true) {
if (embedIndex != null) {
embeds = r16.embeds;
property = embeds[index];
env0_1 = embedIndex;
moduleValue11 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
extractMediaSourcesFromEmbed = moduleValue11.extractMediaSourcesFromEmbed;
guild_id = messageChannel.guild_id;
value13 = Reflect.apply(extractMediaSourcesFromEmbed, moduleValue11, [r17, r16, property, index,
guild_id]);
binding = env0_1;
length = value13.length;
reducibleJoin51: while (true) {
if (binding < length) {
moduleValue12 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
setMediaSourcePortal = moduleValue12.setMediaSourcePortal;
Reflect.apply(setMediaSourcePortal, moduleValue12, [value13[env0_1], portal]);
r6 = value13;
break reducibleJoin51;
}
r6 = value13;
break reducibleJoin51;
}
some = r6.some;
value14 = Reflect.apply(some, r6, [_fun86904]);
reducibleJoin60: while (true) {
if (env0_1 === -1) {
break reducibleJoin60;
}
moduleValue13 = require(9544) /* metro dependency 9544: openMediaModal */;
openMediaModal = moduleValue13.openMediaModal;
object = {disableDownload: value14, initialSources: r6, initialIndex: env0_1,
originViewOrOriginLayout: layout,
analyticsSource: 'Channel'};
id = messageChannel.id;
object.channelId = id;
reducibleJoin54: while (true) {
if (showContextName) {
moduleValue14 = require(4805) /* metro dependency 4805: useChannelName */;
computeChannelName = moduleValue14.computeChannelName;
channelName = Reflect.apply(computeChannelName, moduleValue14, [messageChannel, UserStore,
RelationshipStore,
false]);
r7 = channelName;
break reducibleJoin54;
}
r7 = value;
break reducibleJoin54;
}
object.contextName = r7;
reducibleJoin56: while (true) {
if (showContextName) {
moduleValue15 = require(6647) /* metro dependency 6647: ChannelUtils */;
getChannelIcon = moduleValue15.getChannelIcon;
value15 = Reflect.apply(getChannelIcon, moduleValue15, [messageChannel]);
r7 = value15;
break reducibleJoin56;
}
r7 = value;
break reducibleJoin56;
}
object.contextIcon = r7;
Reflect.apply(openMediaModal, moduleValue13, [object]);
break reducibleJoin60;
}
return value;
}
break reducibleJoin24;
}
}
if (type2 === 'component') {
if (componentId == null) {
return null;
}
reducibleJoin42: while (true) {
reducibleJoin41: while (true) {
if (embedId == null) {
break reducibleJoin41;
}
if (embedId === '') {
break reducibleJoin41;
}
embeds = r16.embeds;
find = embeds.find;
value11 = Reflect.apply(find, embeds, [function({id}) {
return id === embedId;
}]);
reducibleJoin40: while (true) {
if (value11 == null) {
components = value;
break reducibleJoin40;
}
components = value11.components;
break reducibleJoin40;
}
break reducibleJoin42;
}
components = r16.components;
break reducibleJoin42;
}
reducibleJoin51: while (true) {
reducibleJoin47: while (true) {
if (components == null) {
break reducibleJoin47;
}
length = components.length;
if (length === 0) {
break reducibleJoin47;
}
moduleValue8 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
extractMediaSourcesFromComponent = moduleValue8.extractMediaSourcesFromComponent;
guild_id = messageChannel.guild_id;
moduleValue9 = require(4633) /* metro dependency 4633: InteractionComponentTypes */;
asComponentId = moduleValue9.asComponentId;
value12 = Reflect.apply(extractMediaSourcesFromComponent, moduleValue8, [r17, components, guild_id,
Reflect.apply(asComponentId, moduleValue9, [componentId]), componentMediaIndex]);
if (value12 == null) {
return value;
}
sources = value12.sources;
initialIndex = value12.initialIndex;
env0_1 = initialIndex;
moduleValue10 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
setMediaSourcePortal = moduleValue10.setMediaSourcePortal;
Reflect.apply(setMediaSourcePortal, moduleValue10, [sources[env0_1], portal]);
r6 = sources;
break reducibleJoin51;
}
return value;
}
} else {
moduleValue4 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
value6 = moduleValue4.extractMediaSourcesFromMessage(r17, r16, messageChannel.guild_id);
length = value6.length;
value7 = 0;
if (value7 < length) {
r26 = value7;
reducibleLoop26: while (true) {
moduleValue5 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
flattenSource = moduleValue5.flattenSource;
value8 = Reflect.apply(flattenSource, moduleValue5, [value6[r26]]);
if (value8 != null) {
accessoryType = value8.accessoryType;
reducibleJoin31: while (true) {
if (accessoryType !== type2) {
break reducibleJoin31;
}
mediaViewIndex = value8.mediaViewIndex;
reducibleJoin30: while (true) {
if (mediaViewIndex != null) {
r23 = mediaViewIndex;
break reducibleJoin30;
}
mediaIndex = value8.mediaIndex;
r23 = mediaIndex;
break reducibleJoin30;
}
if (r23 === index) {
noCarousel = value8.noCarousel;
if (noCarousel) {
property = value6[r26];
object = [property];
env0_1 = value7;
moduleValue7 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
setMediaSourcePortal = moduleValue7.setMediaSourcePortal;
Reflect.apply(setMediaSourcePortal, moduleValue7, [object[value7], portal]);
r6 = object;
} else {
env0_1 = r26;
moduleValue6 = require(9546) /* metro dependency 9546: MediaSourceUtil */;
setMediaSourcePortal = moduleValue6.setMediaSourcePortal;
Reflect.apply(setMediaSourcePortal, moduleValue6, [value6[r26], portal]);
value10 = value6.filter(_fun86903);
r6 = value10;
}
break reducibleLoop26;
}
break reducibleJoin31;
}
}
value9 = typeof r26 === 'bigint' ? r26 + 1n : +r26 + 1;
length = value6.length;
if (value9 < length) {
r26 = value9;
continue reducibleLoop26;
}
r6 = value6;
break reducibleLoop26;
}
} else {
r6 = value6;
}
}
reducibleJoin60: while (true) {
if (env0_1 === -1) {
break reducibleJoin60;
}
moduleValue13 = require(9544) /* metro dependency 9544: openMediaModal */;
openMediaModal = moduleValue13.openMediaModal;
object = {disableDownload: r6.some(_fun86904), initialSources: r6, initialIndex: env0_1,
originViewOrOriginLayout: layout, analyticsSource: 'Channel'};
id = messageChannel.id;
object.channelId = id;
reducibleJoin54: while (true) {
if (showContextName) {
moduleValue14 = require(4805) /* metro dependency 4805: useChannelName */;
computeChannelName = moduleValue14.computeChannelName;
channelName = Reflect.apply(computeChannelName, moduleValue14, [messageChannel, UserStore,
RelationshipStore,
false]);
r7 = channelName;
break reducibleJoin54;
}
r7 = value;
break reducibleJoin54;
}
object.contextName = r7;
reducibleJoin56: while (true) {
if (showContextName) {
moduleValue15 = require(6647) /* metro dependency 6647: ChannelUtils */;
getChannelIcon = moduleValue15.getChannelIcon;
value15 = Reflect.apply(getChannelIcon, moduleValue15, [messageChannel]);
r7 = value15;
break reducibleJoin56;
}
r7 = value;
break reducibleJoin56;
}
object.contextIcon = r7;
Reflect.apply(openMediaModal, moduleValue13, [object]);
break reducibleJoin60;
}
return value;
function _fun86901(a0) { // fn#86901, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11534:1051, offset: 0x01fa6ba1, size: 44 bytes, params: 2, frame: 11
let value = environment.__proto__;
value = require(9546) /* metro dependency 9546: MediaSourceUtil */;
return !value.isThumbnailAttachment(a0);
}
function _fun86903(a0, a1) { // fn#86903, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11534:2104, offset: 0x01fa6bcd, size: 96 bytes, params: 3, frame: 12
var binding;
let value = environment.__proto__;
value = require(9546) /* metro dependency 9546: MediaSourceUtil */;
value = value.flattenSource(a0);
const r0 = value != null && !value.noCarousel;
if (!r0 && env0_1 >= a1) {
binding = env0_1;
env0_1 = typeof binding === 'bigint' ? binding - 1n : +binding - 1;
}
return r0;
}
function _fun86904(a0) { // fn#86904, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11534:2216, offset: 0x01fa6c2d, size: 59 bytes, params: 2, frame: 13
let value = environment.__proto__;
value = require(9546) /* metro dependency 9546: MediaSourceUtil */;
value = value.flattenSource(a0, true);
return value != null && value.disableDownload;
}
}
}
global.__d(_fun86899, 11348, [4833, 3793, 1878, 661, 9548, 9877, 679, 9546, 3853, 4633, 9544, 4805, 6647,
2]) /* metro module 11348, dependencies: [4833, 3793, 1878, 661, 9548, 9877, 679, 9546, 3853, 4633, 9544, 4805, 6647, 2] */;