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

438 lines
22 KiB
TypeScript

/* Metro module 11330; source: modules/messages/native/MessagesHooks.tsx; dependencies: [57, 31, 27, 9858, 7729, 4646, 1867, 4396, 566, 22, 628, 6772, 1360, 4116, 11331, 9835, 11332, 2] */
import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */
import GuildStore from '../../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import PresenceStore from '../../../stores/PresenceStore.tsx'; /* Metro dependency 4396 */
import GuildAvailabilityStore from '../../../stores/GuildAvailabilityStore.tsx'; /* Metro dependency 4646 */
import VoiceChannelStartTimeStore from '../../channel/VoiceChannelStartTimeStore.tsx'; /* Metro dependency 9858 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ShallowEqualModule from '../../../external/discord_common/js/packages/shallow-equal/shallowEqual.tsx'; /* Metro dependency 628 */
import * as UseChatBottomManagerUIStoreModule from '../../chat_input/native/useChatBottomManagerUIStore.tsx'; /* Metro dependency 7729 */
function _fun86505(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#86505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:6, offset: 0x01f966dc, size: 355 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_86508 = 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 Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/messages/native/MessagesHooks.tsx');
exports.useMessageAuthorActivities = useMessageAuthorActivities_86509;
exports.useFetchMessageApplications = useFetchMessageApplications_86514;
exports.useFetchVoiceChannelInviteStartTimes = useFetchVoiceChannelInviteStartTimes;
exports.useMessagesLifecycle = useMessagesLifecycle;
exports.useScrollState = useScrollState_86525;
exports.useChatUpdatesQueue = useChatUpdatesQueue;
exports.useMessagesState = useMessagesState;
function _createForOfIteratorHelperLoose_86506(a0, a1) { // fn#86506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:234, offset: 0x01f9683f, 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 _fun86507;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_86508(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_86508(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_86508(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun86507;
}
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 _fun86507() { // fn#86507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:805, 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 useMessageAuthorActivities_86509(a0) { // fn#86509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1251, offset: 0x01f969b3, size: 110 bytes, params: 2, frame: 16
const env0_0 = a0;
return (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([PresenceStore], _fun86512,
[ReactModule.useMemo(function() {
var object = {};
object.forEach(_fun86511);
return object;
}, [a0])]);
function _fun86510() { // fn#86510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1307, offset: 0x01f96a21, size: 34 bytes, params: 1, frame: 12
const object = {};
object.forEach(_fun86511);
return object;
function _fun86511(a0) { // fn#86511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1339, offset: 0x01f93bdc, size: 57 bytes, params: 2, frame: 4
if (a0.author != null && a0.activity != null) {
env0_0[a0.author.id] = null;
}
}
}
function _fun86512() { // fn#86512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1457, offset: 0x01f96a43, size: 55 bytes, params: 1, frame: 13
var environment;
let value = environment.__proto__;
value = importDefault(22) /* metro dependency 22 */;
return value.mapValues(env0_1, function(a0, a1) {
return PresenceStore.getPrimaryActivity(a1);
});
}
}
function useFetchMessageApplications_86514(a0) { // fn#86514, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1553, offset: 0x01f96a91, size: 94 bytes, params: 2, frame: 14
const env0_0 = a0;
const value = ReactModule.useMemo(function() {
var value2 = new global.Set();
value2.forEach(_fun86516);
return global.Array.from(value2);
}, [a0]);
const env0_2 = ReactModule.useRef([]);
ReactModule.useEffect(_fun86517, [value]);
function _fun86515() { // fn#86515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1610, offset: 0x01f96aef, size: 76 bytes, params: 1, frame: 13
const Set = global.Set;
const set = new Set();
set.forEach(_fun86516);
const Array = global.Array;
return Array.from(set);
function _fun86516(a0) { // fn#86516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1647, offset: 0x01f93d0d, size: 55 bytes, params: 2, frame: 12
var binding;
if (a0.applicationId != null && a0.application == null) {
binding = env0_0;
binding.add(a0.applicationId);
}
}
}
function _fun86517() { // fn#86517, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1770, offset: 0x01f96b3b, size: 174 bytes, params: 1, frame: 19
var defaultImport;
var fetchApplications;
var defaultImport2;
var value3;
let value = environment.__proto__;
const areArraysShallowEqual = ShallowEqualModule.areArraysShallowEqual;
let binding = env0_1;
if (!Reflect.apply(areArraysShallowEqual, ShallowEqualModule, [binding, env0_2.current])) {
defaultImport = importDefault(6772) /* metro dependency 6772: ApplicationActionCreators */;
fetchApplications = defaultImport.fetchApplications;
defaultImport2 = importDefault(22) /* metro dependency 22 */;
binding = env0_1;
value3 = defaultImport2(binding);
value = value3.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish);
value = value.uniq();
value = value.value();
Reflect.apply(fetchApplications, defaultImport, [value, false]);
env0_2.current = binding;
}
}
}
function useFetchVoiceChannelInviteStartTimes(a0) { // fn#86518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:1971, offset: 0x01f96be9, size: 122 bytes, params: 2, frame: 19
const env0_0 = a0;
ReactModule.useEffect(_fun86520, [a0,
(FluxModule).useStateFromStoresObject([GuildStore, GuildAvailabilityStore],
_fun86519, [a0])]);
function _fun86519() { // fn#86519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2067, offset: 0x01f96c63, size: 185 bytes, params: 1, frame: 21
var r3;
var r10;
var value6;
var guild;
var moduleValue;
var isVoiceChannelInvite;
var id;
var guildStoreBinding;
var getGuild;
var value7;
var guildAvailabilityStoreBinding;
var isUnavailable;
var value8;
var value9;
const object = {};
const value4 = _createForOfIteratorHelperLoose_86506(env0_0.values());
const value5 = value4();
let done = value5.done;
if (!done) {
r3 = value5;
while (true) {
value6 = r3.value;
guild = value6.guild;
if (guild != null) {
moduleValue = require(4116) /* metro dependency 4116: InviteTypeUtils */;
isVoiceChannelInvite = moduleValue.isVoiceChannelInvite;
if (Reflect.apply(isVoiceChannelInvite, moduleValue, [value6])) {
guild = value6.guild;
id = guild.id;
guildStoreBinding = GuildStore;
getGuild = guildStoreBinding.getGuild;
value7 = Reflect.apply(getGuild, guildStoreBinding, [id]) != null;
if (!value7) {
r10 = value7;
continue;
}
guildAvailabilityStoreBinding = GuildAvailabilityStore;
isUnavailable = guildAvailabilityStoreBinding.isUnavailable;
value8 = !Reflect.apply(isUnavailable, guildAvailabilityStoreBinding, [id]);
r10 = value8;
object[id] = r10;
break;
}
break;
}
value9 = value4();
done = value9.done;
if (done) {
break;
}
r3 = value9;
continue;
}
}
return object;
}
function _fun86520() { // fn#86520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2309, offset: 0x01f96d1c, size: 211 bytes, params: 1, frame: 23
var r3;
var r12;
var value6;
var guild;
var moduleValue;
var isVoiceChannelInvite;
var id;
var value7;
var hasRequestedStartTimes2;
var moduleValue2;
var value8;
const value4 = _createForOfIteratorHelperLoose_86506(env0_0.values());
const value5 = value4();
let done = value5.done;
if (!done) {
r3 = value5;
while (true) {
value6 = r3.value;
guild = value6.guild;
if (guild != null) {
moduleValue = require(4116) /* metro dependency 4116: InviteTypeUtils */;
isVoiceChannelInvite = moduleValue.isVoiceChannelInvite;
if (Reflect.apply(isVoiceChannelInvite, moduleValue, [value6])) {
guild = value6.guild;
id = guild.id;
value7 = env0_1[id] !== true;
if (value7) {
r12 = value7;
continue;
}
hasRequestedStartTimes2 = VoiceChannelStartTimeStore.hasRequestedStartTimes(id);
r12 = hasRequestedStartTimes2;
if (r12) {
break;
}
moduleValue2 = require(11331) /* metro dependency 11331: ChannelInfoActionCreators */;
moduleValue2.fetchChannelInfo(id);
break;
}
break;
}
value8 = value4();
done = value8.done;
if (done) {
break;
}
r3 = value8;
continue;
}
}
}
}
function useMessagesLifecycle({messages, isMessagesReady, oldestUnreadMessageId, channelId, screenIndex, updateRows, scrollToMessageId}) { // fn#86521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2576, offset: 0x01f96def, size: 137 bytes, params: 2, frame: 16
const binding = screenIndex;
binding.useEffect(_fun86522, []);
binding.useEffect(function() {
return _fun86524;
}, [channelId, screenIndex]);
function _fun86522() { // fn#86522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2734, offset: 0x01f96e78, size: 126 bytes, params: 1, frame: 20
let value = environment.__proto__;
value = require(9835) /* metro dependency 9835: MessagesUtils */;
const syncMessageDisplay = value.syncMessageDisplay;
const messagesBinding = messages;
const channelIdBinding = channelId;
Reflect.apply(syncMessageDisplay, value, [{messages: messagesBinding, isMessagesReady: isMessagesReady,
oldestUnreadMessageId: oldestUnreadMessageId, channelId: channelIdBinding, screenIndex: screenIndex,
updateRows: updateRows, scrollToMessageId: scrollToMessageId}]);
(require(9835) /* metro dependency 9835: MessagesUtils */).recordTimings(channelIdBinding, messagesBinding);
}
function _fun86523() { // fn#86523, offset: 0x01f96ef6, size: 11 bytes, params: 1, frame: 1
return function() {
updateShouldShowJumpToPresentButton(channelId, screenIndex, false);
};
function _fun86524() { // fn#86524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2935, offset: 0x01f96f01, size: 31 bytes, params: 1, frame: 15
updateShouldShowJumpToPresentButton(channelId, screenIndex, false);
}
}
}
function useScrollState_86525() { // fn#86525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:2978, offset: 0x01f96f20, size: 101 bytes, params: 1, frame: 15
const value = Module00057(ReactModule.useState({'animated': false, 'hasHandledScroll': false, 'isAtBottom': false,
'isNearBottom': false, 'isNearTop': false, 'decelerating': false, 'dragging': false,
'hasMoreMessagesAfterForLastUpdate': false, '_loaded': false}), 2);
const property = value[0];
const env0_0 = value[1];
const useCallback = ReactModule.useCallback;
return [property, Reflect.apply(useCallback, ReactModule, [function(a0) {
a0(_fun86527);
}, []])];
function _fun86526(a0) { // fn#86526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3222, offset: 0x01f96f85, size: 32 bytes, params: 2, frame: 11
a0(_fun86527);
function _fun86527(a0) { // fn#86527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3229, offset: 0x01d0cd72, size: 28 bytes, params: 2, frame: 11
const object = {};
copyDataProperties(object, a0, undefined);
copyDataProperties(object, env0_0, environment);
return object;
}
}
}
function useChatUpdatesQueue(a0, a1) { // fn#86528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3279, offset: 0x01f96fa5, size: 85 bytes, params: 3, frame: 15
const env0_0 = a0;
const env0_1 = a1;
const value = ReactModule.useMemo(_fun86529, [a0, a1]);
ReactModule.useEffect(function() {
return _fun86533;
}, [value]);
return value;
function _fun86529() { // fn#86529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3330, offset: 0x01f96ffa, size: 63 bytes, params: 1, frame: 13
var environment;
let value = environment.__proto__;
value = importDefault(11332) /* metro dependency 11332: ChatUpdatesQueue */;
const value2 = Object.create(value.prototype, {constructor: {value: value}});
value = new value(_fun86530, function(a0) {
require(a0);
});
return value instanceof Object ? value : value2;
function _fun86530() { // fn#86530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3349, offset: 0x01f97039, size: 43 bytes, params: 1, frame: 12
const value = environment.__proto__;
const current = env1_0.current;
const value2 = null;
return value2 === current ? value2 : findNodeHandle(env1_0.current);
}
}
function _fun86532() { // fn#86532, offset: 0x01f97077, size: 11 bytes, params: 1, frame: 1
return _fun86533;
function _fun86533() { // fn#86533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3434, offset: 0x01f97082, size: 21 bytes, params: 1, frame: 9
env1_2.cleanup();
}
}
}
function useMessagesState() { // fn#86534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11516:3481, offset: 0x01f97097, size: 97 bytes, params: 1, frame: 19
let useState = ReactModule.useState;
const value2 = Reflect.apply(useState, ReactModule, [false]);
let value = Module00057(value2, 2);
const property = value[0];
const property2 = value[1];
useState = ReactModule.useState;
value = Module00057(Reflect.apply(useState, ReactModule, [false]), 2);
return {shouldForceRender: property, hasJumpedToOriginalPost: value[0], setHasJumpedToOriginalPost: value[1],
setShouldForceRender: property2};
}
}
global.__d(_fun86505, 11330, [57, 31, 27, 9858, 7729, 4646, 1867, 4396, 566, 22, 628, 6772, 1360, 4116, 11331, 9835,
11332,
2]) /* metro module 11330, dependencies: [57, 31, 27, 9858, 7729, 4646, 1867, 4396, 566, 22, 628, 6772, 1360, 4116, 11331, 9835, 11332, 2] */;