decord/alpha/source/modules/stickers/GuildStickersStore.tsx
github-actions 1224ea86fd chore: update source for alpha 348.5
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5021.js (118.4 MB)
2026-09-26 08:31:33 +00:00

229 lines
8.6 KiB
TypeScript

// Module ID: 5815
// Function ID: 5816
// Name: GuildStickersStore
// Dependencies: [32, 2061, 2068, 2067, 5581, 4483, 2071, 2]
// Module 5815 (GuildStickersStore)
import UnicodeEmojisDefault from "UnicodeEmojis" /* 4483 */;
import StickersTypes from "StickersTypes" /* 5581 */;
import _slicedToArray from "module_32" /* 32 */;
import GuildStore from "GuildStore" /* 2067 */;
require = fn;
function parseServerGuildSticker(item10023) {
const obj = { id: item10023.id, tags: item10023.tags, type: item10023.type, name: item10023.name, description: item10023.description, format_type: item10023.format_type, guild_id: item10023.guild_id, available: item10023.available, version: item10023.version, user_id: item10023.user_id };
obj[TypeTag] = "GuildSticker";
return obj;
}
function parseServerGuildStickers(stickers) {
const obj = {};
const iter = stickers[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
obj[nextResult.id] = parseServerGuildSticker(nextResult);
continue;
}
return obj;
}
function deriveStickerMetadata(arg0, tags) {
const items = [];
const obj = { type: items(5581).StickerMetadataTypes.STICKER_NAME, value: null };
const trimmed = tags.name.trim();
obj.value = trimmed.toLocaleLowerCase();
items.push(obj);
if (null != tags.tags) {
const obj2 = { type: tmp(5581).StickerMetadataTypes.TAG, value: null };
const trimmed1 = str.trim();
obj2.value = trimmed1.toLocaleLowerCase();
items.push(obj2);
const guild = GuildStore.getGuild(arg0);
if (null != guild) {
const trimmed2 = guild.name.trim();
const toLocaleLowerCaseResult = trimmed2.toLocaleLowerCase();
let tmp5 = null != toLocaleLowerCaseResult;
if (tmp5) {
tmp5 = "" !== toLocaleLowerCaseResult;
}
if (tmp5) {
const obj3 = { type: tmp(5581).StickerMetadataTypes.GUILD_NAME, value: toLocaleLowerCaseResult };
items.push(obj3);
}
}
const byName = UnicodeEmojisDefault.getByName(str);
if (null != byName) {
const obj4 = { type: tmp(5581).StickerMetadataTypes.CORRELATED_EMOJI, value: byName.surrogates };
items.push(obj4);
byName.forEachDiversity((surrogates) => items.push({ type: StickersTypes.StickerMetadataTypes.CORRELATED_EMOJI, value: surrogates.surrogates }));
}
}
return items;
}
function syncStickers(id, stickers, setPartition) {
if ("full_sync" === stickers.op) {
setPartition.setPartition(id, parseServerGuildStickers(stickers.items));
} else {
const nullablePartition = setPartition.getNullablePartition(id);
if (null == nullablePartition) {
setPartition.setPartition(id, parseServerGuildStickers(stickers.writes));
} else if (stickers.writes.length > 0) {
const obj = {};
const merged = Object.assign(nullablePartition);
const deletes = stickers.deletes;
for (const item10016 of deletes) {
delete tmp[tmp2];
continue;
}
const writes = stickers.writes;
for (const item10023 of writes) {
obj[item10023.id] = parseServerGuildSticker(item10023);
continue;
}
setPartition.setPartition(id, obj);
}
}
}
const TypeTag = fn(2061).TypeTag;
const LibdiscoreStore = fn(2068).LibdiscoreStore;
class GuildStickersStore extends LibdiscoreStore {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
applyArgumentsResult.database = applyArgumentsResult.addKKVDatabase("guildStickers");
database = applyArgumentsResult.database;
applyArgumentsResult.stickerByIdIndex = database.addSecondaryKVIndex("id");
database2 = applyArgumentsResult.database;
applyArgumentsResult.getAllGuildStickers = database2.memoized((obj) => {
const map = new Map();
for (const key10009 in arg0) {
let _Object = Object;
let result = map.set(key10009, Object.values(arg0[key10009].root));
continue;
}
return map;
});
database3 = applyArgumentsResult.database;
applyArgumentsResult.getStickerMetadataMap = database3.memoized((obj) => {
const map = new Map();
for (const key10012 in arg0) {
let _Object = Object;
let entries = Object.entries(arg0[key10012].root);
for (const item10014 of entries) {
let tmp3 = _slicedToArray(item10014, 2);
let result = map.set(tmp3[0], deriveStickerMetadata(key10012, tmp3[1]));
continue;
}
}
return map;
});
database4 = applyArgumentsResult.database;
applyArgumentsResult.getStickersByGuildId = database4.memoizedPartition((arg0, arg1) => Object.values(arg1));
return applyArgumentsResult;
}
}
const prototype = GuildStickersStore.prototype;
prototype["getStickerById"] = function getStickerById(arg0) {
const stickerByIdIndex = this.stickerByIdIndex;
value = stickerByIdIndex.get(arg0);
return value;
};
prototype["stateWrapper"] = function stateWrapper() {
return this.database;
};
GuildStickersStore.displayName = "GuildStickersStore";
const LibdiscoreBatchStoreRefactorExperiment = fn(2071).LibdiscoreBatchStoreRefactorExperiment;
const guildStickersStore = new GuildStickersStore({
LOGOUT(arg0, clear) {
return clear.clear();
},
BACKGROUND_SYNC(arg0, clear) {
return clear.clear();
},
RESET_SOCKET(arg0, clear) {
return clear.clear();
},
CONNECTION_OPEN(arg0, getPartitionKeys) {
({ guilds, unavailableGuilds } = arg0);
const set = new Set(guilds.map((id) => id.id));
for (const item10017 of unavailableGuilds) {
let addResult = set.add(item10017);
continue;
}
const partitionKeys = getPartitionKeys.getPartitionKeys();
for (const item10028 of partitionKeys) {
let tmp3 = item10028;
if (!set.has(item10028)) {
let removePartitionResult = arg1.removePartition(tmp3);
}
continue;
}
const iter = guilds[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp8 = syncStickers(nextResult.id, nextResult.stickers, getPartitionKeys);
continue;
}
},
GUILD_CREATE(guild, setPartition) {
if (null == guild.guild.joined_at) {
return false;
} else {
syncStickers(guild.guild.id, guild.guild.stickers, setPartition);
}
},
GUILD_DELETE(guild, removePartition) {
removePartition.removePartition(guild.guild.id);
},
GUILD_STICKERS_CREATE_SUCCESS(sticker, setRecord) {
sticker = sticker.sticker;
const obj = { id: sticker.id, tags: sticker.tags, type: sticker.type, name: sticker.name, description: sticker.description, format_type: sticker.format_type, guild_id: sticker.guild_id, available: sticker.available, version: sticker.version, user_id: sticker.user_id };
obj[TypeTag] = "GuildSticker";
setRecord.setRecord(sticker.guildId, sticker.sticker.id, obj);
},
GUILD_STICKER_FETCH_SUCCESS(sticker, setRecord) {
sticker = sticker.sticker;
const obj = { id: sticker.id, tags: sticker.tags, type: sticker.type, name: sticker.name, description: sticker.description, format_type: sticker.format_type, guild_id: sticker.guild_id, available: sticker.available, version: sticker.version, user_id: sticker.user_id };
obj[TypeTag] = "GuildSticker";
setRecord.setRecord(sticker.sticker.guild_id, sticker.sticker.id, obj);
},
GUILD_STICKERS_UPDATE(guildId, getPartition) {
const partition = getPartition.getPartition(guildId.guildId);
const tmp2 = parseServerGuildStickers(guildId.stickers);
if (null != partition) {
for (const key10012 in tmp2) {
let tmp10 = tmp2[key10012];
let tmp11 = partition[key10012];
let tmp4 = null != tmp11;
if (tmp4) {
tmp4 = null == tmp10.user_id;
}
if (tmp4) {
tmp4 = null != tmp11.user_id;
}
if (!tmp4) {
continue;
} else {
let obj = {};
let merged = Object.assign(tmp10);
obj.user_id = tmp11.user_id;
tmp2[key10012] = obj;
continue;
}
continue;
}
}
getPartition.setPartition(guildId.guildId, tmp2);
},
CACHED_STICKERS_LOADED(arg0, setPartition) {
while (tmp !== undefined) {
let tmp4 = _slicedToArray(tmp2, 2);
let setPartitionResult = setPartition.setPartition(tmp4[0], parseServerGuildStickers(tmp4[1]));
continue;
}
},
GUILD_STICKERS_FETCH_SUCCESS(guildId, setPartition) {
setPartition.setPartition(guildId.guildId, parseServerGuildStickers(guildId.stickers));
}
}, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
const size = fn(2);
let result = size.fileFinishedImporting("modules/stickers/GuildStickersStore.tsx");
export default guildStickersStore;