decord/source/modules/user_affinities/UserAffinitiesV2Store.tsx

145 lines
4.2 KiB
TypeScript
Raw Normal View History

2026-07-30 10:14:41 +00:00
// Module ID: 5943
// Function ID: 5944
2026-07-29 08:29:29 +00:00
// Name: recomputeAffinities
2026-07-30 10:14:41 +00:00
// Dependencies: [3826, 5944, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-07-30 10:14:41 +00:00
// Module 5943 (recomputeAffinities)
2026-07-29 08:29:29 +00:00
import upsertRelationship from "upsertRelationship";
2026-07-23 10:11:24 +00:00
import { USER_AFFINITY_TTL } from "result";
2026-07-29 08:29:29 +00:00
import { PersistedStore } from "initialize";
2026-07-20 16:05:17 +00:00
function recomputeAffinities() {
const userAffinities = obj.userAffinities;
2026-07-29 08:29:29 +00:00
const found = userAffinities.filter((otherUserId) => !blockedOrIgnored.isBlockedOrIgnored(otherUserId.otherUserId));
2026-07-20 16:05:17 +00:00
const map = new Map(found.map((otherUserId) => {
const items = [otherUserId.otherUserId, otherUserId];
return items;
}));
}
2026-07-23 10:11:24 +00:00
let map = new Map();
2026-07-29 08:29:29 +00:00
let c3 = false;
2026-07-20 16:05:17 +00:00
const frozen = Object.freeze({ userAffinities: [], lastFetched: 0 });
let obj = {};
2026-07-23 10:11:24 +00:00
let merged = Object.assign(frozen);
2026-07-29 08:29:29 +00:00
class UserAffinitiesV2Store extends PersistedStore {
}
const prototype = UserAffinitiesV2Store.prototype;
prototype["initialize"] = function initialize(userAffinities) {
const self = this;
this.waitFor(upsertRelationship);
if (null != userAffinities) {
obj.userAffinities = userAffinities.userAffinities;
obj.lastFetched = userAffinities.lastFetched;
const _Map = Map;
userAffinities = obj.userAffinities;
const found = userAffinities.filter((otherUserId) => !blockedOrIgnored.isBlockedOrIgnored(otherUserId.otherUserId));
const map = new Map(found.map((otherUserId) => {
const items = [otherUserId.otherUserId, otherUserId];
return items;
}));
}
const items = [upsertRelationship];
self.syncWith(items, recomputeAffinities);
};
prototype["shouldFetch"] = function shouldFetch() {
if (!c3) {
const _Date = Date;
return Date.now() - obj.lastFetched > USER_AFFINITY_TTL;
}
};
prototype["isFetching"] = function isFetching() {
return c3;
};
prototype["getUserAffinities"] = function getUserAffinities() {
return obj.userAffinities;
};
prototype["getUserAffinitiesMap"] = function getUserAffinitiesMap() {
return map;
};
prototype["compare"] = function compare(arg0, arg1) {
let value = map.get(arg1);
let num;
if (value != null) {
num = value.communicationProbability;
}
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
value = map.get(arg0);
let num2;
if (value != null) {
num2 = value.communicationProbability;
}
if (num2 == null) {
num2 = 0;
}
return num - num2;
};
prototype["compareByDmProbability"] = function compareByDmProbability(arg0, arg1) {
let value = map.get(arg1);
let num;
if (value != null) {
num = value.dmProbability;
}
if (num == null) {
num = 0;
}
value = map.get(arg0);
let num2;
if (value != null) {
num2 = value.dmProbability;
}
if (num2 == null) {
num2 = 0;
}
return num - num2;
};
prototype["getUserAffinity"] = function getUserAffinity(userId) {
return map.get(userId);
};
prototype["getState"] = function getState() {
return obj;
};
prototype["isHighlyAffinedVCUser"] = function isHighlyAffinedVCUser(arg0) {
const value = map.get(arg0);
let num;
if (value != null) {
num = value.vcProbability;
}
if (num == null) {
num = 0;
}
return num > 0.5;
};
UserAffinitiesV2Store.displayName = "UserAffinitiesV2Store";
UserAffinitiesV2Store.persistKey = "UserAffinitiesStoreV2";
2026-07-20 16:05:17 +00:00
obj = {
LOAD_USER_AFFINITIES_V2: function handleLoadUserAffinities() {
2026-07-29 08:29:29 +00:00
let c3 = true;
2026-07-20 16:05:17 +00:00
},
LOAD_USER_AFFINITIES_V2_SUCCESS: function handleLoadUserAffinitiesSuccess(affineUsers) {
obj.lastFetched = Date.now();
2026-07-29 08:29:29 +00:00
let c3 = false;
2026-07-20 16:05:17 +00:00
obj.userAffinities = affineUsers.affineUsers;
2026-07-29 08:29:29 +00:00
const userAffinities = obj.userAffinities;
const found = userAffinities.filter((otherUserId) => !blockedOrIgnored.isBlockedOrIgnored(otherUserId.otherUserId));
const map = new Map(found.map((otherUserId) => {
const items = [otherUserId.otherUserId, otherUserId];
return items;
}));
2026-07-20 16:05:17 +00:00
},
LOAD_USER_AFFINITIES_V2_FAILURE: function handleLoadUserAffinitiesFailure() {
2026-07-29 08:29:29 +00:00
let c3 = false;
2026-07-20 16:05:17 +00:00
},
LOGOUT: function handleLogout() {
const obj = {};
const merged = Object.assign(frozen);
const map = new Map();
2026-07-29 08:29:29 +00:00
let c3 = false;
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
const userAffinitiesV2Store = new UserAffinitiesV2Store(require("dispatcher"), obj);
const result = require("initialize").fileFinishedImporting("modules/user_affinities/UserAffinitiesV2Store.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default userAffinitiesV2Store;