463 lines
21 KiB
TypeScript
463 lines
21 KiB
TypeScript
/* Metro module 12590; source: stores/ActivityTrackingStore.tsx; dependencies: [6, 7, 15, 17, 18, 4266, 1348, 1226, 4267, 4270, 4294, 1934, 661, 672, 587, 4278, 11328, 4041, 4482, 566, 694, 2] */
|
|
import ClassCallCheck from '../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
|
|
import CreateClass from '../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
|
|
import PossibleConstructorReturn from '../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
|
|
import Module00017 from '../by-id/module-00017.js'; /* Metro dependency 17 */
|
|
import Inherits from '../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
|
|
import Flux from '../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
|
|
import AuthenticationStore from './AuthenticationStore.tsx'; /* Metro dependency 1226 */
|
|
import UserSettingsProtoStore from '../modules/user_settings/UserSettingsProtoStore.tsx'; /* Metro dependency 1348 */
|
|
import SelectedChannelStore from './SelectedChannelStore.tsx'; /* Metro dependency 1934 */
|
|
import RunningGameStoreNative from '../modules/game_detection/RunningGameStore.native.tsx'; /* Metro dependency 4266 */
|
|
import DetectableGameStore from './DetectableGameStore.tsx'; /* Metro dependency 4267 */
|
|
import LibraryApplicationStore from './LibraryApplicationStore.tsx'; /* Metro dependency 4270 */
|
|
import RTCConnectionStore from './RTCConnectionStore.tsx'; /* Metro dependency 4294 */
|
|
import ActivitiesActionCreators from '../actions/ActivitiesActionCreators.tsx'; /* Metro dependency 11328 */
|
|
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as StorageModule from '../external/discord_common/js/packages/storage/Storage.tsx'; /* Metro dependency 587 */
|
|
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as LibraryApplicationUtilsModule from '../utils/LibraryApplicationUtils.tsx'; /* Metro dependency 4278 */
|
|
|
|
function _fun96464(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#96464, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:6, offset: 0x0215ecdf, size: 654 bytes, params: 8, frame: 22
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_96470 = function(a0, a1) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var value3;
|
|
var length;
|
|
var value5;
|
|
var value = undefined;
|
|
var value2 = value == null;
|
|
reducibleJoin2: while (true) {
|
|
if (value2) {
|
|
r0 = value2;
|
|
break reducibleJoin2;
|
|
}
|
|
value3 = value > a0.length;
|
|
r0 = value3;
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (r0) {
|
|
length = a0.length;
|
|
r1 = length;
|
|
break reducibleJoin4;
|
|
}
|
|
r1 = value;
|
|
break reducibleJoin4;
|
|
}
|
|
value = (0, global.Array)(r1);
|
|
var value4 = 0;
|
|
if (value4 < r1) {
|
|
r2 = value4;
|
|
reducibleLoop5: while (true) {
|
|
value[r2] = a0[r2];
|
|
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
if (value5 < r1) {
|
|
r2 = value5;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
const LOGOUT_964752 = LOGOUT_96475;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
let MINUTE = Millis.MINUTE;
|
|
const env0_17 = 30 * MINUTE;
|
|
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
MINUTE = Millis.MINUTE;
|
|
const env0_18 = 5 * MINUTE;
|
|
const Storage = (StorageModule).Storage;
|
|
const env0_19 = Storage.get('ActivityTrackingStore') ?? ({});
|
|
const env0_20 = {};
|
|
const Store = (Flux).Store;
|
|
_fun96476(Store).displayName = 'ActivityTrackingStore';
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {RUNNING_GAMES_CHANGE: function() {
|
|
handleRunningGamesChange();
|
|
}, CONNECTION_OPEN: CONNECTION_OPEN_96481, CONNECTION_CLOSED: CONNECTION_CLOSED_96482, LOGOUT: LOGOUT_964752,
|
|
ACTIVITY_UPDATE_SUCCESS: ACTIVITY_UPDATE_SUCCESS, ACTIVITY_UPDATE_FAIL: ACTIVITY_UPDATE_FAIL});
|
|
(FileImportTrackerModule).fileFinishedImporting('stores/ActivityTrackingStore.tsx');
|
|
exports.default = value;
|
|
function _isNativeReflectConstruct_96465() { // fn#96465, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:253, offset: 0x0215ef6d, size: 98 bytes, params: 1, frame: 18
|
|
var Boolean;
|
|
var prototype;
|
|
var valueOf;
|
|
var call;
|
|
var Reflect;
|
|
var construct;
|
|
var closure;
|
|
var value;
|
|
var error;
|
|
try {
|
|
Boolean = global.Boolean;
|
|
prototype = Boolean.prototype;
|
|
valueOf = prototype.valueOf;
|
|
call = valueOf.call;
|
|
Reflect = global.Reflect;
|
|
construct = Reflect.construct;
|
|
Boolean = global.Boolean;
|
|
closure = function() {
|
|
};
|
|
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
|
|
value = Reflect.apply(call, valueOf, [value]);
|
|
var result = !value;
|
|
} catch (error) {
|
|
}
|
|
return (_isNativeReflectConstruct_96465_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_96468(a0, a1) { // fn#96468, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:446, offset: 0x0215efcf, size: 372 bytes, params: 3, frame: 20
|
|
var r6;
|
|
var r9;
|
|
var r5;
|
|
var value3;
|
|
var regexp;
|
|
const env0_0 = a0;
|
|
const Symbol = global.Symbol;
|
|
let value = typeof Symbol !== 'undefined';
|
|
let r1 = value && a0[global.Symbol.iterator];
|
|
r1 = !r1 ? a0['@@iterator'] : r1;
|
|
if (r1) {
|
|
value = r1.call(a0);
|
|
return value.next.bind(value);
|
|
}
|
|
const Array = global.Array;
|
|
if (Array.isArray(a0)) {
|
|
if (r1) {
|
|
}
|
|
return _fun96469;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r5 = value;
|
|
} else {
|
|
value3 = ({}).toString.call(a0).slice(8, -1);
|
|
r6 = value3 === 'Object' && a0.constructor;
|
|
r9 = r6 ? a0.constructor.name : value3;
|
|
if (r9 === 'Map') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Set') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Arguments') {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun96469;
|
|
}
|
|
const TypeError = global.TypeError;
|
|
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
|
|
function _fun96469() { // fn#96469, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:1017, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
|
|
return env0_1 >= env0_0.length ? {done: true} : {done: false,
|
|
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
|
|
}
|
|
|
|
}
|
|
|
|
function stopActivity(a0) { // fn#96471, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:1493, offset: 0x0215f143, size: 137 bytes, params: 2, frame: 14
|
|
const value = a1;
|
|
if (!(value !== undefined) || value) {
|
|
updateActivity_96472(a0, true);
|
|
}
|
|
const property = env0_20[a0.applicationId];
|
|
if (property != null) {
|
|
property.stop();
|
|
delete env0_20[a0.applicationId];
|
|
}
|
|
delete env0_19[a0.applicationId];
|
|
const Storage = (StorageModule).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|
|
function updateActivity_96472(a0) { // fn#96472, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:1671, offset: 0x0215f1cc, size: 483 bytes, params: 2, frame: 27
|
|
var interval;
|
|
var start;
|
|
var Storage;
|
|
var set;
|
|
let value = a1;
|
|
const env0_0 = a0;
|
|
const r2 = value !== undefined ? value : false;
|
|
const Date = global.Date;
|
|
value = Date.now();
|
|
const updatedAt = a0.updatedAt;
|
|
const value2 = 0;
|
|
let r16 = updatedAt != null ? value - a0.updatedAt : value2;
|
|
let binding = env0_17;
|
|
r16 = r16 > binding + env0_18 ? value2 : r16;
|
|
const shouldShareApplicationActivity = LibraryApplicationUtilsModule.shouldShareApplicationActivity;
|
|
let applicationId = a0.applicationId;
|
|
const shouldShareApplicationActivity2 = Reflect.apply(shouldShareApplicationActivity, LibraryApplicationUtilsModule,
|
|
[applicationId, LibraryApplicationStore]);
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
const sessionId = AuthenticationStore.getSessionId();
|
|
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
|
|
const defaultImport = ActivitiesActionCreators;
|
|
const updateActivity = defaultImport.updateActivity;
|
|
const object = {};
|
|
object.applicationId = a0.applicationId;
|
|
object.distributor = a0.isDiscordApplication ? Distributors.DISCORD : a0.distributor;
|
|
object.shareActivity = shouldShareApplicationActivity2;
|
|
object.token = a0.token;
|
|
const Math = global.Math;
|
|
object.duration = Math.floor(r16 / 1000);
|
|
object.closed = r2;
|
|
object.exePath = a0.exePath;
|
|
object.voiceChannelId = voiceChannelId;
|
|
object.sessionId = sessionId;
|
|
object.mediaSessionId = mediaSessionId;
|
|
Reflect.apply(updateActivity, defaultImport, [object]);
|
|
a0.updatedAt = value;
|
|
binding = env0_20;
|
|
applicationId = a0.applicationId;
|
|
if (binding[applicationId] == null) {
|
|
binding = env0_20;
|
|
applicationId = a0.applicationId;
|
|
interval = new (require(4041) /* metro dependency 4041: Timers */).Interval();
|
|
binding[applicationId] = interval;
|
|
start = interval.start;
|
|
binding = env0_17;
|
|
Reflect.apply(start, interval, [binding, _fun96473]);
|
|
}
|
|
if (!r2) {
|
|
binding = env0_19;
|
|
binding[a0.applicationId] = a0;
|
|
Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
set = Storage.set;
|
|
binding = env0_16;
|
|
Reflect.apply(set, Storage, [binding, env0_19]);
|
|
}
|
|
function _fun96473() { // fn#96473, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2252, offset: 0x011c734f, size: 23 bytes, params: 1, frame: 11
|
|
updateActivity_96472(env0_0);
|
|
}
|
|
|
|
}
|
|
|
|
function handleRunningGamesChange() { // fn#96474, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2329, offset: 0x0215f3af, size: 368 bytes, params: 1, frame: 28
|
|
var r7;
|
|
var r15;
|
|
var r2;
|
|
var value8;
|
|
var game;
|
|
var add;
|
|
var id;
|
|
var updateActivity_96472Binding;
|
|
var object;
|
|
var Date;
|
|
var distributor;
|
|
var moduleValue;
|
|
var removeExecutablePathPrefix;
|
|
var exePath;
|
|
var value9;
|
|
var property;
|
|
var has;
|
|
var value12;
|
|
const value = a0;
|
|
const r6 = !(value !== undefined) || value;
|
|
const visibleRunningGames = RunningGameStoreNative.getVisibleRunningGames();
|
|
const Set = global.Set;
|
|
const set = new Set();
|
|
const value5 = _createForOfIteratorHelperLoose_96468(visibleRunningGames);
|
|
const value6 = value5();
|
|
let done = value6.done;
|
|
if (!done) {
|
|
r7 = value6;
|
|
while (true) {
|
|
value8 = r7.value;
|
|
game = DetectableGameStore.findGame(value8);
|
|
if (game != null) {
|
|
add = set.add;
|
|
id = game.id;
|
|
Reflect.apply(add, set, [id]);
|
|
id = game.id;
|
|
if (id in env0_19) {
|
|
break;
|
|
}
|
|
updateActivity_96472Binding = updateActivity_96472;
|
|
object = {};
|
|
id = game.id;
|
|
object.applicationId = id;
|
|
Date = global.Date;
|
|
object.updatedAt = Date.now();
|
|
distributor = value8.distributor;
|
|
object.distributor = distributor;
|
|
moduleValue = require(4482) /* metro dependency 4482: GameAnalyticsUtils */;
|
|
removeExecutablePathPrefix = moduleValue.removeExecutablePathPrefix;
|
|
exePath = value8.exePath;
|
|
if (exePath != null) {
|
|
r15 = exePath;
|
|
continue;
|
|
}
|
|
r15 = '';
|
|
continue;
|
|
object.exePath = Reflect.apply(removeExecutablePathPrefix, moduleValue, [r15]);
|
|
updateActivity_96472Binding(object);
|
|
break;
|
|
}
|
|
value9 = value5();
|
|
done = value9.done;
|
|
if (done) {
|
|
break;
|
|
}
|
|
r7 = value9;
|
|
continue;
|
|
}
|
|
}
|
|
const Object = global.Object;
|
|
const value10 = Object.keys(env0_19);
|
|
let length = value10.length;
|
|
const value11 = 0;
|
|
if (value11 < length) {
|
|
r2 = value11;
|
|
while (true) {
|
|
property = value10[r2];
|
|
has = set.has;
|
|
if (!Reflect.apply(has, set, [property])) {
|
|
stopActivity(env0_19[property], r6);
|
|
}
|
|
value12 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
length = value10.length;
|
|
if (value12 < length) {
|
|
r2 = value12;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function LOGOUT_96475() { // fn#96475, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2780, offset: 0x0215f51f, size: 82 bytes, params: 1, frame: 15
|
|
var r3;
|
|
var property;
|
|
var value4;
|
|
const Object = global.Object;
|
|
const value2 = Object.keys(env0_19);
|
|
let length = value2.length;
|
|
const value3 = 0;
|
|
if (value3 < length) {
|
|
for (r3 = value3; true; r3 = value4) {
|
|
property = value2[r3];
|
|
stopActivity(env0_19[property]);
|
|
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
|
|
length = value2.length;
|
|
if (!(value4 < length)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun96476(a0) { // fn#96476, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2890, offset: 0x0215f571, size: 97 bytes, params: 2, frame: 16
|
|
const ActivityTrackingStore2 = ActivityTrackingStore;
|
|
Inherits(ActivityTrackingStore2, a0);
|
|
return CreateClass(ActivityTrackingStore2, [{key: 'initialize', value: function() {
|
|
var authenticationStoreBinding = AuthenticationStore;
|
|
var detectableGameStoreBinding = DetectableGameStore;
|
|
var libraryApplicationStoreBinding = LibraryApplicationStore;
|
|
var rtcConnectionStoreBinding = RTCConnectionStore;
|
|
var runningGameStoreNativeBinding = RunningGameStoreNative;
|
|
var selectedChannelStoreBinding = SelectedChannelStore;
|
|
var userSettingsProtoStoreBinding = UserSettingsProtoStore;
|
|
this.waitFor(authenticationStoreBinding, detectableGameStoreBinding, libraryApplicationStoreBinding,
|
|
rtcConnectionStoreBinding, runningGameStoreNativeBinding, selectedChannelStoreBinding,
|
|
userSettingsProtoStoreBinding);
|
|
this.syncWith([userSettingsProtoStoreBinding], handleRunningGamesChange);
|
|
}}, {key: 'getActivities', value: value_96479}]);
|
|
function ActivityTrackingStore() { // fn#96477, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2902, offset: 0x00e3fd08, size: 113 bytes, params: 1, frame: 20
|
|
const value = environment.__proto__;
|
|
env1_3(this, ActivityTrackingStore);
|
|
const value3 = env1_6(ActivityTrackingStore);
|
|
return env1_5(this, _isNativeReflectConstruct_96465() ? global.Reflect.construct(value3, arguments,
|
|
env1_6(this).constructor) : value3.apply(this, arguments));
|
|
}
|
|
|
|
function value_96479() { // fn#96479, offset: 0x00d406a2, size: 9 bytes, params: 1, frame: 1
|
|
return env1_19;
|
|
}
|
|
|
|
}
|
|
|
|
function CONNECTION_OPEN_96481() { // fn#96481, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3506, offset: 0x0215f620, size: 104 bytes, params: 1, frame: 15
|
|
var r3;
|
|
var property;
|
|
var value4;
|
|
if (env0_21) {
|
|
return false;
|
|
}
|
|
const Object = global.Object;
|
|
const value2 = Object.keys(env0_19);
|
|
let length = value2.length;
|
|
const value3 = 0;
|
|
if (value3 < length) {
|
|
r3 = value3;
|
|
reducibleLoop2: while (true) {
|
|
property = value2[r3];
|
|
updateActivity_96472(env0_19[property]);
|
|
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
|
|
length = value2.length;
|
|
if (value4 < length) {
|
|
r3 = value4;
|
|
continue reducibleLoop2;
|
|
}
|
|
break reducibleLoop2;
|
|
}
|
|
}
|
|
handleRunningGamesChange(false);
|
|
}
|
|
|
|
function CONNECTION_CLOSED_96482({code}) { // fn#96482, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3682, offset: 0x0215f688, size: 35 bytes, params: 2, frame: 9
|
|
if (code === 4004) {
|
|
LOGOUT_96475();
|
|
}
|
|
}
|
|
|
|
function ACTIVITY_UPDATE_SUCCESS({applicationId, token}) { // fn#96483, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3794, offset: 0x0215f6ab, size: 90 bytes, params: 2, frame: 14
|
|
const property = env0_19[applicationId];
|
|
if (property == null) {
|
|
return false;
|
|
}
|
|
property.token = token;
|
|
const Storage = (StorageModule).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|
|
function ACTIVITY_UPDATE_FAIL({applicationId}) { // fn#96484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3941, offset: 0x0215f705, size: 90 bytes, params: 2, frame: 14
|
|
const property = env0_19[applicationId];
|
|
if (property == null) {
|
|
return false;
|
|
}
|
|
property.token = null;
|
|
property.updatedAt = null;
|
|
const Storage = (StorageModule).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun96464, 12590, [6, 7, 15, 17, 18, 4266, 1348, 1226, 4267, 4270, 4294, 1934, 661, 672, 587, 4278,
|
|
11328, 4041, 4482, 566, 694,
|
|
2]) /* metro module 12590, dependencies: [6, 7, 15, 17, 18, 4266, 1348, 1226, 4267, 4270, 4294, 1934, 661, 672, 587, 4278, 11328, 4041, 4482, 566, 694, 2] */;
|