decord/source/modules/messages/native/handlers/handleMessagesTapImage.tsx
2026-08-05 07:35:12 +00:00

219 lines
7.7 KiB
TypeScript

// Module ID: 10905
// Function ID: 10906
// Name: handleMessagesTapImage
// Dependencies: [6948, 3892, 1874, 676, 8742, 10903, 694, 8740, 3952, 4482, 8738, 4445, 4715, 2]
// Exports: handleMessagesTapImage
// Module 10905 (handleMessagesTapImage)
import processMessage from "processMessage";
import upsertRelationship from "upsertRelationship";
import mergeGuildAvatar from "mergeGuildAvatar";
import { MessageTypes } from "ME";
const require = arg1;
let result = require("mergeGuildAvatar").fileFinishedImporting("modules/messages/native/handlers/handleMessagesTapImage.tsx");
export const handleMessagesTapImage = function handleMessagesTapImage(tapImageData) {
let allowWithinModal;
let componentId;
let componentMediaIndex;
let embedId;
let embedIndex;
let flattenSourceResult;
let index;
let message;
let messageChannel;
let num2;
let portal;
let selectedChannelId;
let showContextName;
let sources;
let tmp20;
let type;
tapImageData = tapImageData.tapImageData;
({ index, type, portal, embedIndex, componentId, componentMediaIndex, embedId } = tapImageData);
({ message, messageChannel, showContextName } = tapImageData);
num2 = undefined;
({ allowWithinModal, selectedChannelId } = tapImageData);
if (null != portal) {
let obj = embedId(8742);
obj.markPortalAlive(portal);
}
if (true === allowWithinModal) {
if ("attachment" !== type) {
if ("embed" !== type) {
if ("sticker" !== type) {
if ("component" !== type) {
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("Unsupported thumbnail type: " + type);
throw error;
}
}
}
}
let tmp7 = message;
if (message.type === MessageTypes.THREAD_STARTER_MESSAGE) {
tmp7 = message;
if (null != message.messageReference) {
const message2 = messageByReference.getMessageByReference(message.messageReference).message;
tmp7 = message;
if (null != message2) {
tmp7 = message2;
}
}
}
const messageReference = tmp7.messageReference;
type = undefined;
if (messageReference != null) {
type = messageReference.type;
}
let tmp12 = tmp7;
if (type !== embedId(694).MessageReferenceTypes.FORWARD) {
const attachments = tmp7.attachments;
const found = attachments.filter((flags) => !embedId(8740).isThumbnailAttachment(flags));
if ("attachment" === type) {
if (index < found.length) {
let tmp10Result = tmp10(8740);
if (null == tmp10Result.extractMediaFromAttachment(found[index], tmp7, index, messageChannel.guild_id)) {
if (null != tmp15.url) {
if ("" !== tmp15.url) {
num2(3952).openURL(tmp15.url);
}
}
}
}
}
num2 = -1;
if ("embed" === type) {
if (null != embedIndex) {
num2 = embedIndex;
tmp10Result = tmp10(8740);
const result = tmp10Result.extractMediaSourcesFromEmbed(tmp7, tmp12, tmp12.embeds[index], index, messageChannel.guild_id);
let found2 = result;
let tmp25 = tmp10;
if (num2 < result.length) {
tmp10(8740).setMediaSourcePortal(result[num2], portal);
found2 = result;
tmp25 = tmp10;
const tmp10Result1 = tmp10(8740);
}
}
if (-1 !== num2) {
let tmp25Result = tmp25(8738);
obj = { disableDownload: null, initialSources: null, initialIndex: null, originViewOrOriginLayout: null, analyticsSource: "Channel", channelId: null, contextName: null, contextIcon: null };
obj[0] = tmp44;
obj[1] = found2;
obj[2] = num2;
obj[3] = tapImageData.layout;
obj[5] = messageChannel.id;
let channelName;
if (showContextName) {
tmp25Result = tmp25(4445);
channelName = tmp25Result.computeChannelName(messageChannel, mergeGuildAvatar, upsertRelationship, false);
}
obj[6] = channelName;
let channelIcon;
if (showContextName) {
channelIcon = tmp25(4715).getChannelIcon(messageChannel);
const tmp25Result1 = tmp25(4715);
}
obj[7] = channelIcon;
tmp25Result.openMediaModal(obj);
}
}
if ("component" === type) {
if (null == componentId) {
return null;
} else {
if (null != embedId) {
if ("" !== embedId) {
const embeds = tmp12.embeds;
const found1 = embeds.find((id) => id.id === embedId);
if (found1 != null) {
let components = found1.components;
}
}
if (null != components) {
if (0 !== components.length) {
const tmp10Result2 = tmp10(8740);
const result1 = tmp10Result2.extractMediaSourcesFromComponent(tmp7, components, messageChannel.guild_id, tmp10(4482).asComponentId(componentId), componentMediaIndex);
if (null != result1) {
({ sources, initialIndex: num2 } = result1);
tmp10(8740).setMediaSourcePortal(sources[num2], portal);
found2 = sources;
tmp25 = tmp10;
const tmp10Result4 = tmp10(8740);
}
const tmp10Result3 = tmp10(4482);
}
}
}
components = tmp12.components;
}
} else {
const result2 = tmp10(8740).extractMediaSourcesFromMessage(tmp7, tmp12, messageChannel.guild_id);
num2 = 0;
found2 = result2;
tmp25 = tmp10;
if (0 < result2.length) {
while (true) {
tmp20 = embedId;
let tmp21 = dependencyMap;
let obj4 = embedId(8740);
flattenSourceResult = obj4.flattenSource(result2[num2]);
let tmp23 = num2;
if (null != flattenSourceResult) {
if (flattenSourceResult.accessoryType === type) {
let mediaIndex = flattenSourceResult.mediaViewIndex;
if (mediaIndex == null) {
mediaIndex = flattenSourceResult.mediaIndex;
}
if (mediaIndex === index) {
break;
}
}
}
num2 = num2 + 1;
found2 = result2;
tmp25 = tmp20;
let tmp26 = tmp21;
}
if (flattenSourceResult.noCarousel) {
const items = [result2[num2]];
num2 = 0;
let tmp20Result = tmp20(8740);
tmp20Result.setMediaSourcePortal(items[0], portal);
found2 = items;
tmp25 = tmp20;
} else {
tmp20Result = tmp20(8740);
tmp20Result.setMediaSourcePortal(result2[num2], portal);
found2 = result2.filter((closure_1) => {
const flattenSourceResult = embedId(outer1_2[7]).flattenSource(closure_1);
let tmp3 = !tmp2;
if (!(null != flattenSourceResult && !flattenSourceResult.noCarousel)) {
tmp3 = closure_1 >= arg1;
}
if (tmp3) {
closure_1 = closure_1 - 1;
}
return null != flattenSourceResult && !flattenSourceResult.noCarousel;
});
tmp25 = tmp20;
}
}
const tmp10Result5 = tmp10(8740);
}
} else {
const first = tmp7.messageSnapshots[0];
message = undefined;
if (first != null) {
message = first.message;
}
tmp12 = message;
}
} else {
const obj2 = embedId(10903);
}
};