// Metro module 5945 (f5946). import RelationshipStore from "../../stores/RelationshipStore"; import { USER_AFFINITY_TTL } from "./UserAffinitiesConstants"; import Module589 from "../../_bundle/Module589"; import Dispatcher from "../../Dispatcher"; function $mk77508() { return (a0) => [a0.otherUserId, a0]; } let c3739_2, c3739_3, c3739_4, c3739_5, $mk77507 = function() { return (a0) => !RelationshipStore.isBlockedOrIgnored(a0.otherUserId); }; const recomputeAffinities = function recomputeAffinities() { c3739_2 = new Map(c3739_5.userAffinities.filter($mk77507()).map($mk77508())); }; c3739_2 = new Map(); c3739_3 = false; c3739_4 = Object.freeze({ userAffinities: [], lastFetched: 0 }); c3739_5 = { ...c3739_4 }; class UserAffinitiesV2Store extends Module589.PersistedStore { static displayName = "UserAffinitiesV2Store"; static persistKey = "UserAffinitiesStoreV2"; initialize(a0) { this.waitFor(RelationshipStore); if (a0 != null) { c3739_5.userAffinities = a0.userAffinities; c3739_5.lastFetched = a0.lastFetched; c3739_2 = new Map(c3739_5.userAffinities.filter($mk77507()).map($mk77508())); } this.syncWith([RelationshipStore], recomputeAffinities); } shouldFetch() { if (c3739_3) { return void 0; } return Date.now() - c3739_5.lastFetched > USER_AFFINITY_TTL; } isFetching() { return c3739_3; } getUserAffinities() { return c3739_5.userAffinities; } getUserAffinitiesMap() { return c3739_2; } compare(a0, a1) { let r9 = c3739_2.get(a1)?.communicationProbability; if (r9 == null) { r9 = 0; } let r14 = c3739_2.get(a0)?.communicationProbability; if (r14 == null) { r14 = 0; } return r9 - r14; } compareByDmProbability(a0, a1) { let r9 = c3739_2.get(a1)?.dmProbability; if (r9 == null) { r9 = 0; } let r14 = c3739_2.get(a0)?.dmProbability; if (r14 == null) { r14 = 0; } return r9 - r14; } getUserAffinity(a0) { return c3739_2.get(a0); } getState() { return c3739_5; } isHighlyAffinedVCUser(a0) { let r8 = c3739_2.get(a0)?.vcProbability; if (r8 == null) { r8 = 0; } return r8 > 0.5; } } const userAffinitiesV2Store = new UserAffinitiesV2Store(Dispatcher, { LOAD_USER_AFFINITIES_V2: function handleLoadUserAffinities() { c3739_3 = true; }, LOAD_USER_AFFINITIES_V2_SUCCESS: function handleLoadUserAffinitiesSuccess({ affineUsers }) { c3739_5.lastFetched = Date.now(); c3739_3 = false; c3739_5.userAffinities = affineUsers; c3739_2 = new Map(c3739_5.userAffinities.filter($mk77507()).map($mk77508())); }, LOAD_USER_AFFINITIES_V2_FAILURE: function handleLoadUserAffinitiesFailure() { c3739_3 = false; }, LOGOUT: function handleLogout() { c3739_5 = { ...c3739_4 }; c3739_2 = new Map(); c3739_3 = false; } }); export default userAffinitiesV2Store;