decord/alpha/source/stores/GuildStore.tsx

298 lines
9.6 KiB
TypeScript
Raw Normal View History

2026-10-08 09:57:35 +00:00
// Module ID: 2086
// Function ID: 2087
// Name: GuildStore
2026-10-08 09:57:35 +00:00
// Dependencies: [2079, 2087, 2082, 502, 2077, 2081, 2089, 11, 2078, 559, 2]
2026-07-20 16:05:17 +00:00
2026-10-08 09:57:35 +00:00
// Module 2086 (GuildStore)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
2026-10-03 08:58:59 +00:00
import libdiscoreExperiments from "libdiscoreExperiments" /* 559 */;
2026-10-08 09:57:35 +00:00
import FavoritesConstants from "FavoritesConstants" /* 2077 */;
import GuildRecordUtilsAll from "GuildRecordUtils" /* 2078 */;
import SetUtils from "SetUtils" /* 2081 */;
import LibdiscoreStore2 from "LibdiscoreStore" /* 2087 */;
import FavoritesUtils from "FavoritesUtils" /* 2089 */;
import PlainRecord from "PlainRecord" /* 2079 */;
import GuildRecord from "GuildRecord" /* 2082 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let set;
let closure_4;
let hasOwnProperty;
let metroImportAll;
let metroImportDefault;
let metroRequire;
2026-07-20 16:05:17 +00:00
function createGuildRecordFromRust(features) {
2026-10-03 08:58:59 +00:00
let date;
let date1;
let obj2;
const obj = { features: obj2.toSetInplace(features.features), joinedAt: date, premiumProgressBarEnabledUserUpdatedAt: date1 };
2026-07-20 16:05:17 +00:00
const merged = Object.assign(features);
2026-10-03 08:58:59 +00:00
date = null;
obj2 = SetUtils;
const tmp = React3;
const tmp2 = metroRequire;
2026-07-20 16:05:17 +00:00
if (null != features.joinedAt) {
const _Date = Date;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-07-20 16:05:17 +00:00
date = new Date(features.joinedAt);
}
2026-10-03 08:58:59 +00:00
date1 = null;
2026-07-20 16:05:17 +00:00
if (null != features.premiumProgressBarEnabledUserUpdatedAt) {
const _Date2 = Date;
2026-10-03 08:58:59 +00:00
const self3 = this;
const self4 = this;
2026-07-20 16:05:17 +00:00
date1 = new Date(features.premiumProgressBarEnabledUserUpdatedAt);
}
2026-10-03 08:58:59 +00:00
return tmp(tmp2, obj);
2026-07-20 16:05:17 +00:00
}
({ constructInPlace: closure_4, set: hasOwnProperty } = PlainRecord);
const LibdiscoreStore = LibdiscoreStore2.LibdiscoreStore;
2026-10-03 08:58:59 +00:00
({ GuildRecordTypeTag: metroRequire, updateJoinedAt: metroImportDefault, updateGameApplications: metroImportAll } = GuildRecord);
const FAVORITES_GUILD_RECORD = FavoritesConstants.FAVORITES_GUILD_RECORD;
2026-07-29 08:29:29 +00:00
class GuildStore extends LibdiscoreStore {
constructor() {
2026-10-03 08:58:59 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
require = applyArgumentsResult;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.database = applyArgumentsResult.addKVDatabase("guilds", createGuildRecordFromRust);
applyArgumentsResult.getGuild = function getGuild(guildId) {
if (null != guildId) {
2026-10-03 08:58:59 +00:00
let value;
const obj = FavoritesUtils;
2026-07-29 08:29:29 +00:00
if (obj.isFavoritesGuildId(guildId)) {
value = FAVORITES_GUILD_RECORD;
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const database = require.database;
2026-07-29 08:29:29 +00:00
value = database.get(guildId);
}
return value;
}
};
2026-10-03 08:58:59 +00:00
let database = applyArgumentsResult.database;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.getGuilds = database.memoized((arg0) => {
2026-10-03 08:58:59 +00:00
const obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(arg0);
2026-10-03 08:58:59 +00:00
return obj;
2026-07-29 08:29:29 +00:00
});
2026-10-03 08:58:59 +00:00
const database2 = applyArgumentsResult.database;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.getGuildsArray = database2.memoized((arg0) => Object.values(arg0));
2026-10-03 08:58:59 +00:00
const database3 = applyArgumentsResult.database;
applyArgumentsResult.getGuildIds = database3.memoized((arg0) => {
const obj = SnowflakeUtilsDefault;
return obj.keys(arg0);
});
2026-07-29 08:29:29 +00:00
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
stateWrapper() {
return this.database;
}
getGuildCount() {
const database = this.database;
return database.length();
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = GuildStore.prototype;
GuildStore.displayName = "GuildStore";
2026-10-03 08:58:59 +00:00
let obj = {
2026-07-29 08:29:29 +00:00
BACKGROUND_SYNC(arg0, get) {
const iter = arg0.guilds[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
2026-10-03 08:58:59 +00:00
let value = get.get(nextResult.id);
2026-07-29 08:29:29 +00:00
let tmp5 = null != value;
let tmp4 = value;
if (tmp5) {
tmp5 = "unavailable" !== tmp2.data_mode;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-10-03 08:58:59 +00:00
set = get.set;
let id = tmp2.id;
let obj = GuildRecordUtilsAll;
2026-10-03 08:58:59 +00:00
let result = set(id, obj.fromBackgroundSync(tmp2, tmp4));
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
},
LOGOUT(arg0, clear) {
clear.clear();
},
RESET_SOCKET(arg0, clear) {
clear.clear();
},
CONNECTION_OPEN(arg0, getAllRecords) {
2026-10-03 08:58:59 +00:00
let guilds;
let unavailableGuilds;
2026-07-20 16:05:17 +00:00
({ guilds, unavailableGuilds } = arg0);
const allRecords = getAllRecords.getAllRecords();
2026-10-03 08:58:59 +00:00
const set1 = new Set(Object.keys(allRecords));
2026-07-29 08:29:29 +00:00
const iter = guilds[Symbol.iterator]();
const nextResult = iter.next();
2026-10-03 08:58:59 +00:00
const tmp2 = set1;
2026-07-29 08:29:29 +00:00
while (iter !== undefined) {
let tmp4 = nextResult;
2026-10-03 08:58:59 +00:00
let deleteResult = set1.delete(nextResult.id);
2026-07-29 08:29:29 +00:00
if (null == nextResult.properties) {
if (null == allRecords[tmp4.id]) {
let _Error = Error;
2026-10-03 08:58:59 +00:00
let self = this;
2026-07-29 08:29:29 +00:00
let str = "Guild data was missing from store, but hash was still available.";
2026-10-03 08:58:59 +00:00
let self2 = this;
let error = new Error("Guild data was missing from store, but hash was still available.");
2026-07-29 08:29:29 +00:00
throw error;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
set = getAllRecords.set;
let id = tmp4.id;
let obj2 = GuildRecordUtilsAll;
2026-10-03 08:58:59 +00:00
let result = set(id, obj2.fromServer(tmp4, allRecords[tmp4.id]));
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
for (const item10053 of unavailableGuilds) {
2026-10-03 08:58:59 +00:00
let deleteResult1 = set1.delete(item10053);
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
for (const item10061 of tmp2) {
let removeResult = getAllRecords.remove(item10061);
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
},
OVERLAY_INITIALIZE(guilds, clear) {
2026-10-03 08:58:59 +00:00
let additionalFields;
let properties;
2026-07-20 16:05:17 +00:00
guilds = guilds.guilds;
clear.clear();
if (null != guilds) {
2026-07-29 08:29:29 +00:00
const iter = guilds[Symbol.iterator]();
2026-10-03 08:58:59 +00:00
const nextResult = iter.next();
2026-07-29 08:29:29 +00:00
while (iter !== undefined) {
({ properties, additionalFields } = nextResult);
let tmp5 = additionalFields;
2026-10-03 08:58:59 +00:00
set = clear.set;
let id = properties.id;
let tmp8 = GuildRecordUtilsAll;
2026-07-29 08:29:29 +00:00
let date = null;
2026-10-03 08:58:59 +00:00
let fromGuildPropertiesWithAdditionalFields = tmp8.fromGuildPropertiesWithAdditionalFields;
2026-07-29 08:29:29 +00:00
if (null != additionalFields.joinedAt) {
let _Date = Date;
2026-10-03 08:58:59 +00:00
let self = this;
let self2 = this;
2026-07-29 08:29:29 +00:00
date = new Date(tmp5.joinedAt);
}
2026-10-03 08:58:59 +00:00
let obj = { joinedAt: date, premiumSubscriberCount: tmp5.premiumSubscriberCount };
let result = set(id, fromGuildPropertiesWithAdditionalFields(properties, obj));
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
}
},
2026-10-03 08:58:59 +00:00
CACHE_LOADED(guilds, clear) {
guilds = guilds.guilds;
2026-07-20 16:05:17 +00:00
clear.clear();
2026-10-03 08:58:59 +00:00
for (const item10009 of guilds) {
set = clear.set;
let id = item10009.id;
let obj = GuildRecordUtilsAll;
2026-10-03 08:58:59 +00:00
let result = set(id, obj.fromSerializedGuildRecord(item10009));
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
},
CACHE_LOADED_LAZY(guilds, clear) {
guilds = guilds.guilds;
if (0 !== guilds.length) {
clear.clear();
2026-07-29 08:29:29 +00:00
for (const item10011 of guilds) {
2026-10-03 08:58:59 +00:00
set = clear.set;
let id = item10011.id;
let obj = GuildRecordUtilsAll;
2026-10-03 08:58:59 +00:00
let result = set(id, obj.fromSerializedGuildRecord(item10011));
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
}
},
GUILD_CREATE(guild, get) {
guild = guild.guild;
2026-10-03 08:58:59 +00:00
const value = get.get(guild.id);
2026-07-20 16:05:17 +00:00
if (null == guild.properties) {
if (null == value) {
const _Error = Error;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
const error = new Error("Guild data was missing from store, but hash was still available.");
2026-07-20 16:05:17 +00:00
throw error;
}
}
2026-10-03 08:58:59 +00:00
const id = guild.id;
set = get.set;
const obj = GuildRecordUtilsAll;
const result = set(id, obj.fromServer(guild, value));
2026-07-20 16:05:17 +00:00
},
GUILD_UPDATE(guild, get) {
guild = guild.guild;
2026-10-03 08:58:59 +00:00
const value = get.get(guild.id);
const id = guild.id;
set = get.set;
const obj = GuildRecordUtilsAll;
const result = set(id, obj.fromGuild(guild, value));
2026-07-20 16:05:17 +00:00
},
GUILD_THEME_PREVIEW_SAVE_SUCCESS(guildId, get) {
2026-07-29 08:29:29 +00:00
guildId = guildId.guildId;
2026-10-03 08:58:59 +00:00
const guildTheme = guildId.guildTheme;
const value = get.get(guildId);
2026-07-29 08:29:29 +00:00
if (null != value) {
2026-10-03 08:58:59 +00:00
const result = get.set(guildId, hasOwnProperty(value, "guildTheme", guildTheme));
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
},
GUILD_SETTINGS_GUILD_THEME_SAVE_SUCCESS(guildId, get) {
2026-07-29 08:29:29 +00:00
guildId = guildId.guildId;
2026-10-03 08:58:59 +00:00
const guildTheme = guildId.guildTheme;
const value = get.get(guildId);
2026-07-29 08:29:29 +00:00
if (null != value) {
2026-10-03 08:58:59 +00:00
const result = get.set(guildId, hasOwnProperty(value, "guildTheme", guildTheme));
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
},
GUILD_DELETE(guild, remove) {
guild = guild.guild;
if (!guild.unavailable) {
remove.remove(guild.id);
}
},
GUILD_MEMBER_ADD(user, get) {
2026-10-03 08:58:59 +00:00
let guildId;
let joinedAt;
2026-07-20 16:05:17 +00:00
({ guildId, joinedAt } = user);
2026-10-03 08:58:59 +00:00
user = user.user;
const id = AuthenticationStore.getId();
2026-10-03 08:58:59 +00:00
const value = get.get(guildId);
if (id === user.id) {
2026-07-20 16:05:17 +00:00
if (null != value) {
let date = joinedAt;
2026-08-04 21:03:28 +00:00
if (typeof joinedAt === "string") {
2026-07-20 16:05:17 +00:00
const _Date = Date;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-07-20 16:05:17 +00:00
date = new Date(joinedAt);
}
2026-10-03 08:58:59 +00:00
const tmp5 = date !== value.joinedAt && null != date;
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-10-03 08:58:59 +00:00
const result = get.set(guildId, metroImportDefault(value, date));
2026-07-20 16:05:17 +00:00
}
}
}
},
2026-07-29 08:29:29 +00:00
GUILD_OFFICIAL_GAME_APPLICATIONS_UPDATE(guildId, get) {
guildId = guildId.guildId;
2026-10-03 08:58:59 +00:00
const gameApplicationIds = guildId.gameApplicationIds;
const value = get.get(guildId);
2026-07-20 16:05:17 +00:00
if (null != value) {
2026-10-03 08:58:59 +00:00
const result = get.set(guildId, metroImportAll(value, gameApplicationIds));
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
};
const LibdiscoreBatchStoreRefactorExperiment = libdiscoreExperiments.LibdiscoreBatchStoreRefactorExperiment;
const guildStore = new GuildStore(obj, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
let result = size.fileFinishedImporting("stores/GuildStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default guildStore;