// Metro module 5944 (f5945). import RelationshipStore from "../../stores/RelationshipStore"; import { RelationshipTypes } from "../../Constants"; import { SecondaryIndexMap } from "../../_bundle/Module3813"; import Module589 from "../../_bundle/Module589"; import Dispatcher from "../../Dispatcher"; function $mk77503($env) { return (a0) => { L9: { const r3 = $env; const { type, id } = a0; const r9 = $env.$parent; const r5 = r9[1]; if (type === r5.FRIEND) { r3[2] = r3[2] + 1; } else if (type === r5.PENDING_OUTGOING) { r3[1] = r3[1] + 1; } else if (type === r5.PENDING_INCOMING) { const r12 = r9[0]; if (!r12.isSpam(id) && !r12.isIgnored(id)) { r3[0] = r3[0] + 1; break L9; } return void 0; } } }; } let remove, GAME_RELATIONSHIP_KEY, GameRelationshipIndexes_BY_APPLICATION_ID, GameRelationshipIndexes_BY_USER_ID, GameRelationshipIndexes_BY_RELATIONSHIP_TYPE, c3738_6, c3738_12; let env3738 = {}; const recountRelationshipTypes = function recountRelationshipTypes() { let env15313; const r3 = env15313 = { $parent: env3738 }; env15313[0] = 0; env15313[1] = 0; env15313[2] = 0; c3738_6.values().forEach($mk77503(r3)); env3738[7] = env15313[0]; env3738[8] = env15313[1]; env3738[9] = env15313[2]; }; remove = function remove(a0, a1) { c3738_6.delete(`${a1}-${a0}`); }; GAME_RELATIONSHIP_KEY = (a0, a1) => {}; GameRelationshipIndexes_BY_APPLICATION_ID = (a0) => `application-id-${a0}`; GameRelationshipIndexes_BY_USER_ID = (a0) => {}; GameRelationshipIndexes_BY_RELATIONSHIP_TYPE = (a0) => {}; c3738_6 = new SecondaryIndexMap(function gameRelationshipsIndex(a0) { const r0 = []; r0.push(`application-id-${a0.applicationId}`); r0.push(`user-id-${a0.id}`); r0.push(`relationship-type-${a0.type}`); return r0; }, (a0) => `${a0.since}`); env3738[7] = 0; env3738[8] = 0; env3738[9] = 0; class GameRelationshipStore extends Module589.Store { static displayName = "GameRelationshipStore"; constructor() { super(...arguments); } initialize() { this.waitFor(RelationshipStore); } getPendingIncomingCount() { return env3738[7]; } getPendingOutgoingCount() { return env3738[8]; } getGameFriendCount() { return env3738[9]; } getGameFriendsForApplication(a0) { return c3738_6.values(`application-id-${a0}`, true).filter((item) => item.type === RelationshipTypes.FRIEND); } getGameRelationshipsForUser(a0) { return c3738_6.values(`user-id-${a0}`, true); } getGameRelationshipsForUserByType(a0, c15314_0) { return this.getGameRelationshipsForUser(a0).filter((item) => item.type === c15314_0); } getGameFriendsForUser(a0) { return this.getGameRelationshipsForUserByType(a0, RelationshipTypes.FRIEND); } getGameRelationshipCount() { return c3738_6.size(); } getGameRelationships() { return c3738_6; } getGameRelationshipsByType(a0) { return c3738_6.values(`relationship-type-${a0}`, true); } getGameRelationshipsVersion() { return c3738_6.version; } } c3738_12 = GameRelationshipStore; const r74 = new GameRelationshipStore(Dispatcher, { CONNECTION_OPEN: function handleConnectionOpen(a0) { let env15315; c3738_6.clear(); a0.gameRelationships.forEach((gameRelationship) => { const r4 = { id: gameRelationship.id, applicationId: gameRelationship.application_id, type: gameRelationship.type, since: gameRelationship.since, dmAccessType: gameRelationship.dm_access_type }; c3738_6.set(`${r4.applicationId}-${r4.id}`, r4); }); const r11 = env15315 = { $parent: env3738 }; env15315[0] = 0; env15315[1] = 0; env15315[2] = 0; c3738_6.values().forEach($mk77503(r11)); env3738[7] = env15315[0]; env3738[8] = env15315[1]; env3738[9] = env15315[2]; }, GAME_RELATIONSHIP_ADD: function handleGameRelationshipAdd({ gameRelationship }) { const { id, applicationId } = gameRelationship; let env15316; c3738_6.set(`${applicationId}-${id}`, gameRelationship); const r21 = env15316 = { $parent: env3738 }; env15316[0] = 0; env15316[1] = 0; env15316[2] = 0; c3738_6.values().forEach($mk77503(r21)); env3738[7] = env15316[0]; env3738[8] = env15316[1]; env3738[9] = env15316[2]; }, GAME_RELATIONSHIP_REMOVE: function handleGameRelationshipRemove({ userId, applicationId }) { let env15317; c3738_6.delete(`${applicationId}-${userId}`); const r20 = env15317 = { $parent: env3738 }; env15317[0] = 0; env15317[1] = 0; env15317[2] = 0; c3738_6.values().forEach($mk77503(r20)); env3738[7] = env15317[0]; env3738[8] = env15317[1]; env3738[9] = env15317[2]; }, APPLICATIONS_FETCH_SUCCESS: function handleApplicationsFetchSuccess({ unknownApplicationIds }) { if (unknownApplicationIds != null) { for (const item of unknownApplicationIds) { for (const item2 of c3738_6.values(GameRelationshipIndexes_BY_APPLICATION_ID(item))) { if (!(item2.type !== RelationshipTypes.PENDING_INCOMING && item2.type !== RelationshipTypes.PENDING_OUTGOING)) { remove(item2.id, item); } } } recountRelationshipTypes(); } } }); export default r74;