Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5014.js (118.4 MB)
208 lines
7 KiB
TypeScript
208 lines
7 KiB
TypeScript
// Module ID: 14110
|
|
// Function ID: 14111
|
|
// Name: ActivityTrackingStore
|
|
// Dependencies: [1999, 1220, 502, 2016, 7727, 4852, 2098, 1074, 1091, 510, 7729, 11815, 2039, 4958, 504, 573, 2]
|
|
|
|
// Module 14110 (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" /* 4958 */;
|
|
import ActivitiesActionCreatorsDefault from "ActivitiesActionCreators" /* 11815 */;
|
|
import RunningGameStore from "RunningGameStore" /* 1999 */;
|
|
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1220 */;
|
|
import AuthenticationStore from "AuthenticationStore" /* 502 */;
|
|
import DetectableGameStore from "DetectableGameStore" /* 2016 */;
|
|
import LibraryApplicationStore from "LibraryApplicationStore" /* 7727 */;
|
|
import RTCConnectionStore from "RTCConnectionStore" /* 4852 */;
|
|
import SelectedChannelStore from "SelectedChannelStore" /* 2098 */;
|
|
|
|
require = fn;
|
|
function stopActivity(applicationId, flag) {
|
|
if (flag === undefined) {
|
|
flag = true;
|
|
}
|
|
if (flag) {
|
|
updateActivity(applicationId, true);
|
|
}
|
|
if (null != dependencyMap[applicationId.applicationId]) {
|
|
obj.stop();
|
|
applicationId = applicationId.applicationId;
|
|
delete tmp3[tmp2];
|
|
}
|
|
delete tmp3[tmp];
|
|
const Storage = Storage2.Storage;
|
|
const result = Storage.set(ActivityTrackingStore, obj);
|
|
}
|
|
function updateActivity(applicationId) {
|
|
_require = applicationId;
|
|
let flag = arg1;
|
|
if (arg1 === undefined) {
|
|
flag = false;
|
|
}
|
|
const timestamp = Date.now();
|
|
let num = 0;
|
|
if (null != applicationId.updatedAt) {
|
|
num = timestamp - applicationId.updatedAt;
|
|
}
|
|
if (num > closure_12 + closure_13) {
|
|
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 };
|
|
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);
|
|
applicationId.updatedAt = timestamp;
|
|
if (null == dependencyMap[applicationId.applicationId]) {
|
|
const interval = new tmp3(2039).Interval();
|
|
tmp11[applicationId.applicationId] = interval;
|
|
interval.start(closure_12, () => {
|
|
updateActivity(closure_0);
|
|
});
|
|
}
|
|
if (!flag) {
|
|
obj[applicationId.applicationId] = applicationId;
|
|
const Storage = tmp3(510).Storage;
|
|
const result1 = Storage.set(ActivityTrackingStore, obj);
|
|
}
|
|
}
|
|
function handleRunningGamesChange(flag) {
|
|
if (flag === undefined) {
|
|
flag = true;
|
|
}
|
|
const visibleRunningGames = RunningGameStore.getVisibleRunningGames();
|
|
const set = new Set();
|
|
const iter = visibleRunningGames[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp3 = nextResult;
|
|
let findGameResult = DetectableGameStore.findGame(nextResult);
|
|
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;
|
|
let _Date = Date;
|
|
let tmp7 = updateActivity;
|
|
obj.updatedAt = Date.now();
|
|
obj.distributor = tmp3.distributor;
|
|
let obj3 = GameAnalyticsUtils;
|
|
let str = tmp3.exePath;
|
|
if (str == null) {
|
|
str = "";
|
|
}
|
|
obj.exePath = obj3.removeExecutablePathPrefix(str);
|
|
let tmp7Result = tmp7(obj);
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
const keys = Object.keys(obj);
|
|
for (const item10052 of keys) {
|
|
let tmp14 = item10052;
|
|
if (!set.has(item10052)) {
|
|
let tmp18 = stopActivity(obj[tmp14], flag);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
function handleLogout() {
|
|
const keys = Object.keys(obj);
|
|
while (tmp2 !== undefined) {
|
|
let tmp6 = stopActivity(obj[tmp3]);
|
|
continue;
|
|
}
|
|
c16 = false;
|
|
}
|
|
const Distributors = fn(1074).Distributors;
|
|
const ActivityTrackingStore = "ActivityTrackingStore";
|
|
let closure_12 = 30 * DurationsDefault.Millis.MINUTE;
|
|
let closure_13 = 5 * DurationsDefault.Millis.MINUTE;
|
|
let Storage = fn(510).Storage;
|
|
let obj = Storage.get("ActivityTrackingStore");
|
|
if (obj == null) {
|
|
obj = {};
|
|
}
|
|
const dependencyMap = {};
|
|
let c16 = false;
|
|
const Store = initializeDefault.Store;
|
|
class ActivityTrackingStore extends Store {
|
|
}
|
|
const prototype = ActivityTrackingStore.prototype;
|
|
prototype["initialize"] = function initialize() {
|
|
this.waitFor(AuthenticationStore, DetectableGameStore, LibraryApplicationStore, RTCConnectionStore, RunningGameStore, SelectedChannelStore, UserSettingsProtoStore);
|
|
const items = [UserSettingsProtoStore];
|
|
this.syncWith(items, handleRunningGamesChange);
|
|
};
|
|
prototype["getActivities"] = function getActivities() {
|
|
return obj;
|
|
};
|
|
ActivityTrackingStore.displayName = "ActivityTrackingStore";
|
|
const activityTrackingStore = new ActivityTrackingStore(DispatcherDefault, {
|
|
RUNNING_GAMES_CHANGE() {
|
|
handleRunningGamesChange();
|
|
},
|
|
CONNECTION_OPEN: function handleConnectionOpen() {
|
|
if (c16) {
|
|
return false;
|
|
} else {
|
|
const _Object = Object;
|
|
const keys = Object.keys(obj);
|
|
const tmp5 = keys[Symbol.iterator]();
|
|
while (tmp5 !== undefined) {
|
|
let tmp11 = updateActivity(obj[tmp7]);
|
|
continue;
|
|
}
|
|
handleRunningGamesChange(false);
|
|
c16 = true;
|
|
}
|
|
},
|
|
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 {
|
|
tmp3.token = tmp;
|
|
const Storage = Storage2.Storage;
|
|
const result = Storage.set(ActivityTrackingStore, tmp2);
|
|
}
|
|
},
|
|
ACTIVITY_UPDATE_FAIL: function handleActivityUpdateFail(arg0) {
|
|
if (null == obj[arg0.applicationId]) {
|
|
return false;
|
|
} else {
|
|
tmp2.token = null;
|
|
tmp2.updatedAt = null;
|
|
const Storage = Storage2.Storage;
|
|
const result = Storage.set(ActivityTrackingStore, tmp);
|
|
}
|
|
}
|
|
});
|
|
const size = fn(2);
|
|
let result = size.fileFinishedImporting("stores/ActivityTrackingStore.tsx");
|
|
|
|
export default activityTrackingStore;
|