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

317 lines
14 KiB
TypeScript

/* Metro module 7219; source: modules/poggermode/PoggermodeStore.tsx; dependencies: [6, 7, 15, 17, 18, 1226, 1934, 7072, 7073, 661, 3780, 4041, 7220, 1239, 566, 694, 2] */
function _fun57722(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57722, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:6, offset: 0x016b47a9, size: 586 bytes, params: 8, frame: 23
const env0_0 = require;
const closure = function(a0) {
var r1;
var r0;
var value = a0 != null;
if (value) {
value = a0.value > 0;
if (value) {
r1 = value;
} else {
value = undefined;
value = (a0 == null ? value : a0.multiplier) > 1;
r1 = value;
}
r0 = r1;
} else {
r0 = value;
}
return r0;
};
const closure2 = function(a0, a1, a2, a3) {
var r1;
var r0;
var value = a0 === a1;
if (value) {
r1 = a2 != null && !a3.has(a2);
if (r1) {
a3.add(a2);
r1 = true;
}
r0 = r1;
} else {
r0 = value;
}
return r0;
};
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 authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const selectedChannelStore = importDefault(1934) /* metro dependency 1934: SelectedChannelStore */;
const poggermodeSettingsStore = importDefault(7072) /* metro dependency 7072: PoggermodeSettingsStore */;
const poggermodeConstantsModule = require(7073) /* metro dependency 7073: PoggermodeConstants */;
const env0_10 = poggermodeConstantsModule.ShakeLevel;
const env0_11 = poggermodeConstantsModule.ShakeLocation;
const env0_12 = (require(661) /* metro dependency 661: Constants */).ComponentActions;
const Set = global.Set;
const set = new Set();
const SecondaryIndexMap = (require(3780) /* metro dependency 3780: SecondaryIndexMap */).SecondaryIndexMap;
let secondaryIndexMap = new SecondaryIndexMap(function({userId, channelId}) {
return [userId, channelId];
}, function({userId, channelId}) {
return '' + channelId + '-' + userId;
});
secondaryIndexMap = new SecondaryIndexMap(function(a0) {
var messageId = a0.messageId;
var channelId = a0.channelId;
var userId = a0.combo.userId;
return [messageId, channelId, userId];
}, function(a0) {
var messageId = a0.messageId;
var channelId = a0.channelId;
var userId = a0.combo.userId;
return '' + channelId + '-' + userId + '-' + messageId;
});
const closure7 = function({userId, channelId}) {
return '' + userId + '-' + channelId;
};
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
_fun57735(Store).displayName = 'PoggermodeStore';
secondaryIndexMap = new secondaryIndexMap(importDefault(694) /* metro dependency 694: Dispatcher */,
{POGGERMODE_UPDATE_COMBO: function(a0) {
var r3;
a0.type;
var value = Object.create(null);
value.type = 0;
value = copyDataProperties({}, a0, value, r3);
if (PoggermodeSettingsStore.isEnabled()) {
updateCombo_57727(value);
return undefined;
}
return false;
}, POGGERMODE_UPDATE_MESSAGE_COMBO: POGGERMODE_UPDATE_MESSAGE_COMBO, MESSAGE_CREATE: MESSAGE_CREATE_57746});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/poggermode/PoggermodeStore.tsx');
exports.default = secondaryIndexMap;
exports.isComboing = closure;
exports.getComboId = closure7;
exports.shouldTrackMessage = closure2;
}
function _isNativeReflectConstruct_57723() { // fn#57723, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:248, offset: 0x016b49f3, 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_57723_isNativeReflectConstruct = function() {
return !!result;
})();
}
function updateCombo_57727(a0) { // fn#57727, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:914, offset: 0x016b4a86, size: 327 bytes, params: 2, frame: 22
var interval;
const value = undefined;
value !== value;
let binding = env0_14;
const value3 = binding.get(getComboId_57734(a0));
const object2 = {};
copyDataProperties(object2, value3, undefined);
copyDataProperties(object2, a0, undefined);
let r7 = a0.value ?? (value3 == null ? value : value3.value);
object2['value'] = r7 ?? 0;
const Math = global.Math;
object2['multiplier'] = Math.min(a0.multiplier ?? (value3 == null ? value : value3.multiplier) ?? 1, 7);
let decayInterval = value3 == null ? value : value3.decayInterval;
if (decayInterval != null) {
r7 = decayInterval;
} else {
interval = new (require(4041) /* metro dependency 4041: Timers */).Interval();
}
object2['decayInterval'] = r7;
binding = env0_14;
binding.set(getComboId_57734(a0), object2);
decayInterval = object2.decayInterval;
if (decayInterval != null) {
decayInterval.start(1000, _fun57728);
}
return value;
}
function _fun57735(a0) { // fn#57735, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:1674, offset: 0x016b4dd2, size: 214 bytes, params: 2, frame: 16
const closure = PoggermodeStore;
env0_6(closure, a0);
return env0_3(closure, [{key: 'initialize', value: function() {
this.waitFor(AuthenticationStore, PoggermodeSettingsStore, SelectedChannelStore);
}}, {key: 'getComboScore', value: value_57738}, {key: 'getUserCombo', value: value_57739}, {key: 'isComboing',
value: value_57740}, {key: 'getMessageCombo', value: value_57741}, {key: 'getMostRecentMessageCombo',
value: value_57742}, {key: 'getUserComboShakeIntensity', value: value_57743}]);
}
function POGGERMODE_UPDATE_MESSAGE_COMBO({comboMessage}) { // fn#57745, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2926, offset: 0x016b5086, size: 57 bytes, params: 2, frame: 13
var binding;
if (PoggermodeSettingsStore.isEnabled()) {
binding = env0_15;
binding.set(comboMessage.messageId, comboMessage);
return undefined;
}
return false;
}
function MESSAGE_CREATE_57746({channelId, message}) { // fn#57746, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:3078, offset: 0x016b50bf, size: 422 bytes, params: 2, frame: 24
var r4;
var binding;
var value5;
var moduleValue;
var ComponentDispatch;
const mentions = message.mentions;
const author = message.author;
if (PoggermodeSettingsStore.isEnabled()) {
if (shouldTrackMessage(author?.id, AuthenticationStore.getId(), message.nonce, env0_13)) {
binding = env0_14;
value5 = binding.get(getComboId_57734({userId: author?.id ?? '???', channelId: channelId}));
if (PoggermodeSettingsStore.screenshakeEnabled) {
if (PoggermodeSettingsStore.screenshakeEnabledLocations[ShakeLocation.MENTION]) {
if (mentions == null) {
return false;
}
if (mentions.find(_fun57747) != null) {
if (value5 != null) {
moduleValue = require(7220) /* metro dependency 7220: PoggermodeUtils */;
r4 = moduleValue.getComboShakeIntensity(value5, ShakeLevel.LEVEL_4) ?? 0.001;
} else {
r4 = 4 * global.Math.random();
}
ComponentDispatch = (require(1239) /* metro dependency 1239: ComponentDispatchUtils */).ComponentDispatch;
ComponentDispatch.dispatch(ComponentActions.SHAKE_APP, {duration: 1000, intensity: r4});
return true;
}
return false;
}
return false;
}
return false;
}
}
return false;
}
function _fun57728() { // fn#57728, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:1298, offset: 0x016b4bcd, size: 244 bytes, params: 1, frame: 18
var updateCombo_57727Binding;
var object2;
var decayInterval;
const value3 = env1_14.get(getComboId_57734(env0_0));
if (value3 != null) {
if (value3.value <= 0) {
decayInterval = value3.decayInterval;
if (decayInterval != null) {
decayInterval.stop();
}
if (value3.value <= 0) {
updateCombo_57727Binding = updateCombo_57727;
object2 = {};
copyDataProperties(object2, value3, undefined);
object2['value'] = 0;
object2['multiplier'] = 1;
updateCombo_57727Binding(object2);
env1_17.emitChange();
}
} else if (env0_0.multiplier !== value3.multiplier && env0_0.value !== value3.value) {
decayInterval = value3.decayInterval;
if (decayInterval != null) {
decayInterval.stop();
}
if (value3.value <= 0) {
updateCombo_57727Binding = updateCombo_57727;
object2 = {};
copyDataProperties(object2, value3, undefined);
object2['value'] = 0;
object2['multiplier'] = 1;
updateCombo_57727Binding(object2);
env1_17.emitChange();
}
} else {
updateCombo_57727Binding = updateCombo_57727;
object2 = {};
copyDataProperties(object2, value3, undefined);
object2['value'] = value3.value - 1;
updateCombo_57727Binding(object2);
env1_17.emitChange();
}
}
}
function value_57738(a0, a1) { // fn#57738, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2039, offset: 0x016b4ecb, size: 88 bytes, params: 3, frame: 14
var r0;
let value = environment.__proto__;
const value2 = env1_14.get(getComboId_57734({userId: a0, channelId: a1}));
if (value2 == null) {
r0 = 0;
} else {
value = require(7220) /* metro dependency 7220: PoggermodeUtils */;
value = value.getComboScore(value2);
r0 = value;
}
return r0;
}
function value_57739(a0, a1) { // fn#57739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2172, offset: 0x016b4f23, size: 46 bytes, params: 3, frame: 13
return env1_14.get(getComboId_57734({userId: a0, channelId: a1}));
}
function value_57740(a0, a1) { // fn#57740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2261, offset: 0x016b4f51, size: 71 bytes, params: 3, frame: 13
var value6;
let value = this.getUserCombo(a0, a1);
let r0 = value != null && value.value >= PoggermodeSettingsStore.combosRequiredCount;
if (r0) {
value6 = environment.__proto__;
value = isComboing(value);
r0 = value;
}
return r0;
}
function value_57741(a0) { // fn#57741, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2398, offset: 0x016b4f98, size: 51 bytes, params: 2, frame: 13
let value = environment.__proto__;
value = env1_15.get(a0);
const value2 = undefined;
return (value == null ? value2 : value.combo) ?? value2;
}
function value_57742(a0) { // fn#57742, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2517, offset: 0x016b4fcb, size: 38 bytes, params: 2, frame: 11
let value = environment.__proto__;
value = env1_15.values(a0);
return value[value.length - 1];
}
function value_57743(a0, a1, a2, a3) { // fn#57743, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:2610, offset: 0x016b4ff1, size: 81 bytes, params: 5, frame: 14
var r0;
var value3;
let value = this.getUserCombo(a0, a1);
if (value != null) {
value3 = environment.__proto__;
value = (require(7220) /* metro dependency 7220: PoggermodeUtils */).getComboShakeIntensity(value, a3);
value *= a2;
r0 = value;
} else {
r0 = 0;
}
return r0;
}