204 lines
6.1 KiB
TypeScript
204 lines
6.1 KiB
TypeScript
// Metro module 6142 (f6143).
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import SelectedChannelStore from "../../stores/SelectedChannelStore";
|
|
import PoggermodeSettingsStore from "./PoggermodeSettingsStore";
|
|
import { ShakeLevel, ShakeLocation } from "./PoggermodeConstants";
|
|
import { ComponentActions } from "../../Constants";
|
|
import { SecondaryIndexMap } from "../../_bundle/Module3813";
|
|
import { Interval } from "../../_bundle/Timeout";
|
|
import * as _PoggermodeUtils from "./PoggermodeUtils";
|
|
import { getComboShakeIntensity } from "./PoggermodeUtils";
|
|
import { ComponentDispatch } from "../../utils/ComponentDispatchUtils";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c3884_8, c3884_9, c3884_10, c3884_12;
|
|
const updateCombo = function updateCombo(rest) {
|
|
const r1 = void 0 === void 0 ? true : void 0;
|
|
const r25 = c3884_9.get(`${rest.userId}-${rest.channelId}`);
|
|
let value = rest.value;
|
|
if (value == null) {
|
|
value = r25?.value;
|
|
}
|
|
if (value == null) {
|
|
value = 0;
|
|
}
|
|
const r16 = Math;
|
|
let multiplier = rest.multiplier;
|
|
if (multiplier == null) {
|
|
multiplier = r25?.multiplier;
|
|
}
|
|
if (multiplier == null) {
|
|
multiplier = 1;
|
|
}
|
|
const r26 = {
|
|
...r25,
|
|
...rest,
|
|
value,
|
|
multiplier: r16.min(multiplier, 7)
|
|
};
|
|
let decayInterval2 = r25?.decayInterval;
|
|
if (decayInterval2 == null) {
|
|
decayInterval2 = new Interval();
|
|
}
|
|
r26.decayInterval = decayInterval2;
|
|
let c15497_0 = r26;
|
|
c3884_9.set(`${rest.userId}-${rest.channelId}`, r26);
|
|
if (r1) {
|
|
const decayInterval = r26.decayInterval;
|
|
if (decayInterval != null) {
|
|
decayInterval.start(1000, () => {
|
|
L10: {
|
|
const r21 = c3884_9.get(`${c15497_0.userId}-${c15497_0.channelId}`);
|
|
if (r21 != null) {
|
|
const r2 = c15497_0.multiplier !== r21.multiplier && c15497_0.value !== r21.value;
|
|
if (!(r21.value <= 0) && !r2) {
|
|
updateCombo({
|
|
...r21,
|
|
value: r21.value - 1
|
|
});
|
|
c3884_12.emitChange();
|
|
break L10;
|
|
}
|
|
const decayInterval = r21.decayInterval;
|
|
if (decayInterval != null) {
|
|
decayInterval.stop();
|
|
}
|
|
if (r21.value <= 0) {
|
|
updateCombo({
|
|
...r21,
|
|
value: 0,
|
|
multiplier: 1
|
|
});
|
|
c3884_12.emitChange();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
c3884_8 = new Set();
|
|
c3884_9 = new SecondaryIndexMap(function(a0) {
|
|
return [a0.userId, a0.channelId];
|
|
}, function(a0) {
|
|
return `${a0.channelId}-${a0.userId}`;
|
|
});
|
|
c3884_10 = new SecondaryIndexMap(function(a0) {
|
|
return [a0.messageId, a0.channelId, a0.combo.userId];
|
|
}, function(a0) {
|
|
return `${a0.channelId}-${a0.combo.userId}-${a0.messageId}`;
|
|
});
|
|
class PoggermodeStore extends Module589.Store {
|
|
static displayName = "PoggermodeStore";
|
|
initialize() {
|
|
this.waitFor(AuthenticationStore, PoggermodeSettingsStore, SelectedChannelStore);
|
|
}
|
|
getComboScore(a0, a1) {
|
|
const r12 = c3884_9.get(`${a0}-${a1}`);
|
|
return r12 == null ? 0 : _PoggermodeUtils.getComboScore(r12);
|
|
}
|
|
getUserCombo(a0, a1) {
|
|
return c3884_9.get(`${a0}-${a1}`);
|
|
}
|
|
isComboing(a0, a1) {
|
|
const userCombo = this.getUserCombo(a0, a1);
|
|
return userCombo != null && userCombo.value >= PoggermodeSettingsStore.combosRequiredCount && (userCombo != null && (userCombo.value > 0 || userCombo?.multiplier > 1));
|
|
}
|
|
getMessageCombo(a0) {
|
|
let r8 = c3884_10.get(a0)?.combo;
|
|
if (r8 == null) {
|
|
r8 = void 0;
|
|
}
|
|
return r8;
|
|
}
|
|
getMostRecentMessageCombo(a0) {
|
|
const r5 = c3884_10.values(a0);
|
|
return r5[r5.length - 1];
|
|
}
|
|
getUserComboShakeIntensity(a0, a1, a2, a3) {
|
|
const userCombo = this.getUserCombo(a0, a1);
|
|
return userCombo != null ? getComboShakeIntensity(userCombo, a3) * a2 : 0;
|
|
}
|
|
}
|
|
c3884_12 = new PoggermodeStore(Dispatcher, {
|
|
POGGERMODE_UPDATE_COMBO: function handleComboing(a0) {
|
|
a0.type;
|
|
const { type, ...rest } = a0;
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
updateCombo(rest);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
},
|
|
POGGERMODE_UPDATE_MESSAGE_COMBO: function handleUpdateMessageCombo({ comboMessage }) {
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
c3884_10.set(comboMessage.messageId, comboMessage);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
},
|
|
MESSAGE_CREATE: function handleIncomingMessage({ channelId, message }) {
|
|
let intensity;
|
|
let id;
|
|
const { mentions, author, nonce } = message;
|
|
id = void 0;
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
id = AuthenticationStore.getId();
|
|
let r25 = author?.id === id;
|
|
if (r25) {
|
|
let r1 = nonce != null && !c3884_8.has(nonce);
|
|
if (r1) {
|
|
c3884_8.add(nonce);
|
|
r1 = true;
|
|
}
|
|
r25 = r1;
|
|
}
|
|
if (r25) {
|
|
let r16 = author?.id;
|
|
if (r16 == null) {
|
|
r16 = "???";
|
|
}
|
|
const r39 = c3884_9.get(`${r16}-${channelId}`);
|
|
if (PoggermodeSettingsStore.screenshakeEnabled && PoggermodeSettingsStore.screenshakeEnabledLocations[ShakeLocation.MENTION] && mentions != null && mentions.find((mention) => mention.id === id) != null) {
|
|
if (r39 != null) {
|
|
let r60 = getComboShakeIntensity(r39, ShakeLevel.LEVEL_4);
|
|
if (r60 == null) {
|
|
r60 = 0.001;
|
|
}
|
|
intensity = r60;
|
|
} else {
|
|
intensity = 4 * Math.random();
|
|
}
|
|
ComponentDispatch.dispatch(ComponentActions.SHAKE_APP, {
|
|
duration: 1000,
|
|
intensity
|
|
});
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
export default c3884_12;
|
|
export function isComboing(a0) {
|
|
return a0 != null && (a0.value > 0 || a0?.multiplier > 1);
|
|
}
|
|
export function getComboId(a0) {
|
|
return `${a0.userId}-${a0.channelId}`;
|
|
}
|
|
export function shouldTrackMessage(a0, a1, a2, a3) {
|
|
let r1 = a0 === a1;
|
|
if (r1) {
|
|
let r7 = a2 != null && !a3.has(a2);
|
|
if (r7) {
|
|
a3.add(a2);
|
|
r7 = true;
|
|
}
|
|
r1 = r7;
|
|
}
|
|
return r1;
|
|
}
|