68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
// Metro module 4527 (f4528).
|
|
import GuildStore from "./GuildStore";
|
|
import Logger from "../modules/debug/Logger";
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
let c2734_1, c2734_2;
|
|
const handleConnectionOpen = function handleConnectionOpen(a0) {
|
|
c2734_2 = new Set(a0.unavailableGuilds);
|
|
if (a0.unavailableGuilds.length > 0) {
|
|
c2734_1.warn(`${a0.unavailableGuilds.length} guilds are unavailable on connection open: ${a0.unavailableGuilds}`);
|
|
}
|
|
};
|
|
const handleGuild = function handleGuild(a0) {
|
|
if (c2734_2.has(a0.guild.id)) {
|
|
c2734_2.delete(a0.guild.id);
|
|
c2734_1.info(`Guild has become available: ${a0.guild.id}`);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
};
|
|
c2734_1 = new Logger("GuildAvailabilityStore");
|
|
c2734_2 = new Set();
|
|
class GuildAvailabilityStore extends Module589.Store {
|
|
static displayName = "GuildAvailabilityStore";
|
|
initialize() {
|
|
this.waitFor(GuildStore);
|
|
}
|
|
isUnavailable(a0) {
|
|
return a0 != null && c2734_2.has(a0);
|
|
}
|
|
get totalGuilds() {
|
|
return GuildStore.getGuildCount() + c2734_2.size;
|
|
}
|
|
get totalUnavailableGuilds() {
|
|
return c2734_2.size;
|
|
}
|
|
get unavailableGuilds() {
|
|
return Array.from(c2734_2);
|
|
}
|
|
}
|
|
const guildAvailabilityStore = new GuildAvailabilityStore(Dispatcher, {
|
|
CONNECTION_OPEN: handleConnectionOpen,
|
|
OVERLAY_INITIALIZE: handleConnectionOpen,
|
|
GUILD_UNAVAILABLE: function handleGuildUnavailable(a0) {
|
|
if (c2734_2.has(a0.guildId)) {
|
|
return false;
|
|
}
|
|
const guild = GuildStore.getGuild(a0.guildId);
|
|
c2734_1.warn(`Guild has gone unavailable: ${a0.guildId} (${guild != null && guild.name != null ? guild.name : "???"})`);
|
|
c2734_2.add(a0.guildId);
|
|
},
|
|
GUILD_DELETE: function handleGuildDelete(a0) {
|
|
if (a0.guild.unavailable !== true) {
|
|
c2734_2.delete(a0.guild.id);
|
|
}
|
|
},
|
|
GUILD_CREATE: handleGuild,
|
|
GUILD_UPDATE: handleGuild,
|
|
GUILD_GEO_RESTRICTED: function handleGuildGeoRestrict(a0) {
|
|
if (c2734_2.has(a0.guildId)) {
|
|
c2734_2.delete(a0.guildId);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
export default guildAvailabilityStore;
|