Files
discord-decomp/sources/modules/gateway/EntityVersionsManager.tsx
T
2026-07-27 16:20:00 +03:00

295 lines
14 KiB
TypeScript

/* Metro module 15695; source: modules/gateway/EntityVersionsManager.tsx; dependencies: [6, 7, 15, 17, 18, 6540, 6583, 1379, 1938, 1867, 4257, 3, 694, 4860, 566, 5234, 1225, 21, 2] */
function _fun120403(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#120403, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:6, offset: 0x0252a892, size: 419 bytes, params: 8, frame: 18
const scheduleGuild = function(a0) {
var env0_0 = a0;
var property = global.Math;
var Math = global.Math;
var value = Math.random();
value = property.ceil(2000 * value);
global.setTimeout(_fun120422, value);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(6) /* metro dependency 6 */;
const env0_3 = importDefault(7) /* metro dependency 7 */;
const env0_4 = importDefault(15) /* metro dependency 15 */;
const env0_5 = importDefault(17) /* metro dependency 17 */;
const env0_6 = importDefault(18) /* metro dependency 18 */;
const emojiStore = importDefault(6540) /* metro dependency 6540: EmojiStore */;
const stickersStore = importDefault(6583) /* metro dependency 6583: StickersStore */;
const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */;
const guildRoleStore = importDefault(1938) /* metro dependency 1938: GuildRoleStore */;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
const gatewayConnectionStore = importDefault(4257) /* metro dependency 4257: GatewayConnectionStore */;
let value = importDefault(3) /* metro dependency 3: Logger */;
value = new value('EntityVersionsManager');
value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */;
value = _fun120428(value);
value = new value();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/gateway/EntityVersionsManager.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_120404() { // fn#120404, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:209, offset: 0x0252aa35, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_120404_isNativeReflectConstruct = function() {
return !!result;
})();
}
function handleDeletedEntityIds(a0) { // fn#120407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:447, offset: 0x0252aa97, size: 154 bytes, params: 2, frame: 22
const env0_0 = a0;
const guild = GuildStore.getGuild(a0.guild_id);
const value3 = undefined;
const name = guild == null ? value3 : guild.name;
const binding = env0_13;
binding.fileOnly('received deleted guild entities (id: ' + a0.guild_id + ', name: ' + name + ')');
const Emitter = (importDefault(566) /* metro dependency 566: flux */).Emitter;
Emitter.batched(_fun120408);
return value3;
}
function handleConnectionOpen_120417() { // fn#120417, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1641, offset: 0x0252aed2, size: 56 bytes, params: 1, frame: 12
let value = importDefault(5234) /* metro dependency 5234: GuildsRequiringDeletedIdsSync */;
value = value.getAll();
value.then(function(a0) {
a0.forEach(_fun120419);
});
}
function handleGuildCreate_120420({guild}) { // fn#120420, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1737, offset: 0x0252af37, size: 40 bytes, params: 2, frame: 11
if (guild.unableToSyncDeletes) {
scheduleGuild(guild.id);
}
}
function scheduleGuild(a0) { // fn#120421, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1818, offset: 0x0252af5f, size: 77 bytes, params: 2, frame: 15
const env0_0 = a0;
const Math = global.Math;
const ceil = Math.ceil;
const Math2 = global.Math;
let value = Math2.random();
value = Reflect.apply(ceil, Math, [2000 * value]);
global.setTimeout(_fun120422, value);
}
function computeHash(a0) { // fn#120427, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:2389, offset: 0x0252b0f9, size: 74 bytes, params: 2, frame: 13
var value;
const v3 = (importDefault(1225) /* metro dependency 1225 */).v3;
const value2 = a0.sort();
value = Reflect.apply(v3, value, [value2.join(',')]);
return value.toString();
}
function _fun120428(a0) { // fn#120428, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:2473, offset: 0x0252b143, size: 97 bytes, params: 2, frame: 16
const closure = EntityVersionsManager;
env0_6(closure, a0);
return env0_3(closure, [{key: '_initialize', value: function() {
importDefault(dependencyMap[12]).subscribe('CONNECTION_OPEN', handleConnectionOpen_120417);
}}, {key: '_terminate', value: function() {
importDefault(dependencyMap[12]).unsubscribe('CONNECTION_OPEN', handleConnectionOpen_120417);
}}]);
}
function _fun120408() { // fn#120408, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:641, offset: 0x0252ab31, size: 299 bytes, params: 1, frame: 16
var binding;
var guild_id;
var Set;
var value2;
var set;
var value4;
var value6;
let channels = env0_0.channels;
if (channels != null) {
binding = env0_0;
guild_id = binding.guild_id;
Set = global.Set;
channels = binding.channels;
value2 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set(channels);
syncChannels(guild_id, set instanceof Object ? set : value2);
}
let roles = env0_0.roles;
if (roles != null) {
binding = env0_0;
guild_id = binding.guild_id;
Set = global.Set;
roles = binding.roles;
value4 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set(roles);
syncRoles_120411(guild_id, set instanceof Object ? set : value4);
}
let emojis = env0_0.emojis;
if (emojis != null) {
binding = env0_0;
guild_id = binding.guild_id;
Set = global.Set;
emojis = binding.emojis;
value6 = Object.create(Set.prototype, {constructor: {value: Set}});
set = new Set(emojis);
syncEmojis_120413(guild_id, set instanceof Object ? set : value6);
}
if (env0_0.stickers != null) {
binding = env0_0;
syncStickers_120415(binding.guild_id, new global.Set(binding.stickers));
}
}
function _fun120418(a0) { // fn#120418, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1697, offset: 0x0252af0a, size: 26 bytes, params: 2, frame: 11
a0.forEach(function(a0) {
scheduleGuild(a0);
});
}
function _fun120422() { // fn#120422, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1891, offset: 0x0252afac, size: 25 bytes, params: 1, frame: 11
computeHashAndFetchDeletedIds(env0_0);
}
function EntityVersionsManager(a0) { // fn#120429, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:2485, offset: 0x0252b1a4, size: 152 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_2;
binding(this, EntityVersionsManager);
const items = [];
arraySpread(items, value, 0, items);
value = env1_5(EntityVersionsManager);
binding = env1_4;
if (_isNativeReflectConstruct_120404()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items, env1_5(this).constructor);
r0 = value;
} else {
value = value.apply(this, items);
r0 = value;
}
value = binding(this, r0);
value.actions = {GUILD_CREATE: handleGuildCreate_120420, DELETED_ENTITY_IDS: handleDeletedEntityIds};
return value;
}
function syncChannels(a0, a1) { // fn#120409, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:664, offset: 0x0252ac5c, size: 123 bytes, params: 3, frame: 18
const env0_0 = a0;
const env0_1 = a1;
const defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */;
const keys = defaultImport.keys;
const getMutableBasicGuildChannelsForGuild = ChannelStore.getMutableBasicGuildChannelsForGuild;
const value2 = Reflect.apply(keys, defaultImport, [Reflect.apply(getMutableBasicGuildChannelsForGuild, ChannelStore,
[a0])]);
const binding = env2_13;
binding.fileOnly('syncChannels', {channelIdsInMemory: value2, channelIdsFromServer: a1});
value2.forEach(_fun120410);
}
function syncRoles_120411(a0, a1) { // fn#120411, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:989, offset: 0x0252ad36, size: 85 bytes, params: 3, frame: 15
var environment;
const env0_0 = a0;
const env0_1 = a1;
const value = environment.__proto__.__proto__;
const defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */;
const keys = defaultImport.keys;
const getUnsafeMutableRoles = GuildRoleStore.getUnsafeMutableRoles;
Reflect.apply(keys, defaultImport, [Reflect.apply(getUnsafeMutableRoles, GuildRoleStore, [a0])]).forEach(_fun120412);
}
function syncEmojis_120413(a0, a1) { // fn#120413, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1192, offset: 0x0252ade0, size: 116 bytes, params: 3, frame: 14
var environment;
const env0_0 = a1;
let value = environment.__proto__.__proto__;
const guildEmoji = EmojiStore.getGuildEmoji(a0);
const value3 = guildEmoji.filter(function(a0) {
return require.has(a0.id);
});
if (guildEmoji.length !== value3.length) {
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.dispatch({type: 'GUILD_EMOJIS_UPDATE', guildId: a0, emojis: value3});
}
}
function syncStickers_120415(a0, a1) { // fn#120415, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1408, offset: 0x0252ae54, size: 126 bytes, params: 3, frame: 14
var environment;
const env0_0 = a1;
let value = environment.__proto__.__proto__;
const r1 = StickersStore.getStickersByGuildId(a0) ?? [];
const value3 = r1.filter(function(a0) {
return require.has(a0.id);
});
if (r1.length !== value3.length) {
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.dispatch({type: 'GUILD_STICKERS_UPDATE', guildId: a0, stickers: value3});
}
}
function computeHashAndFetchDeletedIds(a0) { // fn#120423, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1895, offset: 0x0252afc5, size: 308 bytes, params: 2, frame: 25
var environment;
const value = environment.__proto__.__proto__;
const guild = GuildStore.getGuild(a0);
const value3 = undefined;
env2_13.fileOnly('requesting deleted guild entities (id: ' + a0 + ', name: ' + (guild == null ? value3 : guild.name) + ')');
const computeHashBinding = computeHash;
const Object = global.Object;
const keys = Object.keys;
const getMutableBasicGuildChannelsForGuild = ChannelStore.getMutableBasicGuildChannelsForGuild;
const hash = computeHashBinding(Reflect.apply(keys, Object, [Reflect.apply(getMutableBasicGuildChannelsForGuild,
ChannelStore, [a0])]));
const sortedRoles = GuildRoleStore.getSortedRoles(a0);
const hash2 = computeHashBinding(sortedRoles.map(function(a0) {
return a0.id;
}));
const guildEmoji = EmojiStore.getGuildEmoji(a0);
const hash3 = computeHashBinding(guildEmoji.map(function(a0) {
return a0.id;
}));
const stickersByGuildId = StickersStore.getStickersByGuildId(a0);
let r2 = stickersByGuildId == null ? value3 : stickersByGuildId.map(function(a0) {
return a0.id;
});
r2 = r2 ?? [];
GatewayConnectionStore.getSocket().getDeletedEntityIdsNotMatchingHash(a0, hash, hash2, hash3,
computeHashBinding(r2));
return value3;
}
function _fun120410(a0) { // fn#120410, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:838, offset: 0x0252acd7, size: 95 bytes, params: 2, frame: 15
var value2;
if (!require.has(a0)) {
value2 = environment.__proto__.__proto__.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'CHANNEL_DELETE',
channel: {guild_id: env0_0, id: a0, parent_id: undefined}});
}
}
function _fun120412(a0) { // fn#120412, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1064, offset: 0x0252ad8b, size: 85 bytes, params: 2, frame: 14
var value2;
var defaultImport;
if (!require.has(a0)) {
value2 = environment.__proto__.__proto__.__proto__;
defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */;
defaultImport.dispatch({type: 'GUILD_ROLE_DELETE', guildId: env0_0, roleId: a0});
}
}