decord/source/stores/GuildAvailabilityStore.tsx

96 lines
2.9 KiB
TypeScript
Raw Normal View History

2026-08-05 07:35:12 +00:00
// Module ID: 4592
// Function ID: 4593
2026-07-29 08:29:29 +00:00
// Name: handleConnectionOpen
// Dependencies: [1862, 3, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-05 07:35:12 +00:00
// Module 4592 (handleConnectionOpen)
2026-07-29 08:29:29 +00:00
import createGuildRecordFromRust from "createGuildRecordFromRust";
import { Store } from "initialize";
import set from "initialize";
2026-07-20 16:05:17 +00:00
function handleConnectionOpen(unavailableGuilds) {
const set = new Set(unavailableGuilds.unavailableGuilds);
if (unavailableGuilds.unavailableGuilds.length > 0) {
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
tmp2.warn("" + unavailableGuilds.unavailableGuilds.length + " guilds are unavailable on connection open: " + unavailableGuilds.unavailableGuilds);
2026-07-20 16:05:17 +00:00
}
}
function handleGuild(guild) {
if (set.has(guild.guild.id)) {
set.delete(guild.guild.id);
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
tmp2.info("Guild has become available: " + guild.guild.id);
2026-07-20 16:05:17 +00:00
} else {
return false;
}
}
2026-07-29 08:29:29 +00:00
let closure_1 = new require("dispatcher")("GuildAvailabilityStore");
2026-07-23 10:11:24 +00:00
let set = new Set();
2026-07-29 08:29:29 +00:00
class GuildAvailabilityStore extends Store {
}
const prototype = GuildAvailabilityStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(createGuildRecordFromRust);
};
2026-08-04 08:36:32 +00:00
prototype["isUnavailable"] = function isUnavailable(guildId, token, selected) {
2026-07-29 08:29:29 +00:00
let hasItem = null != guildId;
if (hasItem) {
hasItem = set.has(guildId);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return hasItem;
};
Object.defineProperty(prototype, "totalGuilds", {
get: function totalGuilds() {
return store.getGuildCount() + set.size;
},
set: undefined
});
Object.defineProperty(prototype, "totalUnavailableGuilds", {
get: function totalUnavailableGuilds() {
return set.size;
},
set: undefined
});
Object.defineProperty(prototype, "unavailableGuilds", {
get: function unavailableGuilds() {
return Array.from(set);
},
set: undefined
});
GuildAvailabilityStore.displayName = "GuildAvailabilityStore";
const guildAvailabilityStore = new GuildAvailabilityStore(require("dispatcher"), {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
GUILD_UNAVAILABLE: function handleGuildUnavailable(guildId) {
if (set.has(guildId.guildId)) {
return false;
} else {
2026-07-29 08:29:29 +00:00
const guild = store.getGuild(guildId.guildId);
2026-07-20 16:05:17 +00:00
let str = "???";
if (tmp4) {
str = guild.name;
}
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
tmp2.warn("Guild has gone unavailable: " + guildId.guildId + " (" + str + ")");
2026-07-20 16:05:17 +00:00
set.add(guildId.guildId);
}
},
GUILD_DELETE: function handleGuildDelete(guild) {
if (true !== guild.guild.unavailable) {
set.delete(guild.guild.id);
}
},
GUILD_CREATE: handleGuild,
GUILD_UPDATE: handleGuild,
GUILD_GEO_RESTRICTED: function handleGuildGeoRestrict(guildId) {
if (set.has(guildId.guildId)) {
set.delete(guildId.guildId);
} else {
return false;
}
}
});
2026-07-29 08:29:29 +00:00
const result = set.fileFinishedImporting("stores/GuildAvailabilityStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default guildAvailabilityStore;