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

312 lines
17 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] */
import Logger from '../debug/Logger.tsx'; /* Metro dependency 3 */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import SnowflakeUtils from '../../utils/SnowflakeUtils.tsx'; /* Metro dependency 21 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import Module01225 from '../../by-id/module-01225.js'; /* Metro dependency 1225 */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import GuildRoleStore from '../../stores/GuildRoleStore.tsx'; /* Metro dependency 1938 */
import GatewayConnectionStore from './GatewayConnectionStore.tsx'; /* Metro dependency 4257 */
import GuildsRequiringDeletedIdsSync from '../app_database/modules/GuildsRequiringDeletedIdsSync.tsx'; /* Metro dependency 5234 */
import EmojiStore from '../emojis/EmojiStore.tsx'; /* Metro dependency 6540 */
import StickersStore from '../stickers/StickersStore.tsx'; /* Metro dependency 6583 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 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});
let value = Logger;
value = new value('EntityVersionsManager');
value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */;
value = _fun120428(value);
value = new value();
(FileImportTrackerModule).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 = (Flux).Emitter;
Emitter.batched(_fun120408);
return value3;
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 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 = SnowflakeUtils;
const keys = defaultImport.keys;
const channelStoreBinding = ChannelStore;
const getMutableBasicGuildChannelsForGuild = channelStoreBinding.getMutableBasicGuildChannelsForGuild;
const value2 = Reflect.apply(keys, defaultImport, [Reflect.apply(getMutableBasicGuildChannelsForGuild,
channelStoreBinding, [a0])]);
const binding = env2_13;
binding.fileOnly('syncChannels', {channelIdsInMemory: value2, channelIdsFromServer: a1});
value2.forEach(_fun120410);
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 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 = SnowflakeUtils;
const keys = defaultImport.keys;
const guildRoleStoreBinding = GuildRoleStore;
const getUnsafeMutableRoles = guildRoleStoreBinding.getUnsafeMutableRoles;
Reflect.apply(keys, defaultImport, [Reflect.apply(getUnsafeMutableRoles, guildRoleStoreBinding,
[a0])]).forEach(_fun120412);
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});
}
}
}
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 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 = GuildsRequiringDeletedIdsSync;
value = value.getAll();
value.then(function(a0) {
a0.forEach(_fun120419);
});
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 _fun120419(a0) { // fn#120419, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15903:1712, offset: 0x0252af24, size: 19 bytes, params: 2, frame: 11
scheduleGuild(a0);
}
}
}
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 _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 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 channelStoreBinding = ChannelStore;
const getMutableBasicGuildChannelsForGuild = channelStoreBinding.getMutableBasicGuildChannelsForGuild;
const hash = computeHashBinding(Reflect.apply(keys, Object, [Reflect.apply(getMutableBasicGuildChannelsForGuild,
channelStoreBinding, [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 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 value2 = a0.sort();
value = Reflect.apply(Module01225.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 EntityVersionsManager2 = EntityVersionsManager;
Inherits(EntityVersionsManager2, a0);
return CreateClass(EntityVersionsManager2, [{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 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 items2 = [];
arraySpread(items2, value, 0, items2);
value = env1_5(EntityVersionsManager);
binding = env1_4;
if (_isNativeReflectConstruct_120404()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items2, env1_5(this).constructor);
r0 = value;
} else {
value = value.apply(this, items2);
r0 = value;
}
value = binding(this, r0);
value.actions = {GUILD_CREATE: handleGuildCreate_120420, DELETED_ENTITY_IDS: handleDeletedEntityIds};
return value;
}
}
}
global.__d(_fun120403, 15695, [6, 7, 15, 17, 18, 6540, 6583, 1379, 1938, 1867, 4257, 3, 694, 4860, 566, 5234, 1225,
21,
2]) /* metro module 15695, dependencies: [6, 7, 15, 17, 18, 6540, 6583, 1379, 1938, 1867, 4257, 3, 694, 4860, 566, 5234, 1225, 21, 2] */;