151 lines
5.2 KiB
TypeScript
151 lines
5.2 KiB
TypeScript
// Metro module 16165 (f16166).
|
|
import EmojiStore from "../emojis/EmojiStore";
|
|
import StickersStore from "../stickers/StickersStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildRoleStore from "../../stores/GuildRoleStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import "./GatewayConnectionStore";
|
|
import Logger from "../debug/Logger";
|
|
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import GuildsRequiringDeletedIdsSync from "../app_database/modules/GuildsRequiringDeletedIdsSync";
|
|
import SnowflakeUtils from "../../utils/SnowflakeUtils";
|
|
function $mk98825($env) {
|
|
return () => {
|
|
const r9 = $env[0];
|
|
const r21 = $env.$parent;
|
|
r21[8].fileOnly(`requesting deleted guild entities (id: ${r9}, name: ${r21[6].getGuild(r9)?.name})`);
|
|
const r10 = Object.keys(r21[4].getMutableBasicGuildChannelsForGuild(r9));
|
|
const r32 = r21[0];
|
|
const r33 = r21[1];
|
|
const r43 = r32(r33[11]).v3(r10.sort().join(",")).toString();
|
|
const r49 = r21[5].getSortedRoles(r9).map((item) => item.id);
|
|
const r59 = r32(r33[11]).v3(r49.sort().join(",")).toString();
|
|
const r13 = r21[2].getGuildEmoji(r9).map((item) => item.id);
|
|
const r74 = r32(r33[11]).v3(r13.sort().join(",")).toString();
|
|
const stickersByGuildId = r21[3].getStickersByGuildId(r9);
|
|
let r78 = stickersByGuildId == null ? void 0 : stickersByGuildId.map((item) => item.id);
|
|
if (r78 == null) {
|
|
r78 = [];
|
|
}
|
|
const r15 = r32(r33[11]).v3(r78.sort().join(",")).toString();
|
|
r21[7].getSocket().getDeletedEntityIdsNotMatchingHash(r9, r43, r59, r74, r15);
|
|
};
|
|
}
|
|
let handleConnectionOpen, handleGuildCreate, c11583_8, c11583_12;
|
|
let env11583 = {};
|
|
const handleDeletedEntityIds = function handleDeletedEntityIds(a0) {
|
|
c11583_8.fileOnly(`received deleted guild entities (id: ${a0.guild_id}, name: ${GuildStore.getGuild(a0.guild_id)?.name})`);
|
|
Module589.Emitter.batched(() => {
|
|
if (a0.channels != null) {
|
|
const guild_id3 = a0.guild_id;
|
|
const set = new Set(a0.channels);
|
|
const guild_id = guild_id3;
|
|
let c28247_1 = set;
|
|
const channelIdsInMemory = SnowflakeUtils.keys(ChannelStore.getMutableBasicGuildChannelsForGuild(guild_id));
|
|
c11583_8.fileOnly("syncChannels", {
|
|
channelIdsInMemory,
|
|
channelIdsFromServer: set
|
|
});
|
|
channelIdsInMemory.forEach((item) => {
|
|
if (!c28247_1.has(item)) {
|
|
Dispatcher.dispatch({
|
|
type: "CHANNEL_DELETE",
|
|
channel: {
|
|
guild_id,
|
|
id: item,
|
|
parent_id: void 0
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
if (a0.roles != null) {
|
|
const guild_id4 = a0.guild_id;
|
|
const set2 = new Set(a0.roles);
|
|
const guild_id2 = guild_id4;
|
|
let c28248_1 = set2;
|
|
SnowflakeUtils.keys(GuildRoleStore.getUnsafeMutableRoles(guild_id2)).forEach((item) => {
|
|
if (!c28248_1.has(item)) {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_ROLE_DELETE",
|
|
guildId: guild_id2,
|
|
roleId: item
|
|
});
|
|
}
|
|
});
|
|
}
|
|
if (a0.emojis != null) {
|
|
const guild_id5 = a0.guild_id;
|
|
let c28249_0 = new Set(a0.emojis);
|
|
const guildEmoji = EmojiStore.getGuildEmoji(guild_id5);
|
|
const emojis = guildEmoji.filter((item) => c28249_0.has(item.id));
|
|
if (guildEmoji.length !== emojis.length) {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_EMOJIS_UPDATE",
|
|
guildId: guild_id5,
|
|
emojis
|
|
});
|
|
}
|
|
}
|
|
if (a0.stickers != null) {
|
|
const guild_id6 = a0.guild_id;
|
|
let c28250_0 = new Set(a0.stickers);
|
|
let r97 = StickersStore.getStickersByGuildId(guild_id6);
|
|
if (r97 == null) {
|
|
r97 = [];
|
|
}
|
|
const stickers = r97.filter((item) => c28250_0.has(item.id));
|
|
if (r97.length !== stickers.length) {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_STICKERS_UPDATE",
|
|
guildId: guild_id6,
|
|
stickers
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
handleConnectionOpen = function handleConnectionOpen() {
|
|
GuildsRequiringDeletedIdsSync.getAll().then((result) => {
|
|
result.forEach((item) => {
|
|
let env30967;
|
|
const r2 = env30967 = {
|
|
$parent: env11583
|
|
};
|
|
env30967[0] = item;
|
|
const r11 = Math.ceil(2000 * Math.random());
|
|
setTimeout($mk98825(r2), r11);
|
|
});
|
|
});
|
|
};
|
|
handleGuildCreate = function handleGuildCreate({ guild }) {
|
|
if (guild.unableToSyncDeletes) {
|
|
let env22834;
|
|
const id = guild.id;
|
|
const r10 = env22834 = {
|
|
$parent: env11583
|
|
};
|
|
env22834[0] = id;
|
|
const r14 = Math.ceil(2000 * Math.random());
|
|
setTimeout($mk98825(r10), r14);
|
|
}
|
|
};
|
|
c11583_8 = new Logger("EntityVersionsManager");
|
|
class EntityVersionsManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
GUILD_CREATE: handleGuildCreate,
|
|
DELETED_ENTITY_IDS: handleDeletedEntityIds
|
|
};
|
|
_initialize() {
|
|
Dispatcher.subscribe("CONNECTION_OPEN", handleConnectionOpen);
|
|
}
|
|
_terminate() {
|
|
Dispatcher.unsubscribe("CONNECTION_OPEN", handleConnectionOpen);
|
|
}
|
|
}
|
|
c11583_12 = EntityVersionsManager;
|
|
const r45 = new EntityVersionsManager();
|
|
export default r45;
|