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

397 lines
16 KiB
TypeScript

/* Metro module 8057; source: modules/interactions/InteractionStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 1226, 1379, 672, 4629, 1909, 7067, 566, 694, 2] */
function _fun63924(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#63924, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:6, offset: 0x01b96662, size: 563 bytes, params: 8, frame: 21
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(6) /* metro dependency 6 */;
const env0_4 = importDefault(7) /* metro dependency 7 */;
const env0_5 = importDefault(15) /* metro dependency 15 */;
const env0_6 = importDefault(17) /* metro dependency 17 */;
const env0_7 = importDefault(18) /* metro dependency 18 */;
const env0_8 = importDefault(57) /* metro dependency 57 */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */;
let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
const MINUTE = Millis.MINUTE;
const value = 5 * MINUTE;
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
const SECOND = Millis.SECOND;
const value2 = 10 * SECOND;
const env0_13 = {};
const env0_14 = {};
const env0_15 = {};
const env0_18 = {};
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
const value3 = _fun63930(Store);
value3.displayName = 'InteractionStore';
const value6 = new value3(importDefault(694) /* metro dependency 694: Dispatcher */, {LOGOUT: LOGOUT_63939,
INTERACTION_QUEUE: INTERACTION_QUEUE, INTERACTION_CREATE: INTERACTION_CREATE,
INTERACTION_SUCCESS: function({nonce}) {
markInteractionByNonceCompleted(nonce);
}, INTERACTION_FAILURE: INTERACTION_FAILURE_63944, MESSAGE_CREATE: MESSAGE_CREATE_63945,
CHANNEL_SELECT: CHANNEL_SELECT_63946, INTERACTION_IFRAME_MODAL_CREATE: function({application, nonce}) {
env0_17 = application.id;
markInteractionByNonceCompleted(nonce);
}, INTERACTION_IFRAME_MODAL_CLOSE: function() {
env0_16 = undefined;
env0_17 = undefined;
}, INTERACTION_IFRAME_MODAL_KEY_CREATE: function(a0) {
env0_16 = a0.modalKey;
}, INTERACTION_MODAL_CREATE: function({nonce}) {
markInteractionByNonceCompleted(nonce);
}, EMBEDDED_ACTIVITY_UPDATE_V2: EMBEDDED_ACTIVITY_UPDATE_V2_63951});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/interactions/InteractionStore.tsx');
exports.default = value6;
exports.STALE_INTERACTION_INTERVAL = value;
exports.STALE_INTERACTION_DURATION = value2;
}
function _isNativeReflectConstruct_63925() { // fn#63925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:178, offset: 0x01b96895, 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_63925_isNativeReflectConstruct = function() {
return !!result;
})();
}
function markInteractionByNonceCompleted(a0) { // fn#63928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:466, offset: 0x01b968f3, size: 65 bytes, params: 2, frame: 13
if (a0 == null) {
return false;
}
const property = env0_13[a0];
if (property == null) {
return false;
}
if (property.onSuccess != null) {
property.onSuccess();
}
deleteNonce(a0);
}
function deleteNonce(a0) { // fn#63929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:609, offset: 0x01b96934, size: 124 bytes, params: 2, frame: 14
var property;
var property2;
var binding;
var object2;
if (env0_18[a0] == null) {
property = env0_13[a0];
delete env0_13[a0];
property2 = env0_15[a0];
if (property2 != null) {
delete env0_14[property2];
}
delete env0_15[a0];
binding = env0_18;
object2 = {};
object2.insertedAt = global.Date.now();
object2.nonce = a0;
object2.messageId = property2;
object2.interaction = property;
binding[a0] = object2;
} else {
delete env0_18[a0];
}
}
function _fun63930(a0) { // fn#63930, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:801, offset: 0x01b969b0, size: 216 bytes, params: 2, frame: 16
const closure = InteractionStore;
env0_7(closure, a0);
return env0_4(closure, [{key: 'initialize', value: function() {
this.waitFor(AuthenticationStore, ChannelStore);
}}, {key: 'getInteraction', value: value_63933}, {key: 'getMessageInteractionStates', value: value_63934},
{key: 'canQueueInteraction', value: value_63935}, {key: 'getIFrameModalApplicationId', value: value_63936},
{key: 'getIFrameModalKey', value: value_63937}, {key: 'getInteractionDebugContext', value: value_63938}]);
}
function LOGOUT_63939() { // fn#63939, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2003, offset: 0x01b96c41, size: 56 bytes, params: 1, frame: 13
env0_13 = {};
env0_14 = {};
env0_15 = {};
env0_18 = {};
global.setInterval(_fun63940, env0_11);
}
function INTERACTION_QUEUE({nonce, messageId, data, onCreate, onCancel, onSuccess, onFailure}) { // fn#63941, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2209, offset: 0x01b96cf8, size: 145 bytes, params: 2, frame: 19
if (messageId != null) {
env0_14[messageId] = nonce;
env0_15[nonce] = messageId;
}
const binding = env0_13;
const InteractionState = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState;
const QUEUED = InteractionState.QUEUED;
binding[nonce] = {state: QUEUED, data: data, onCreate: onCreate, onCancel: onCancel, onSuccess: onSuccess,
onFailure: onFailure};
}
function INTERACTION_CREATE({nonce, interactionId}) { // fn#63942, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2460, offset: 0x01b96d89, size: 145 bytes, params: 2, frame: 17
if (nonce == null) {
return false;
}
const property = env0_13[nonce];
if (property == null) {
return false;
}
const state = property.state;
const InteractionState = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState;
const QUEUED = InteractionState.QUEUED;
if (state !== QUEUED) {
return false;
}
const CREATED = InteractionState.CREATED;
property.state = CREATED;
if (property.onCreate != null) {
property.onCreate(interactionId);
}
}
function INTERACTION_FAILURE_63944({nonce, errorCode, errorMessage, status, reasonCode}) { // fn#63944, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2809, offset: 0x01b96e33, size: 243 bytes, params: 2, frame: 21
var r11;
var binding;
var object2;
if (nonce == null) {
return false;
}
const property = env0_13[nonce];
if (property == null) {
return false;
}
if (property.onFailure != null) {
property.onFailure(errorCode, errorMessage, status, reasonCode);
r11 = status;
}
const interactionType = property.data.interactionType;
const InteractionTypes = (require(1909) /* metro dependency 1909: Server */).InteractionTypes;
const APPLICATION_COMMAND = InteractionTypes.APPLICATION_COMMAND;
if (interactionType === APPLICATION_COMMAND) {
deleteNonce(nonce);
} else {
binding = env0_13;
object2 = {};
copyDataProperties(object2, property, r11);
object2['state'] = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState.FAILED;
object2['errorCode'] = errorCode;
object2['errorMessage'] = errorMessage;
binding[nonce] = object2;
}
}
function MESSAGE_CREATE_63945({message}) { // fn#63945, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:3173, offset: 0x01b96f26, size: 88 bytes, params: 2, frame: 13
if (message.nonce == null) {
return false;
}
const property = env0_13[message.nonce];
if (property == null) {
return false;
}
if (property.onSuccess != null) {
property.onSuccess();
}
deleteNonce(message.nonce);
}
function CHANNEL_SELECT_63946({channelId}) { // fn#63946, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:3348, offset: 0x01b96f7e, size: 171 bytes, params: 2, frame: 21
var r2;
var property;
var value5;
var state;
var InteractionState;
var FAILED;
var value6;
if (ChannelStore.getChannel(channelId) == null) {
return false;
}
const Object = global.Object;
const value3 = Object.entries(env0_13);
let length = value3.length;
if (0 < length) {
r2 = 0;
while (true) {
property = value3[r2];
value5 = env0_8(property, 2);
property = value5[0];
state = value5[1].state;
InteractionState = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState;
FAILED = InteractionState.FAILED;
if (state === FAILED) {
deleteNonce(property);
}
value6 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
length = value3.length;
if (value6 < length) {
r2 = value6;
continue;
}
break;
}
}
}
function EMBEDDED_ACTIVITY_UPDATE_V2_63951({participants}) { // fn#63951, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:4010, offset: 0x01b97073, size: 246 bytes, params: 2, frame: 18
var r0;
var r4;
var nonce;
var binding;
var property;
var messageId;
var value;
const env0_0 = AuthenticationStore.getSessionId();
const env0_1 = AuthenticationStore.getId();
const value2 = participants.find(_fun63952);
if (value2 != null) {
nonce = value2.nonce;
if (nonce != null) {
binding = env0_18;
nonce = value2.nonce;
property = binding[nonce];
if (property == null) {
binding = env0_15;
nonce = value2.nonce;
property = binding[nonce];
binding = env0_13;
nonce = value2.nonce;
r0 = binding[nonce];
r4 = property;
} else {
messageId = property.messageId;
r0 = property.interaction;
r4 = messageId;
}
if (r0 != null && r4 != null) {
deleteNonce(value2.nonce);
if (r4 != null && 'channelId' in r0.data) {
value = importDefault(7067) /* metro dependency 7067: MessageActionCreators */;
value.deleteMessage(r0.data.channelId, r4, true);
}
}
}
}
}
function value_63933({id}) { // fn#63933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1170, offset: 0x01b96aa6, size: 38 bytes, params: 2, frame: 4
const property = env1_14[id];
return property != null ? env1_13[property] : null;
}
function value_63934() { // fn#63934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1264, offset: 0x01b96acc, size: 111 bytes, params: 1, frame: 21
var r2;
var property;
var value4;
var property2;
var state;
var value5;
const object2 = {};
const Object = global.Object;
const value2 = Object.entries(env1_13);
let length = value2.length;
const value3 = 0;
if (value3 < length) {
r2 = value3;
while (true) {
property = value2[r2];
value4 = env1_8(property, 2);
property = value4[value3];
property2 = value4[1];
property = env1_15[property];
if (property != null) {
state = property2.state;
object2[property] = state;
}
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
length = value2.length;
if (value5 < length) {
r2 = value5;
continue;
}
break;
}
}
return object2;
}
function value_63935(a0, a1) { // fn#63935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1437, offset: 0x01b96b3b, size: 169 bytes, params: 3, frame: 16
const InteractionState = (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState;
const value = environment.__proto__;
const property = env1_14[a0];
let r0 = property != null && env1_13[property] != null && env1_13[property].state !== InteractionState.FAILED;
r0 = !r0 ? env1_13[a1] != null && env1_13[a1].state !== InteractionState.FAILED : r0;
return !r0;
}
function value_63938(a0) { // fn#63938, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:1753, offset: 0x01b96be4, size: 93 bytes, params: 2, frame: 7
var value;
var property;
if (a0 != null) {
value = environment.__proto__;
property = env1_13[a0];
if (property != null) {
return {interaction: property, messageId: env1_15[a0]};
}
property = env1_18[a0];
value = undefined;
return property != null ? {interaction: property.interaction, messageId: property.messageId} : value;
}
}
function _fun63940() { // fn#63940, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:2058, offset: 0x01b96c79, size: 127 bytes, params: 1, frame: 20
var r2;
var property;
var value5;
var insertedAt;
var value6;
var value7;
const Date = global.Date;
const value = Date.now();
const Object = global.Object;
const value3 = Object.entries(env1_18);
let length = value3.length;
const value4 = 0;
if (value4 < length) {
r2 = value4;
while (true) {
property = value3[r2];
value5 = env1_8(property, 2);
property = value5[value4];
insertedAt = value5[1].insertedAt;
value6 = value - insertedAt;
if (value6 > env1_12) {
delete env1_18[property];
}
value7 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
length = value3.length;
if (value7 < length) {
r2 = value7;
continue;
}
break;
}
}
}
function _fun63952(a0) { // fn#63952, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8235:4113, offset: 0x01b97169, size: 39 bytes, params: 2, frame: 4
const user_id = a0.user_id;
return user_id === env0_1 && a0.session_id === env0_0;
}