Files
discord-decomp/sources/modules/presence_subscriptions/PresenceSubscriptionsStore.tsx
T
2026-07-27 16:20:00 +03:00

213 lines
8.0 KiB
TypeScript

/* Metro module 11327; source: modules/presence_subscriptions/PresenceSubscriptionsStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 4396, 4237, 11328, 4041, 566, 694, 2] */
function _fun86472(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#86472, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:6, offset: 0x01f959a8, size: 447 bytes, params: 8, frame: 21
const makeSubscriptionId = function(a0, a1) {
return '' + a0 + ':' + a1;
};
const closure = function() {
env0_10 = {};
env0_11 = {};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(6) /* metro dependency 6 */;
const env0_3 = importDefault(7) /* metro dependency 7 */;
const env0_4 = importDefault(15) /* metro dependency 15 */;
const env0_5 = importDefault(17) /* metro dependency 17 */;
const env0_6 = importDefault(18) /* metro dependency 18 */;
const env0_7 = importDefault(57) /* metro dependency 57 */;
const presenceStore = importDefault(4396) /* metro dependency 4396: PresenceStore */;
const env0_9 = (require(4237) /* metro dependency 4237: Constants */).INVITE_EXPIRATION_MS;
let env0_10 = {};
let env0_11 = {};
const DelayedCall = (require(4041) /* metro dependency 4041: Timers */).DelayedCall;
let delayedCall = new DelayedCall(3000, flush_86479);
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
_fun86480(Store).displayName = 'PresenceSubscriptionsStore';
delayedCall = new delayedCall(importDefault(694) /* metro dependency 694: Dispatcher */,
{PRESENCE_SUBSCRIPTIONS_ADD: PRESENCE_SUBSCRIPTIONS_ADD, CONNECTION_OPEN: closure, CONNECTION_RESUMED: closure,
LOGOUT: function() {
env0_10 = {};
env0_11 = {};
}});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/presence_subscriptions/PresenceSubscriptionsStore.tsx');
exports.default = delayedCall;
}
function _isNativeReflectConstruct_86473() { // fn#86473, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:199, offset: 0x01f95b67, 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_86473_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _isSubscribed({applicationId, partyId}) { // fn#86477, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:674, offset: 0x01f95bc9, size: 50 bytes, params: 2, frame: 14
const subscriptionId = makeSubscriptionId(applicationId, partyId);
return subscriptionId in env0_10 || subscriptionId in env0_11;
}
function flush_86479() { // fn#86479, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:493, offset: 0x01f95c0e, size: 156 bytes, params: 1, frame: 20
var r5;
var property;
var value4;
var property2;
var push;
var value5;
var subscribeActivities;
const items2 = [];
const Object = global.Object;
const entries = Object.entries;
let value = environment;
const value2 = Reflect.apply(entries, Object, [env0_11]);
let length = value2.length;
const value3 = 0;
if (value3 < length) {
r5 = value3;
reducibleLoop1: while (true) {
property = value2[r5];
value4 = env0_7(property, 2);
property = value4[value3];
property2 = value4[1];
push = items2.push;
Reflect.apply(push, items2, [property2]);
env0_10[property] = property2;
delete env0_11[property];
value5 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
length = value2.length;
if (value5 < length) {
r5 = value5;
continue reducibleLoop1;
}
break reducibleLoop1;
}
}
reducibleJoin4: while (true) {
if (value3 === items2.length) {
break reducibleJoin4;
}
value = importDefault(11328) /* metro dependency 11328: ActivitiesActionCreators */;
subscribeActivities = value.subscribeActivities;
Reflect.apply(subscribeActivities, value, [items2]);
break reducibleJoin4;
}
}
function _fun86480(a0) { // fn#86480, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:831, offset: 0x01f95caa, size: 97 bytes, params: 2, frame: 16
const closure = PresenceSubscriptionsStore;
env0_6(closure, a0);
return env0_3(closure, [{key: 'initialize', value: function() {
this.waitFor(PresenceStore);
}}, {key: 'isSubscribed', value: function(a0) {
return _isSubscribed(a0);
}}]);
}
function PRESENCE_SUBSCRIPTIONS_ADD({subscription}) { // fn#86484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11513:1395, offset: 0x01f95d0b, size: 395 bytes, params: 2, frame: 24
var r6;
var r7;
var r0;
var property;
var value7;
var expiresAt;
var value8;
var value10;
var value11;
let Date = global.Date;
let value = Date.now();
let Object = global.Object;
const value3 = Object.entries(env0_10);
let length = value3.length;
if (0 < length) {
r6 = 0;
r7 = false;
while (true) {
property = value3[r6];
value7 = env0_7(property, 2);
property = value7[0];
expiresAt = value7[1].expiresAt;
if (expiresAt < value) {
delete env0_10[property];
r7 = true;
}
value8 = typeof r6 === 'bigint' ? r6 + 1n : +r6 + 1;
length = value3.length;
if (value8 < length) {
r6 = value8;
continue;
}
r0 = r7;
break;
}
} else {
r0 = false;
}
Object = global.Object;
const value9 = Object.entries(env0_11);
length = value9.length;
if (0 < length) {
r6 = 0;
r7 = r0;
while (true) {
property = value9[r6];
value10 = env0_7(property, 2);
property = value10[0];
expiresAt = value10[1].expiresAt;
if (expiresAt < value) {
delete env0_11[property];
r7 = true;
}
value11 = typeof r6 === 'bigint' ? r6 + 1n : +r6 + 1;
length = value9.length;
if (value11 < length) {
r6 = value11;
continue;
}
r0 = r7;
break;
}
}
const userId = subscription.userId;
const applicationId = subscription.applicationId;
const partyId = subscription.partyId;
const messageId = subscription.messageId;
const channelId = subscription.channelId;
const inviteTime = subscription.inviteTime;
if (_isSubscribed(subscription)) {
return r0;
}
value = inviteTime + INVITE_EXPIRATION_MS;
Date = global.Date;
if (value < Date.now()) {
return r0;
}
value = makeSubscriptionId(applicationId, partyId);
Date = global.Date;
env0_11[value] = {userId: userId, applicationId: applicationId, partyId: partyId, messageId: messageId,
channelId: channelId, expiresAt: INVITE_EXPIRATION_MS + Date.now()};
env0_12.delay();
return true;
}