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

367 lines
15 KiB
TypeScript

/* Metro module 5242; source: modules/game_relationships/GameRelationshipStore.tsx; dependencies: [6, 7, 15, 17, 18, 3793, 661, 3780, 566, 694, 2] */
function _fun46622(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#46622, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:6, offset: 0x011ac006, size: 472 bytes, params: 8, frame: 21
const _arrayLikeToArray_46628 = 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 Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_0 = importDefault(6) /* metro dependency 6 */;
const env0_1 = importDefault(7) /* metro dependency 7 */;
const env0_2 = importDefault(15) /* metro dependency 15 */;
const env0_3 = importDefault(17) /* metro dependency 17 */;
const env0_4 = importDefault(18) /* metro dependency 18 */;
const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */;
const env0_6 = (require(661) /* metro dependency 661: Constants */).RelationshipTypes;
const GAME_RELATIONSHIP_KEY = function(a0, a1) {
return '' + a1 + '-' + a0;
};
const GameRelationshipIndexes_BY_APPLICATION_ID = function(a0) {
return 'application-id-' + a0;
};
const GameRelationshipIndexes_BY_USER_ID = function(a0) {
return 'user-id-' + a0;
};
const GameRelationshipIndexes_BY_RELATIONSHIP_TYPE = function(a0) {
return 'relationship-type-' + a0;
};
const SecondaryIndexMap = (require(3780) /* metro dependency 3780: SecondaryIndexMap */).SecondaryIndexMap;
let secondaryIndexMap = new SecondaryIndexMap(function(a0) {
var items = [];
items.push(GameRelationshipIndexes_BY_APPLICATION_ID(a0.applicationId));
items.push(GameRelationshipIndexes_BY_USER_ID(a0.id));
items.push(GameRelationshipIndexes_BY_RELATIONSHIP_TYPE(a0.type));
return items;
}, function({since}) {
return '' + since;
});
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
_fun46639(Store).displayName = 'GameRelationshipStore';
secondaryIndexMap = new secondaryIndexMap(importDefault(694) /* metro dependency 694: Dispatcher */,
{CONNECTION_OPEN: CONNECTION_OPEN_46655, GAME_RELATIONSHIP_ADD: function(a0) {
upsert(a0.gameRelationship);
recountRelationshipTypes();
}, GAME_RELATIONSHIP_REMOVE: function(a0) {
var remove_46632Binding = remove_46632;
var userId = a0.userId;
remove_46632Binding(userId, a0.applicationId);
recountRelationshipTypes();
}, APPLICATIONS_FETCH_SUCCESS: APPLICATIONS_FETCH_SUCCESS_46659});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/game_relationships/GameRelationshipStore.tsx');
exports.default = secondaryIndexMap;
}
function _isNativeReflectConstruct_46623() { // fn#46623, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:189, offset: 0x011ac1de, 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_46623_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_46626(a0, a1) { // fn#46626, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:382, offset: 0x011ac23c, 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 _fun46627;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_46628(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_46628(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_46628(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun46627;
}
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 recountRelationshipTypes() { // fn#46629, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:1832, offset: 0x011ac3ae, size: 75 bytes, params: 1, frame: 13
env0_11.values().forEach(_fun46630);
}
function upsert(a0) { // fn#46631, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:2070, offset: 0x011ac499, size: 45 bytes, params: 2, frame: 16
const binding = env0_11;
binding.set(GAME_RELATIONSHIP_KEY(a0.id, a0.applicationId), a0);
}
function remove_46632(a0, a1) { // fn#46632, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:2142, offset: 0x011ac4c6, size: 37 bytes, params: 3, frame: 15
env0_11.delete(GAME_RELATIONSHIP_KEY(a0, a1));
}
function _fun46639(a0) { // fn#46639, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:2206, offset: 0x011ac5dd, size: 327 bytes, params: 2, frame: 16
const closure = GameRelationshipStore;
env0_4(closure, a0);
return env0_1(closure, [{key: 'initialize', value: function() {
this.waitFor(RelationshipStore);
}}, {key: 'getPendingIncomingCount', value: value_46642}, {key: 'getPendingOutgoingCount', value: value_46643},
{key: 'getGameFriendCount', value: value_46644}, {key: 'getGameFriendsForApplication', value: value_46645},
{key: 'getGameRelationshipsForUser', value: value_46647}, {key: 'getGameRelationshipsForUserByType',
value: function(a0, a1) {
var env0_0 = a1;
return this.getGameRelationshipsForUser(a0).filter(_fun46649);
}}, {key: 'getGameFriendsForUser', value: function(a0) {
return this.getGameRelationshipsForUserByType(a0, RelationshipTypes.FRIEND);
}}, {key: 'getGameRelationshipCount', value: value_46651}, {key: 'getGameRelationships', value: value_46652},
{key: 'getGameRelationshipsByType', value: value_46653}, {key: 'getGameRelationshipsVersion',
value: value_46654}]);
}
function CONNECTION_OPEN_46655({gameRelationships}) { // fn#46655, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:3653, offset: 0x011ac829, size: 55 bytes, params: 2, frame: 12
env0_11.clear();
gameRelationships.forEach(function(a0) {
upsert({id: a0.id, applicationId: a0.application_id, type: a0.type, since: a0.since,
dmAccessType: a0.dm_access_type});
});
recountRelationshipTypes();
}
function APPLICATIONS_FETCH_SUCCESS_46659({unknownApplicationIds}) { // fn#46659, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:4183, offset: 0x011ac8ee, size: 213 bytes, params: 2, frame: 21
var r4;
var r6;
var r2;
var _createForOfIteratorHelperLoose_46626Binding;
var value2;
var value3;
var done;
var value4;
var binding;
var values;
var value5;
var value6;
var value7;
var type;
var PENDING_INCOMING;
var value8;
var PENDING_OUTGOING;
var value9;
var remove_46632Binding;
var id;
var value10;
var value11;
if (unknownApplicationIds != null) {
value2 = _createForOfIteratorHelperLoose_46626(unknownApplicationIds);
value3 = value2();
done = value3.done;
if (!done) {
r4 = value3;
while (true) {
value4 = r4.value;
_createForOfIteratorHelperLoose_46626Binding = _createForOfIteratorHelperLoose_46626;
binding = env0_11;
values = binding.values;
value5 = _createForOfIteratorHelperLoose_46626Binding(Reflect.apply(values, binding,
[GameRelationshipIndexes_BY_APPLICATION_ID(value4)]));
value6 = value5();
done = value6.done;
if (!done) {
r6 = value6;
while (true) {
value7 = r6.value;
type = value7.type;
PENDING_INCOMING = RelationshipTypes.PENDING_INCOMING;
value8 = type !== PENDING_INCOMING;
if (value8) {
type = value7.type;
PENDING_OUTGOING = RelationshipTypes.PENDING_OUTGOING;
value9 = type !== PENDING_OUTGOING;
r2 = value9;
} else {
r2 = value8;
}
if (r2) {
continue;
}
remove_46632Binding = remove_46632;
id = value7.id;
remove_46632Binding(id, value4);
value10 = value5();
done = value10.done;
if (done) {
break;
}
r6 = value10;
continue;
}
}
value11 = value2();
done = value11.done;
if (done) {
break;
}
r4 = value11;
continue;
}
}
recountRelationshipTypes();
}
}
function _fun46630({type, id}) { // fn#46630, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:1904, offset: 0x011ac3f9, size: 160 bytes, params: 2, frame: 12
const FRIEND = RelationshipTypes.FRIEND;
if (type === FRIEND) {
env0_2 += 1;
} else {
var PENDING_OUTGOING = RelationshipTypes.PENDING_OUTGOING;
if (type === PENDING_OUTGOING) {
env0_1 += 1;
return undefined;
}
var PENDING_INCOMING = RelationshipTypes.PENDING_INCOMING;
if (type !== PENDING_INCOMING) {
return undefined;
}
if (RelationshipStore.isSpam(id)) {
return undefined;
}
if (RelationshipStore.isIgnored(id)) {
return undefined;
}
env0_0 += 1;
}
}
function value_46645(a0) { // fn#46645, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:2784, offset: 0x011ac724, size: 53 bytes, params: 2, frame: 14
var environment;
let value = environment.__proto__;
const binding = env1_11;
const values = binding.values;
value = GameRelationshipIndexes_BY_APPLICATION_ID(a0);
value = Reflect.apply(values, binding, [value, true]);
return value.filter(function({type}) {
return type === RelationshipTypes.FRIEND;
});
}
function value_46647(a0) { // fn#46647, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:2935, offset: 0x011ac774, size: 36 bytes, params: 2, frame: 14
const value = environment.__proto__;
const binding = env1_11;
return binding.values(GameRelationshipIndexes_BY_USER_ID(a0), true);
}
function value_46648(a0, a1) { // fn#46648, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:3054, offset: 0x011ac798, size: 43 bytes, params: 3, frame: 12
const env0_0 = a1;
return this.getGameRelationshipsForUser(a0).filter(function({type}) {
return type === require;
});
}
function value_46651() { // fn#46651, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:3282, offset: 0x011ac7e4, size: 18 bytes, params: 1, frame: 9
return env1_11.size();
}
function value_46653(a0) { // fn#46653, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:3407, offset: 0x011ac7f6, size: 36 bytes, params: 2, frame: 14
const value = environment.__proto__;
const binding = env1_11;
return binding.values(GameRelationshipIndexes_BY_RELATIONSHIP_TYPE(a0), true);
}
function value_46654() { // fn#46654, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5420:3530, offset: 0x011ac81a, size: 15 bytes, params: 1, frame: 1
return env1_11.version;
}