448 lines
20 KiB
TypeScript
448 lines
20 KiB
TypeScript
/* Metro module 6876; source: stores/SelfPresenceStore.tsx; dependencies: [6, 7, 15, 17, 18, 6867, 1348, 4267, 4795, 4270, 6877, 4396, 4296, 661, 4278, 3829, 1391, 6887, 644, 22, 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 UserSettingsProtoStore from '../modules/user_settings/UserSettingsProtoStore.tsx'; /* Metro dependency 1348 */
|
|
import DetectableGameStore from './DetectableGameStore.tsx'; /* Metro dependency 4267 */
|
|
import LibraryApplicationStore from './LibraryApplicationStore.tsx'; /* Metro dependency 4270 */
|
|
import SessionsStore from './SessionsStore.tsx'; /* Metro dependency 4296 */
|
|
import PresenceStore from './PresenceStore.tsx'; /* Metro dependency 4396 */
|
|
import IdleStore from './IdleStore.tsx'; /* Metro dependency 4795 */
|
|
import SpotifyStore from '../modules/spotify/SpotifyStore.tsx'; /* Metro dependency 6867 */
|
|
import LocalActivityStore from './LocalActivityStore.tsx'; /* Metro dependency 6877 */
|
|
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as FlagUtilsModule from '../external/discord_common/js/shared/utils/FlagUtils.tsx'; /* Metro dependency 1391 */
|
|
import * as PresenceStoreModule from './PresenceStore.tsx'; /* Metro dependency 4396 */
|
|
|
|
function _fun54523(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#54523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:6, offset: 0x01367670, size: 778 bytes, params: 8, frame: 24
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_54529 = 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 shouldShowApplicationActivity = function(a0) {
|
|
return require(dependencyMap[14]).shouldShareApplicationActivity(a0, LibraryApplicationStore);
|
|
};
|
|
const START_SESSION_545332 = START_SESSION_54533;
|
|
const CONNECTION_OPEN_SUPPLEMENTAL_545362 = CONNECTION_OPEN_SUPPLEMENTAL_54536;
|
|
let Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = ConstantsModule;
|
|
const StatusTypes = value.StatusTypes;
|
|
const env0_18 = value.ActivityFlags;
|
|
const env0_19 = value.ActivityTypes;
|
|
const env0_20 = value.AppStates;
|
|
const env0_22 = StatusTypes.ONLINE;
|
|
let env0_23 = StatusTypes.UNKNOWN;
|
|
const env0_25 = [];
|
|
const env0_26 = [];
|
|
Object = global.Object;
|
|
const env0_29 = Object.freeze([]);
|
|
Object = global.Object;
|
|
const env0_30 = Object.freeze([]);
|
|
const env0_31 = [];
|
|
const env0_32 = [];
|
|
const Store = (Flux).Store;
|
|
_fun54537(Store).displayName = 'SelfPresenceStore';
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {START_SESSION: START_SESSION_545332,
|
|
CONNECTION_OPEN: function() {
|
|
CONNECTION_OPEN_SUPPLEMENTAL_54536();
|
|
}, CONNECTION_OPEN_SUPPLEMENTAL: CONNECTION_OPEN_SUPPLEMENTAL_545362,
|
|
OVERLAY_INITIALIZE: CONNECTION_OPEN_SUPPLEMENTAL_545362, CONNECTION_CLOSED: START_SESSION_545332,
|
|
IDLE: START_SESSION_545332, AFK: START_SESSION_545332, RUNNING_GAMES_CHANGE: START_SESSION_545332,
|
|
STREAMING_UPDATE: START_SESSION_545332, USER_SETTINGS_PROTO_UPDATE: START_SESSION_545332,
|
|
LOCAL_ACTIVITY_UPDATE: START_SESSION_545332, SPOTIFY_PLAYER_STATE: START_SESSION_545332,
|
|
SPOTIFY_PLAYER_PLAY: START_SESSION_545332, USER_CONNECTIONS_UPDATE: START_SESSION_545332,
|
|
SESSIONS_REPLACE: START_SESSION_545332, RPC_APP_DISCONNECTED: START_SESSION_545332,
|
|
LIBRARY_FETCH_SUCCESS: START_SESSION_545332, LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: START_SESSION_545332,
|
|
LOGOUT: function() {
|
|
env0_28 = true;
|
|
env0_23 = ONLINE;
|
|
START_SESSION_54533();
|
|
}, FORCE_INVISIBLE: function(a0) {
|
|
env0_21 = a0.invisible;
|
|
START_SESSION_54533();
|
|
}, WINDOW_FOCUS: function() {
|
|
env0_21 = false;
|
|
START_SESSION_54533();
|
|
}, APP_STATE_UPDATE: APP_STATE_UPDATE_54553});
|
|
(FileImportTrackerModule).fileFinishedImporting('stores/SelfPresenceStore.tsx');
|
|
exports.default = value;
|
|
function _isNativeReflectConstruct_54524() { // fn#54524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:336, offset: 0x0136797a, size: 94 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_54524_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_54527(a0, a1) { // fn#54527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:529, offset: 0x013679d8, size: 370 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 _fun54528;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_54529(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_54529(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_54529(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun54528;
|
|
}
|
|
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 _fun54528() { // fn#54528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:1100, 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 filterPlayingActivities_54530(a0) { // fn#54530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:1545, offset: 0x01367b4a, size: 214 bytes, params: 2, frame: 21
|
|
var r10;
|
|
var r5;
|
|
var value4;
|
|
var type;
|
|
var PLAYING;
|
|
var value5;
|
|
if (a0.length === 0) {
|
|
return a0;
|
|
}
|
|
const items5 = [];
|
|
const items2 = [];
|
|
const value2 = _createForOfIteratorHelperLoose_54527(a0);
|
|
const value3 = value2();
|
|
let done = value3.done;
|
|
if (!done) {
|
|
r5 = value3;
|
|
while (true) {
|
|
value4 = r5.value;
|
|
type = value4.type;
|
|
PLAYING = ActivityTypes.PLAYING;
|
|
if (type === PLAYING) {
|
|
items2.push(value4);
|
|
} else {
|
|
items5.push(value4);
|
|
}
|
|
value5 = value2();
|
|
done = value5.done;
|
|
if (done) {
|
|
r10 = type;
|
|
break;
|
|
}
|
|
r5 = value5;
|
|
continue;
|
|
}
|
|
}
|
|
if (items2.length === 0) {
|
|
return a0;
|
|
}
|
|
if (items2.length === 1) {
|
|
return a0;
|
|
}
|
|
const items3 = [];
|
|
arraySpread(items3, items2, 0, r10);
|
|
const property = items3.sort(sortActivity)[0];
|
|
const items4 = [];
|
|
const value6 = arraySpread(items4, items5, 0, r10);
|
|
items4[value6] = property;
|
|
value6 + 1;
|
|
return items4.sort(sortActivity);
|
|
}
|
|
|
|
function shouldShowActivity(a0) { // fn#54532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:1924, offset: 0x01367c4e, size: 357 bytes, params: 2, frame: 19
|
|
var r0;
|
|
var value4;
|
|
const hasFlag = FlagUtilsModule.hasFlag;
|
|
const flags = a0.flags;
|
|
const value2 = 0;
|
|
const r5 = flags ?? value2;
|
|
const CONTEXTLESS = ActivityFlags.CONTEXTLESS;
|
|
if (Reflect.apply(hasFlag, FlagUtilsModule, [r5, CONTEXTLESS])) {
|
|
return true;
|
|
}
|
|
const type = a0.type;
|
|
const LISTENING = ActivityTypes.LISTENING;
|
|
if (LISTENING === type) {
|
|
r0 = (importDefault(6887) /* metro dependency 6887: isListeningOnSpotify */)(a0) ? SpotifyStore.shouldShowActivity() : a0.application_id != null && shouldShowApplicationActivity(a0.application_id);
|
|
} else {
|
|
var PLAYING = ActivityTypes.PLAYING;
|
|
if (PLAYING === type) {
|
|
if (a0.application_id != null) {
|
|
r0 = shouldShowApplicationActivity(a0.application_id);
|
|
} else {
|
|
value4 = DetectableGameStore.searchGamesByName(a0.name);
|
|
r0 = value4.length === 1 ? shouldShowApplicationActivity(value4[value2]) : (require(3829) /* metro dependency 3829: UserSettings */).ShowCurrentGame.getSetting();
|
|
}
|
|
return r0;
|
|
}
|
|
var STREAMING = ActivityTypes.STREAMING;
|
|
if (STREAMING !== type) {
|
|
ActivityTypes.WATCHING;
|
|
}
|
|
r0 = a0.application_id == null || shouldShowApplicationActivity(a0.application_id);
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function AFK_54533() { // fn#54533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:2556, offset: 0x01367db3, size: 511 bytes, params: 1, frame: 19
|
|
var r6;
|
|
var r3;
|
|
var setting;
|
|
var StatusTypesBinding;
|
|
var INVISIBLE;
|
|
var activities;
|
|
var items2;
|
|
var defaultImport2;
|
|
var binding;
|
|
var value15;
|
|
const idleSince = IdleStore.getIdleSince();
|
|
const value3 = 0;
|
|
let r0 = idleSince ?? value3;
|
|
env0_24 = r0;
|
|
env0_27 = IdleStore.isAFK();
|
|
if (!env0_28) {
|
|
if (env0_21) {
|
|
INVISIBLE = StatusTypes.INVISIBLE;
|
|
} else {
|
|
setting = (require(3829) /* metro dependency 3829: UserSettings */).StatusSetting.getSetting();
|
|
r0 = setting !== StatusTypes.UNKNOWN ? setting : StatusTypes.ONLINE;
|
|
}
|
|
}
|
|
const ONLINE3 = StatusTypes.ONLINE;
|
|
StatusTypesBinding = ONLINE === ONLINE3 && env0_24 > value3 ? StatusTypes : StatusTypesBinding;
|
|
if (env0_28) {
|
|
r6 = [];
|
|
} else if (ONLINE === StatusTypes.INVISIBLE) {
|
|
r6 = [];
|
|
} else {
|
|
activities = LocalActivityStore.getActivities();
|
|
r6 = activities.filter(shouldShowActivity);
|
|
}
|
|
if ((importDefault(644) /* metro dependency 644 */)(env0_25, r6)) {
|
|
r3 = false;
|
|
} else {
|
|
env0_25 = r6;
|
|
env0_26 = filterPlayingActivities_54530(r6);
|
|
r3 = true;
|
|
}
|
|
const remoteActivities = SessionsStore.getRemoteActivities();
|
|
if (remoteActivities2 !== remoteActivities) {
|
|
remoteActivities2 = remoteActivities;
|
|
r3 = true;
|
|
}
|
|
if (env0_30 === SessionsStore.getHiddenActivities()) {
|
|
}
|
|
if (r3) {
|
|
defaultImport2 = importDefault(22) /* metro dependency 22 */;
|
|
binding = env0_25;
|
|
items2 = [];
|
|
value15 = arraySpread(items2, binding, value3, undefined);
|
|
binding = remoteActivities2;
|
|
arraySpread(items2, binding.filter(function({type}) {
|
|
return type !== ActivityTypes.CUSTOM_STATUS;
|
|
}), value15, binding);
|
|
env0_32 = filterPlayingActivities_54530(defaultImport2(items2.sort(sortActivity)).uniqBy(_fun54535).value());
|
|
}
|
|
}
|
|
|
|
function CONNECTION_OPEN_SUPPLEMENTAL_54536() { // fn#54536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3160, offset: 0x01368001, size: 61 bytes, params: 1, frame: 14
|
|
env0_23 = StatusTypes.UNKNOWN;
|
|
START_SESSION_54533();
|
|
PresenceStore.setCurrentUserOnConnectionOpen(ONLINE, env0_31);
|
|
}
|
|
|
|
function _fun54537(a0) { // fn#54537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3268, offset: 0x0136803e, size: 254 bytes, params: 2, frame: 16
|
|
const SelfPresenceStore2 = SelfPresenceStore;
|
|
Inherits(SelfPresenceStore2, a0);
|
|
return CreateClass(SelfPresenceStore2, [{key: 'initialize', value: function() {
|
|
this.waitFor(DetectableGameStore, IdleStore, LibraryApplicationStore, LocalActivityStore, PresenceStore,
|
|
SessionsStore, SpotifyStore, UserSettingsProtoStore);
|
|
this.syncWith([LocalActivityStore], START_SESSION_54533);
|
|
}}, {key: 'getLocalPresence', value: value_54540}, {key: 'getStatus', value: function() {
|
|
return ONLINE;
|
|
}}, {key: 'getActivities', value: value_54542}, {key: 'getUnfilteredActivities', value: value_54543},
|
|
{key: 'getHiddenActivities', value: value_54544}, {key: 'getPrimaryActivity', value: function() {
|
|
var value = a0;
|
|
return this.getActivities(!(value !== undefined) || value)[0];
|
|
}}, {key: 'getApplicationActivity', value: function(a0) {
|
|
var value = a1;
|
|
var env0_0 = a0;
|
|
return this.findActivity(_fun54547, !(value !== undefined) || value);
|
|
}}, {key: 'findActivity', value: function(a0) {
|
|
var value = a1;
|
|
return this.getActivities(!(value !== undefined) || value).find(a0);
|
|
}}]);
|
|
function SelfPresenceStore() { // fn#54538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3280, offset: 0x0136813c, size: 113 bytes, params: 1, frame: 20
|
|
const value = environment.__proto__;
|
|
env1_3(this, SelfPresenceStore);
|
|
const value3 = env1_6(SelfPresenceStore);
|
|
return env1_5(this, _isNativeReflectConstruct_54524() ? global.Reflect.construct(value3, arguments,
|
|
env1_6(this).constructor) : value3.apply(this, arguments));
|
|
}
|
|
|
|
function value_54540() { // fn#54540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3688, offset: 0x01368200, size: 42 bytes, params: 1, frame: 3
|
|
return {status: ONLINE, since: env1_24, activities: env1_26, afk: env1_27};
|
|
}
|
|
|
|
function value_54542() { // fn#54542, offset: 0x0136822a, size: 29 bytes, params: 1, frame: 3
|
|
let value = a0;
|
|
let r0 = !(value !== undefined) || value;
|
|
value = environment.__proto__;
|
|
r0 = r0 ? env1_32 : env1_26;
|
|
return r0;
|
|
}
|
|
|
|
function value_54543() { // fn#54543, offset: 0x01368247, size: 29 bytes, params: 1, frame: 3
|
|
let value = a0;
|
|
let r0 = !(value !== undefined) || value;
|
|
value = environment.__proto__;
|
|
r0 = r0 ? env1_31 : env1_25;
|
|
return r0;
|
|
}
|
|
|
|
function value_54544() { // fn#54544, offset: 0x00e45481, size: 9 bytes, params: 1, frame: 1
|
|
return env1_30;
|
|
}
|
|
|
|
function value_54546(a0) { // fn#54546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:4086, offset: 0x01368285, size: 42 bytes, params: 2, frame: 13
|
|
const value = a1;
|
|
const env0_0 = a0;
|
|
return this.findActivity(_fun54547, !(value !== undefined) || value);
|
|
function _fun54547({application_id}) { // fn#54547, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:4129, offset: 0x0108da35, size: 22 bytes, params: 2, frame: 2
|
|
return application_id === env0_0;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function APP_STATE_UPDATE_54553({state}) { // fn#54553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:5203, offset: 0x01368335, size: 54 bytes, params: 2, frame: 10
|
|
const ACTIVE = AppStates.ACTIVE;
|
|
if (state === ACTIVE) {
|
|
if (env0_21) {
|
|
START_SESSION_54533();
|
|
return undefined;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
function _fun54535({type, application_id, name}) { // fn#54535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3075, offset: 0x01367fcd, size: 52 bytes, params: 2, frame: 18
|
|
return '' + type + ':' + application_id + ':' + name;
|
|
}
|
|
|
|
global.__d(_fun54523, 6876, [6, 7, 15, 17, 18, 6867, 1348, 4267, 4795, 4270, 6877, 4396, 4296, 661, 4278, 3829,
|
|
1391, 6887, 644, 22, 566, 694,
|
|
2]) /* metro module 6876, dependencies: [6, 7, 15, 17, 18, 6867, 1348, 4267, 4795, 4270, 6877, 4396, 4296, 661, 4278, 3829, 1391, 6887, 644, 22, 566, 694, 2] */;
|