208 lines
10 KiB
TypeScript
208 lines
10 KiB
TypeScript
/* Metro module 10921; source: modules/in_app_notifications/InAppNotificationUtils.tsx; dependencies: [31, 3793, 1878, 10922, 661, 4805, 1244, 22, 491, 4845, 4863, 2] */
|
|
function _fun83687(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#83687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:6, offset: 0x01f24bb2, size: 330 bytes, params: 8, frame: 20
|
|
const env0_0 = require;
|
|
const closure = extractGuildAndChannelAndMessageIdFromNotification;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importAll(31) /* metro dependency 31 */;
|
|
const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */;
|
|
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
|
|
const env0_6 = (require(10922) /* metro dependency 10922: InAppNotificationConstants */).REACTION_MILESTONE_COUNTS;
|
|
const constantsModule = require(661) /* metro dependency 661: Constants */;
|
|
const env0_7 = constantsModule.AnalyticEvents;
|
|
const env0_8 = constantsModule.ChannelTypes;
|
|
const env0_9 = constantsModule.InAppNotificationTypes;
|
|
const env0_10 = constantsModule.MessageEmbedTypes;
|
|
const env0_11 = constantsModule.MessageFlags;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/in_app_notifications/InAppNotificationUtils.tsx');
|
|
exports.getNotificationTitle = getNotificationTitle;
|
|
exports.getNotificationBodyText = getNotificationBodyText;
|
|
exports.isReactionMilestoneNotification = function(a0, a1) {
|
|
if (a1 == null) {
|
|
return false;
|
|
}
|
|
if (a1 === ChannelTypes.GUILD_ANNOUNCEMENT) {
|
|
return false;
|
|
}
|
|
return REACTION_MILESTONE_COUNTS.has(require(dependencyMap[7]).sumBy(a0, _fun83694));
|
|
};
|
|
exports.generateInAppNotificationId = generateInAppNotificationId;
|
|
exports.useHasPreviewableMedia = useHasPreviewableMedia;
|
|
exports.extractGuildAndChannelAndMessageIdFromNotification = closure;
|
|
exports.trackInAppNotificationAccessoryClicked = function(a0, a1) {
|
|
var {guildId, channelId, messageId} = extractGuildAndChannelAndMessageIdFromNotification(a0);
|
|
var defaultImport = importDefault(dependencyMap[10]);
|
|
var IN_APP_NOTIFICATION_ACCESSORY_CLICKED = AnalyticEvents.IN_APP_NOTIFICATION_ACCESSORY_CLICKED;
|
|
defaultImport.trackWithMetadata(IN_APP_NOTIFICATION_ACCESSORY_CLICKED, {type: a0.type,
|
|
in_app_notification_id: a0.inAppNotificationId, notif_guild_id: guildId, notif_channel_id: channelId,
|
|
message_id: messageId, accessory: a1});
|
|
};
|
|
}
|
|
|
|
function hasMedia(a0) { // fn#83688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:274, offset: 0x01f24cfc, size: 121 bytes, params: 2, frame: 14
|
|
const hasFlag = a0.hasFlag;
|
|
const IS_VOICE_MESSAGE = MessageFlags.IS_VOICE_MESSAGE;
|
|
let r0 = Reflect.apply(hasFlag, a0, [IS_VOICE_MESSAGE]) || a0.attachments.length > 0;
|
|
r0 = !r0 ? a0.embeds.length > 0 && a0.embeds.every(function({type}) {
|
|
return type === MessageEmbedTypes.GIFV;
|
|
}) : r0;
|
|
r0 = !r0 ? a0.stickerItems.length > 0 : r0;
|
|
return r0;
|
|
}
|
|
|
|
function extractGuildAndChannelAndMessageIdFromNotification(a0) { // fn#83690, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:438, offset: 0x01f24d90, size: 421 bytes, params: 2, frame: 10
|
|
var guild_id;
|
|
var id;
|
|
var r5;
|
|
var r1;
|
|
var r2;
|
|
var r3;
|
|
var MESSAGE_REMINDER;
|
|
var channel;
|
|
var channelId;
|
|
var thread;
|
|
var guild;
|
|
var message;
|
|
const type = a0.type;
|
|
var value;
|
|
const MESSAGE = InAppNotificationTypes.MESSAGE;
|
|
if (MESSAGE === type) {
|
|
guild = a0.guild;
|
|
value = undefined;
|
|
id = guild == null ? value : guild.id;
|
|
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
|
|
channel = a0.channel;
|
|
id = channel == null ? value : channel.id;
|
|
message = a0.message;
|
|
r1 = message == null ? value : message.id;
|
|
r2 = id;
|
|
r3 = r5;
|
|
} else if (InAppNotificationTypes.REACTION === type) {
|
|
guild = a0.guild;
|
|
value = undefined;
|
|
id = guild == null ? value : guild.id;
|
|
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
|
|
channel = a0.channel;
|
|
id = channel == null ? value : channel.id;
|
|
message = a0.message;
|
|
r1 = message == null ? value : message.id;
|
|
r2 = id;
|
|
r3 = r5;
|
|
} else if (InAppNotificationTypes.ALERT === type) {
|
|
guild = a0.guild;
|
|
value = undefined;
|
|
id = guild == null ? value : guild.id;
|
|
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
|
|
channel = a0.channel;
|
|
id = channel == null ? value : channel.id;
|
|
r1 = value;
|
|
r2 = id;
|
|
r3 = r5;
|
|
} else if (InAppNotificationTypes.FORUM_THREAD_CREATED === type) {
|
|
thread = a0.thread;
|
|
value = undefined;
|
|
guild_id = thread == null ? value : thread.guild_id;
|
|
thread = a0.thread;
|
|
id = thread == null ? value : thread.id;
|
|
r1 = value;
|
|
r2 = id;
|
|
r3 = guild_id;
|
|
} else if (InAppNotificationTypes.MESSAGE_FAILED_TO_SEND === type) {
|
|
channelId = a0.channelId;
|
|
value = undefined;
|
|
r1 = value;
|
|
r2 = channelId;
|
|
r3 = value;
|
|
} else {
|
|
MESSAGE_REMINDER = InAppNotificationTypes.MESSAGE_REMINDER;
|
|
value = undefined;
|
|
if (MESSAGE_REMINDER !== type) {
|
|
r1 = value;
|
|
r2 = value;
|
|
r3 = value;
|
|
} else {
|
|
channel = a0.channel;
|
|
guild_id = channel == null ? value : channel.guild_id;
|
|
channel = a0.channel;
|
|
id = channel == null ? value : channel.id;
|
|
r1 = value;
|
|
r2 = id;
|
|
r3 = guild_id;
|
|
}
|
|
}
|
|
return {guildId: r3, channelId: r2, messageId: r1};
|
|
}
|
|
|
|
function getNotificationTitle(a0, {nick}, a2, a3) { // fn#83691, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:1283, offset: 0x01f24f35, size: 476 bytes, params: 5, frame: 26
|
|
const channelName = (require(4805) /* metro dependency 4805: useChannelName */).computeChannelName(a0, UserStore,
|
|
RelationshipStore, true);
|
|
const r11 = a2 != null ? (require(4805) /* metro dependency 4805: useChannelName */).computeChannelName(a2,
|
|
UserStore, RelationshipStore) : null;
|
|
const type = a0.type;
|
|
const GROUP_DM = ChannelTypes.GROUP_DM;
|
|
return GROUP_DM === type ? '' + nick + ' (' + channelName + ')' : ChannelTypes.GUILD_TEXT === type || ChannelTypes.GUILD_ANNOUNCEMENT === type ? a3 == null ? nick : '' + nick + ' (' + channelName + ', ' + a3.name + ')' : ChannelTypes.ANNOUNCEMENT_THREAD === type || ChannelTypes.PUBLIC_THREAD === type ? a2 != null ? '' + nick + ' (' + channelName + ', ' + r11 + ')' : a3 != null ? '' + nick + ' (' + channelName + ', ' + a3.name + ')' : '' + nick + ' (' + channelName + ')' : ChannelTypes.PRIVATE_THREAD !== type ? nick : a2 != null ? '' + nick + ' (' + channelName + ', ' + r11 + ')' : a3 != null ? '' + nick + ' (' + channelName + ', ' + a3.name + ')' : '' + nick + ' (' + channelName + ')';
|
|
}
|
|
|
|
function getNotificationBodyText({notificationMessageContent, isGdmAllReactionNotification, messageAuthor, emojiHook}) { // fn#83692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:1747, offset: 0x01f25111, size: 229 bytes, params: 2, frame: 19
|
|
var r1;
|
|
let value = notificationMessageContent != null;
|
|
if (value) {
|
|
value = notificationMessageContent.trim();
|
|
value = value !== '';
|
|
r1 = value;
|
|
} else {
|
|
r1 = value;
|
|
}
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const format = intl.format;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
return isGdmAllReactionNotification ? r1 ? Reflect.apply(format, intl, [t.MJPwfg, {emojiHook: emojiHook,
|
|
username: messageAuthor.nick}]) : Reflect.apply(format, intl, [t.FpJqb0, {emojiHook: emojiHook,
|
|
username: messageAuthor.nick}]) : r1 ? Reflect.apply(format, intl, [t.sHV43G,
|
|
{emojiHook: emojiHook}]) : Reflect.apply(format, intl, [t.ZOzpKt, {emojiHook: emojiHook}]);
|
|
}
|
|
|
|
function isReactionMilestoneNotification(a0, a1) { // fn#83693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2188, offset: 0x01f251f6, size: 92 bytes, params: 3, frame: 14
|
|
if (a1 == null) {
|
|
return false;
|
|
}
|
|
const GUILD_ANNOUNCEMENT = ChannelTypes.GUILD_ANNOUNCEMENT;
|
|
if (a1 === GUILD_ANNOUNCEMENT) {
|
|
return false;
|
|
}
|
|
return REACTION_MILESTONE_COUNTS.has((require(22) /* metro dependency 22 */).sumBy(a0, function({count_details}) {
|
|
var r5;
|
|
var value = undefined;
|
|
r5 = count_details == null ? value : count_details.burst;
|
|
var value2 = 0;
|
|
return (r5 ?? value2) + ((count_details == null ? value : count_details.normal) ?? value2);
|
|
}));
|
|
}
|
|
|
|
function generateInAppNotificationId() { // fn#83695, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2468, offset: 0x01f25299, size: 37 bytes, params: 1, frame: 11
|
|
return (require(491) /* metro dependency 491 */).v4();
|
|
}
|
|
|
|
function useHasPreviewableMedia(a0) { // fn#83696, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2553, offset: 0x01f252be, size: 44 bytes, params: 2, frame: 14
|
|
const env0_0 = a0;
|
|
return env0_3.useMemo(_fun83697, [a0]);
|
|
}
|
|
|
|
function _fun83697() { // fn#83697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2606, offset: 0x01f252ea, size: 91 bytes, params: 1, frame: 14
|
|
var environment;
|
|
var r0;
|
|
let value = environment.__proto__;
|
|
const hasMedia2 = hasMedia(env0_0);
|
|
if (hasMedia2) {
|
|
r0 = hasMedia2;
|
|
} else {
|
|
value = importDefault(4845) /* metro dependency 4845: isForwardMessage */;
|
|
value = value(env0_0);
|
|
r0 = value && env0_0.messageSnapshots.some(function(a0) {
|
|
return hasMedia(a0.message);
|
|
});
|
|
}
|
|
return r0;
|
|
}
|
|
|