decord/source/modules/user_affinities/UserAffinitiesV2Store.tsx

147 lines
4.3 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 5412
// Function ID: 5413
2026-07-29 08:29:29 +00:00
// Name: recomputeAffinities
2026-08-24 06:08:38 +00:00
// Dependencies: [4033, 5413, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
// Module 5412 (recomputeAffinities)
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_0 from "markAllUserIdListsStale" /* 4033 */;
import { USER_AFFINITY_TTL } from "result" /* 5413 */;
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-08-24 06:08:38 +00:00
map = new Map(found.map((otherUserId) => {
2026-07-20 16:05:17 +00:00
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-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class UserAffinitiesV2Store extends PersistedStore {
}
const prototype = UserAffinitiesV2Store.prototype;
prototype["initialize"] = function initialize(userAffinities) {
const self = this;
2026-08-24 06:08:38 +00:00
this.waitFor(closure_0);
2026-07-29 08:29:29 +00:00
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));
2026-08-24 06:08:38 +00:00
map = new Map(found.map((otherUserId) => {
2026-07-29 08:29:29 +00:00
const items = [otherUserId.otherUserId, otherUserId];
return items;
}));
}
2026-08-24 06:08:38 +00:00
const items = [closure_0];
2026-07-29 08:29:29 +00:00
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-08-24 06:08:38 +00:00
c3 = true;
2026-07-20 16:05:17 +00:00
},
LOAD_USER_AFFINITIES_V2_SUCCESS: function handleLoadUserAffinitiesSuccess(affineUsers) {
obj.lastFetched = Date.now();
2026-08-24 06:08:38 +00:00
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));
2026-08-24 06:08:38 +00:00
map = new Map(found.map((otherUserId) => {
2026-07-29 08:29:29 +00:00
const items = [otherUserId.otherUserId, otherUserId];
return items;
}));
2026-07-20 16:05:17 +00:00
},
LOAD_USER_AFFINITIES_V2_FAILURE: function handleLoadUserAffinitiesFailure() {
2026-08-24 06:08:38 +00:00
c3 = false;
2026-07-20 16:05:17 +00:00
},
LOGOUT: function handleLogout() {
2026-08-24 06:08:38 +00:00
obj = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(frozen);
2026-08-24 06:08:38 +00:00
map = new Map();
c3 = false;
2026-07-20 16:05:17 +00:00
}
};
2026-08-24 06:08:38 +00:00
const userAffinitiesV2Store = new UserAffinitiesV2Store(dispatcherDefault, obj);
const result = require("set").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;