decord/alpha/source/stores/ActivityTrackingStore.tsx

209 lines
7 KiB
TypeScript
Raw Normal View History

// Module ID: 14020
// Function ID: 14021
// Name: ActivityTrackingStore
// Dependencies: [1999, 1220, 502, 2016, 7642, 4780, 2096, 1074, 1091, 510, 7644, 11733, 2037, 4886, 504, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 14020 (ActivityTrackingStore)
import initializeDefault from "initialize" /* 504 */;
import Storage2 from "Storage" /* 510 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import DurationsDefault from "Durations" /* 1091 */;
import GameAnalyticsUtils from "GameAnalyticsUtils" /* 4886 */;
import ActivitiesActionCreatorsDefault from "ActivitiesActionCreators" /* 11733 */;
import RunningGameStore from "RunningGameStore" /* 1999 */;
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1220 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import DetectableGameStore from "DetectableGameStore" /* 2016 */;
import LibraryApplicationStore from "LibraryApplicationStore" /* 7642 */;
import RTCConnectionStore from "RTCConnectionStore" /* 4780 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2096 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function stopActivity(applicationId, flag) {
if (flag === undefined) {
flag = true;
}
if (flag) {
updateActivity(applicationId, true);
}
2026-07-23 10:11:24 +00:00
if (null != dependencyMap[applicationId.applicationId]) {
2026-07-20 16:05:17 +00:00
obj.stop();
applicationId = applicationId.applicationId;
2026-07-23 10:11:24 +00:00
delete tmp3[tmp2];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
delete tmp3[tmp];
2026-08-24 06:08:38 +00:00
const Storage = Storage2.Storage;
2026-07-23 10:11:24 +00:00
const result = Storage.set(ActivityTrackingStore, obj);
2026-07-20 16:05:17 +00:00
}
function updateActivity(applicationId) {
_require = applicationId;
2026-07-29 08:29:29 +00:00
let flag = arg1;
2026-07-20 16:05:17 +00:00
if (arg1 === undefined) {
flag = false;
}
const timestamp = Date.now();
let num = 0;
if (null != applicationId.updatedAt) {
num = timestamp - applicationId.updatedAt;
}
2026-07-29 08:29:29 +00:00
if (num > closure_12 + closure_13) {
2026-07-20 16:05:17 +00:00
num = 0;
}
obj = require("LibraryApplicationUtils");
const result = obj.shouldShareApplicationActivity(applicationId.applicationId, LibraryApplicationStore);
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
const sessionId = AuthenticationStore.getSessionId();
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
const obj3 = { applicationId: applicationId.applicationId, distributor: null, shareActivity: null, token: null, duration: null, closed: null, exePath: null, voiceChannelId: null, sessionId: null, mediaSessionId: null };
2026-07-20 16:05:17 +00:00
if (applicationId.isDiscordApplication) {
let distributor = Distributors.DISCORD;
} else {
distributor = applicationId.distributor;
}
obj3.distributor = distributor;
obj3.shareActivity = result;
obj3.token = applicationId.token;
obj3.duration = Math.floor(num / 1000);
obj3.closed = flag;
obj3.exePath = applicationId.exePath;
obj3.voiceChannelId = voiceChannelId;
obj3.sessionId = sessionId;
obj3.mediaSessionId = mediaSessionId;
ActivitiesActionCreatorsDefault.updateActivity(obj3);
2026-07-20 16:05:17 +00:00
applicationId.updatedAt = timestamp;
2026-07-23 10:11:24 +00:00
if (null == dependencyMap[applicationId.applicationId]) {
const interval = new tmp3(2037).Interval();
2026-07-29 08:29:29 +00:00
tmp11[applicationId.applicationId] = interval;
interval.start(closure_12, () => {
updateActivity(closure_0);
2026-07-20 16:05:17 +00:00
});
}
if (!flag) {
obj[applicationId.applicationId] = applicationId;
const Storage = tmp3(510).Storage;
2026-07-23 10:11:24 +00:00
const result1 = Storage.set(ActivityTrackingStore, obj);
2026-07-20 16:05:17 +00:00
}
}
function handleRunningGamesChange(flag) {
if (flag === undefined) {
flag = true;
}
const visibleRunningGames = RunningGameStore.getVisibleRunningGames();
2026-07-20 16:05:17 +00:00
const set = new Set();
2026-07-29 08:29:29 +00:00
const iter = visibleRunningGames[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp3 = nextResult;
let findGameResult = DetectableGameStore.findGame(nextResult);
2026-07-29 08:29:29 +00:00
let tmp6 = findGameResult;
if (null != findGameResult) {
let addResult = set.add(tmp6.id);
if (!(tmp6.id in obj)) {
obj = { applicationId: null, updatedAt: null, distributor: null, exePath: null };
obj.applicationId = tmp6.id;
2026-07-29 08:29:29 +00:00
let _Date = Date;
let tmp7 = updateActivity;
obj.updatedAt = Date.now();
obj.distributor = tmp3.distributor;
let obj3 = GameAnalyticsUtils;
2026-07-29 08:29:29 +00:00
let str = tmp3.exePath;
if (str == null) {
str = "";
2026-07-20 16:05:17 +00:00
}
obj.exePath = obj3.removeExecutablePathPrefix(str);
2026-07-29 08:29:29 +00:00
let tmp7Result = tmp7(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
const keys = Object.keys(obj);
2026-07-29 08:29:29 +00:00
for (const item10052 of keys) {
let tmp14 = item10052;
if (!set.has(item10052)) {
let tmp18 = stopActivity(obj[tmp14], flag);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
}
function handleLogout() {
const keys = Object.keys(obj);
2026-07-29 08:29:29 +00:00
while (tmp2 !== undefined) {
let tmp6 = stopActivity(obj[tmp3]);
continue;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
c16 = false;
2026-07-20 16:05:17 +00:00
}
const Distributors = fn(1074).Distributors;
2026-07-23 10:11:24 +00:00
const ActivityTrackingStore = "ActivityTrackingStore";
let closure_12 = 30 * DurationsDefault.Millis.MINUTE;
let closure_13 = 5 * DurationsDefault.Millis.MINUTE;
let Storage = fn(510).Storage;
2026-07-20 16:05:17 +00:00
let obj = Storage.get("ActivityTrackingStore");
2026-07-29 08:29:29 +00:00
if (obj == null) {
2026-07-20 16:05:17 +00:00
obj = {};
}
const dependencyMap = {};
2026-07-29 08:29:29 +00:00
let c16 = false;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class ActivityTrackingStore extends Store {
}
const prototype = ActivityTrackingStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(AuthenticationStore, DetectableGameStore, LibraryApplicationStore, RTCConnectionStore, RunningGameStore, SelectedChannelStore, UserSettingsProtoStore);
const items = [UserSettingsProtoStore];
2026-07-29 08:29:29 +00:00
this.syncWith(items, handleRunningGamesChange);
};
prototype["getActivities"] = function getActivities() {
return obj;
};
ActivityTrackingStore.displayName = "ActivityTrackingStore";
const activityTrackingStore = new ActivityTrackingStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
RUNNING_GAMES_CHANGE() {
handleRunningGamesChange();
},
CONNECTION_OPEN: function handleConnectionOpen() {
2026-07-29 08:29:29 +00:00
if (c16) {
2026-07-20 16:05:17 +00:00
return false;
} else {
const _Object = Object;
const keys = Object.keys(obj);
2026-07-29 08:29:29 +00:00
const tmp5 = keys[Symbol.iterator]();
while (tmp5 !== undefined) {
let tmp11 = updateActivity(obj[tmp7]);
continue;
2026-07-20 16:05:17 +00:00
}
handleRunningGamesChange(false);
2026-07-29 08:29:29 +00:00
c16 = true;
2026-07-20 16:05:17 +00:00
}
},
CONNECTION_CLOSED: function handleConnectionClosed(code) {
if (4004 === code.code) {
handleLogout();
}
},
LOGOUT: handleLogout,
ACTIVITY_UPDATE_SUCCESS: function handleActivityUpdate(arg0) {
if (null == obj[arg0.applicationId]) {
return false;
} else {
2026-07-29 08:29:29 +00:00
tmp3.token = tmp;
2026-08-24 06:08:38 +00:00
const Storage = Storage2.Storage;
2026-07-29 08:29:29 +00:00
const result = Storage.set(ActivityTrackingStore, tmp2);
2026-07-20 16:05:17 +00:00
}
},
ACTIVITY_UPDATE_FAIL: function handleActivityUpdateFail(arg0) {
if (null == obj[arg0.applicationId]) {
return false;
} else {
2026-07-29 08:29:29 +00:00
tmp2.token = null;
tmp2.updatedAt = null;
2026-08-24 06:08:38 +00:00
const Storage = Storage2.Storage;
2026-07-29 08:29:29 +00:00
const result = Storage.set(ActivityTrackingStore, tmp);
2026-07-20 16:05:17 +00:00
}
}
});
const size = fn(2);
let result = size.fileFinishedImporting("stores/ActivityTrackingStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default activityTrackingStore;