Files
discord-decomp/sources/modules/poggermode/PoggermodeStore.tsx
T
2026-07-28 01:06:53 +03:00

336 lines
16 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] */
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 AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
import SelectedChannelStore from '../../stores/SelectedChannelStore.tsx'; /* Metro dependency 1934 */
import PoggermodeSettingsStore from './PoggermodeSettingsStore.tsx'; /* Metro dependency 7072 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as SecondaryIndexMapModule from '../../external/discord_common/js/packages/secondary-index-map/SecondaryIndexMap.tsx'; /* Metro dependency 3780 */
import * as PoggermodeConstantsModule from './PoggermodeConstants.tsx'; /* Metro dependency 7073 */
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 Set = global.Set;
const set = new Set();
const SecondaryIndexMap = (SecondaryIndexMapModule).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 = (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});
(FileImportTrackerModule).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 object = {};
copyDataProperties(object, value3, undefined);
copyDataProperties(object, a0, undefined);
let r7 = a0.value ?? (value3 == null ? value : value3.value);
object['value'] = r7 ?? 0;
const Math = global.Math;
object['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();
}
object['decayInterval'] = r7;
binding = env0_14;
binding.set(getComboId_57734(a0), object);
decayInterval = object.decayInterval;
if (decayInterval != null) {
decayInterval.start(1000, _fun57728);
}
return value;
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 object;
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;
object = {};
copyDataProperties(object, value3, undefined);
object['value'] = 0;
object['multiplier'] = 1;
updateCombo_57727Binding(object);
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;
object = {};
copyDataProperties(object, value3, undefined);
object['value'] = 0;
object['multiplier'] = 1;
updateCombo_57727Binding(object);
env1_17.emitChange();
}
} else {
updateCombo_57727Binding = updateCombo_57727;
object = {};
copyDataProperties(object, value3, undefined);
object['value'] = value3.value - 1;
updateCombo_57727Binding(object);
env1_17.emitChange();
}
}
}
}
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 PoggermodeStore2 = PoggermodeStore;
Inherits(PoggermodeStore2, a0);
return CreateClass(PoggermodeStore2, [{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 PoggermodeStore() { // fn#57736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:1686, offset: 0x01176269, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_2(this, PoggermodeStore);
const value3 = env1_5(PoggermodeStore);
return env1_4(this, _isNativeReflectConstruct_57723() ? global.Reflect.construct(value3, arguments,
env1_5(this).constructor) : value3.apply(this, arguments));
}
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;
}
}
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;
const poggermodeSettingsStoreBinding = PoggermodeSettingsStore;
if (poggermodeSettingsStoreBinding.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;
const nonce = message.nonce;
const poggermodeSettingsStoreBinding = PoggermodeSettingsStore;
if (poggermodeSettingsStoreBinding.isEnabled()) {
if (shouldTrackMessage(author?.id, AuthenticationStore.getId(), 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 _fun57747({id}) { // fn#57747, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7397:3444, offset: 0x00db0c48, size: 21 bytes, params: 2, frame: 2
return id === env0_0;
}
}
}
global.__d(_fun57722, 7219, [6, 7, 15, 17, 18, 1226, 1934, 7072, 7073, 661, 3780, 4041, 7220, 1239, 566, 694,
2]) /* metro module 7219, dependencies: [6, 7, 15, 17, 18, 1226, 1934, 7072, 7073, 661, 3780, 4041, 7220, 1239, 566, 694, 2] */;