// Metro module 6073 (f6074). import LurkingStore from "../modules/lurker_mode/LurkingStore"; import UserRecord from "../records/UserRecord"; import ChannelStore from "./ChannelStore"; import UserStore from "./UserStore"; import { ReactionTypes } from "../modules/messages/MessageReactionsTypes"; import Module589 from "../_bundle/Module589"; import { getReactors } from "../modules/reactions/ReactionActionCreators"; import Dispatcher from "../Dispatcher"; let c3853_6, c3853_7; const reactionKey = function reactionKey(a0, item2, item) { const name = item2.name; let id = item2.id; if (id == null) { id = ""; } return `${a0}:${name}:${id}:${item}`; }; const handleReaction = function handleReaction(a0) { const { type, messageId, userId } = a0; const r10 = Reaction.ensure(messageId, a0.emoji, a0.reactionType); if (type === "MESSAGE_REACTION_ADD") { const user = UserStore.getUser(userId); if (user != null) { r10.users.set(userId, user); } } else { r10.users.delete(userId); } }; c3853_6 = {}; c3853_7 = [ReactionTypes.NORMAL, ReactionTypes.BURST]; class Reaction { fetched = false; users = new Map(); static ensure(a0, a1, a2) { const name = a1.name; let id = a1.id; if (id == null) { id = ""; } const r19 = `${a0}:${name}:${id}:${a2}`; let r21 = c3853_6[r19]; if (r21 == null) { const r26 = { __proto__: Reaction.prototype }; r26.fetched = false; r26.users = new Map(); r21 = r26; } c3853_6[r19] = r21; return r21; } } class MessageReactionsStore extends Module589.Store { static displayName = "MessageReactionsStore"; initialize() { this.waitFor(ChannelStore, LurkingStore, UserStore); } getKnownReactorIds(a0, a1) { const set = new Set(); for (const item2 of a1) { for (const item of c3853_7) { const r45 = c3853_6[reactionKey(a0, item2, item)]; if (r45 != null) { for (const item3 of r45.users.keys()) { set.add(item3); } } } } return set; } getReactions(a0, a1, a2, a3, a4) { const r11 = Reaction.ensure(a1, a2, a4); if (!r11.fetched) { const channel = ChannelStore.getChannel(a0); const r7 = channel != null ? channel.getGuildId() : null; if (r7 != null && LurkingStore.isLurking(r7)) { return void 0; } getReactors({ channelId: a0, messageId: a1, emoji: a2, limit: a3, type: a4 }); r11.fetched = true; } return r11.users; } } const messageReactionsStore = new MessageReactionsStore(Dispatcher, { CONNECTION_OPEN: function handleConnectionOpen() { c3853_6 = {}; }, MESSAGE_REACTION_ADD: handleReaction, MESSAGE_REACTION_REMOVE: handleReaction, MESSAGE_REACTION_ADD_USERS: function handleAddUserReactions({ messageId, users, emoji, reactionType }) { let c15460_0 = Reaction.ensure(messageId, emoji, reactionType); users.forEach((user) => c15460_0.users.set(user.id, new UserRecord(user))); } }); export default messageReactionsStore;