288 lines
8.7 KiB
TypeScript
288 lines
8.7 KiB
TypeScript
// Module ID: 7459
|
|
// Function ID: 7460
|
|
// Name: PoggermodeStore
|
|
// Dependencies: [502, 2103, 7162, 7163, 1085, 4504, 2046, 7460, 1121, 504, 584, 2]
|
|
// Exports: getComboId, isComboing, shouldTrackMessage
|
|
|
|
// Module 7459 (PoggermodeStore)
|
|
import get_initializedDefault from "get initialized" /* 504 */;
|
|
import DispatcherDefault from "Dispatcher" /* 584 */;
|
|
import Constants from "Constants" /* 1085 */;
|
|
import ComponentDispatchUtils from "ComponentDispatchUtils" /* 1121 */;
|
|
import SecondaryIndexMap from "SecondaryIndexMap" /* 4504 */;
|
|
import PoggermodeUtils from "PoggermodeUtils" /* 7460 */;
|
|
import AuthenticationStore from "AuthenticationStore" /* 502 */;
|
|
import SelectedChannelStore from "SelectedChannelStore" /* 2103 */;
|
|
import PoggermodeSettingsStore from "PoggermodeSettingsStore" /* 7162 */;
|
|
import PoggermodeConstants from "PoggermodeConstants" /* 7163 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
let hasOwnProperty;
|
|
let metroRequire;
|
|
function updateCombo(userId) {
|
|
let decayInterval1;
|
|
let min;
|
|
let num;
|
|
let num2;
|
|
const flag = true;
|
|
let obj = secondaryIndexMap;
|
|
const iter = secondaryIndexMap.get("" + userId.userId + "-" + userId.channelId);
|
|
let obj2 = { value: num, multiplier: min(num2, 7), decayInterval: decayInterval1 };
|
|
let merged = Object.assign(iter);
|
|
let merged1 = Object.assign(userId);
|
|
num = userId.value;
|
|
if (num == null) {
|
|
let value;
|
|
if (iter != null) {
|
|
value = iter.value;
|
|
}
|
|
num = value;
|
|
}
|
|
if (num == null) {
|
|
num = 0;
|
|
}
|
|
num2 = userId.multiplier;
|
|
const _Math = Math;
|
|
min = Math.min;
|
|
if (num2 == null) {
|
|
let multiplier;
|
|
if (iter != null) {
|
|
multiplier = iter.multiplier;
|
|
}
|
|
num2 = multiplier;
|
|
}
|
|
if (num2 == null) {
|
|
num2 = 1;
|
|
}
|
|
decayInterval1 = undefined;
|
|
if (iter != null) {
|
|
decayInterval1 = iter.decayInterval;
|
|
}
|
|
if (decayInterval1 == null) {
|
|
const self = this;
|
|
const self2 = this;
|
|
decayInterval1 = new obj2(2046).Interval();
|
|
}
|
|
const result = obj.set("" + userId.userId + "-" + userId.channelId, obj2);
|
|
if (flag) {
|
|
let decayInterval = obj2.decayInterval;
|
|
if (decayInterval != null) {
|
|
decayInterval.start(1000, () => {
|
|
const iter2 = secondaryIndexMap.get("" + obj2.userId + "-" + obj2.channelId);
|
|
if (null != iter2) {
|
|
const tmp = obj2.multiplier !== iter2.multiplier && obj2.value !== iter2.value;
|
|
if (iter2.value > 0) {
|
|
if (!tmp) {
|
|
const obj = { value: iter2.value - 1 };
|
|
const merged = Object.assign(iter2);
|
|
updateCombo(obj);
|
|
poggermodeStore.emitChange();
|
|
}
|
|
}
|
|
const decayInterval = iter2.decayInterval;
|
|
if (decayInterval != null) {
|
|
decayInterval.stop();
|
|
}
|
|
if (iter2.value <= 0) {
|
|
obj2 = { value: 0, multiplier: 1 };
|
|
const merged1 = Object.assign(iter2);
|
|
updateCombo(obj2);
|
|
poggermodeStore.emitChange();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
({ ShakeLevel: hasOwnProperty, ShakeLocation: metroRequire } = PoggermodeConstants);
|
|
const ComponentActions = Constants.ComponentActions;
|
|
const set = new Set();
|
|
const secondaryIndexMap = new SecondaryIndexMap.SecondaryIndexMap((arg0) => {
|
|
const items = [, ];
|
|
({ userId: arr[0], channelId: arr[1] } = arg0);
|
|
return items;
|
|
}, (channelId) => "" + channelId.channelId + "-" + channelId.userId);
|
|
const secondaryIndexMap1 = new SecondaryIndexMap.SecondaryIndexMap((combo) => {
|
|
const items = [, , ];
|
|
({ messageId: arr[0], channelId: arr[1] } = combo);
|
|
items[2] = combo.combo.userId;
|
|
return items;
|
|
}, (channelId) => "" + channelId.channelId + "-" + channelId.combo.userId + "-" + channelId.messageId);
|
|
const Store = get_initializedDefault.Store;
|
|
class PoggermodeStore extends Store {
|
|
initialize() {
|
|
this.waitFor(AuthenticationStore, PoggermodeSettingsStore, SelectedChannelStore);
|
|
}
|
|
getComboScore(arg0, arg1) {
|
|
const value = secondaryIndexMap.get("" + arg0 + "-" + arg1);
|
|
let num = 0;
|
|
if (null != value) {
|
|
const obj = PoggermodeUtils;
|
|
num = obj.getComboScore(value);
|
|
}
|
|
return num;
|
|
}
|
|
getUserCombo(id, channelId) {
|
|
return secondaryIndexMap.get("" + id + "-" + channelId);
|
|
}
|
|
isComboing(id, channelId) {
|
|
const iter = this.getUserCombo(id, channelId);
|
|
let tmp = null != iter && iter.value >= PoggermodeSettingsStore.combosRequiredCount;
|
|
if (tmp) {
|
|
let tmp3 = null != iter;
|
|
if (tmp3) {
|
|
let tmp4 = iter.value > 0;
|
|
if (!tmp4) {
|
|
let multiplier;
|
|
if (iter != null) {
|
|
multiplier = iter.multiplier;
|
|
}
|
|
tmp4 = multiplier > 1;
|
|
}
|
|
tmp3 = tmp4;
|
|
}
|
|
tmp = tmp3;
|
|
}
|
|
return tmp;
|
|
}
|
|
getMessageCombo(arg0) {
|
|
const value = secondaryIndexMap1.get(arg0);
|
|
let combo;
|
|
if (value != null) {
|
|
combo = value.combo;
|
|
}
|
|
return combo;
|
|
}
|
|
getMostRecentMessageCombo(arg0) {
|
|
const values = secondaryIndexMap1.values(arg0);
|
|
return values[values.length - 1];
|
|
}
|
|
getUserComboShakeIntensity(id, channelId, arg2, LEVEL_4) {
|
|
const userCombo = this.getUserCombo(id, channelId);
|
|
let num = 0;
|
|
if (null != userCombo) {
|
|
const obj = PoggermodeUtils;
|
|
num = obj.getComboShakeIntensity(userCombo, LEVEL_4) * arg2;
|
|
}
|
|
return num;
|
|
}
|
|
}
|
|
const prototype = PoggermodeStore.prototype;
|
|
PoggermodeStore.displayName = "PoggermodeStore";
|
|
let obj = {
|
|
POGGERMODE_UPDATE_COMBO: function handleComboing(arg0) {
|
|
const merged = Object.assign(arg0, Object.assign({ type: 0 }));
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
updateCombo(merged);
|
|
} else {
|
|
return false;
|
|
}
|
|
},
|
|
POGGERMODE_UPDATE_MESSAGE_COMBO: function handleUpdateMessageCombo(comboMessage) {
|
|
comboMessage = comboMessage.comboMessage;
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
const result = secondaryIndexMap1.set(comboMessage.messageId, comboMessage);
|
|
} else {
|
|
return false;
|
|
}
|
|
},
|
|
MESSAGE_CREATE: function handleIncomingMessage(message) {
|
|
let author;
|
|
let mentions;
|
|
let nonce;
|
|
({ mentions, author, nonce } = message.message);
|
|
let id;
|
|
const channelId = message.channelId;
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
id = AuthenticationStore.getId();
|
|
let id1;
|
|
if (author != null) {
|
|
id1 = author.id;
|
|
}
|
|
let tmp6 = id1 === id;
|
|
if (tmp6) {
|
|
let flag2 = null != nonce && !obj.has(nonce);
|
|
if (flag2) {
|
|
set.add(nonce);
|
|
flag2 = true;
|
|
}
|
|
tmp6 = flag2;
|
|
}
|
|
if (tmp6) {
|
|
let str;
|
|
const get = secondaryIndexMap.get;
|
|
if (author != null) {
|
|
str = author.id;
|
|
}
|
|
if (str == null) {
|
|
str = "???";
|
|
}
|
|
const _HermesInternal = HermesInternal;
|
|
const value = get("" + str + "-" + channelId);
|
|
if (PoggermodeSettingsStore.screenshakeEnabled) {
|
|
if (PoggermodeSettingsStore.screenshakeEnabledLocations[metroRequire.MENTION]) {
|
|
if (null != mentions) {
|
|
if (null != mentions.find((id) => id.id === id)) {
|
|
let result;
|
|
if (null != value) {
|
|
const obj2 = PoggermodeUtils;
|
|
let num2 = obj2.getComboShakeIntensity(value, hasOwnProperty.LEVEL_4);
|
|
if (num2 == null) {
|
|
num2 = 0.001;
|
|
}
|
|
result = num2;
|
|
} else {
|
|
const _Math = Math;
|
|
result = 4 * Math.random();
|
|
}
|
|
const ComponentDispatch = ComponentDispatchUtils.ComponentDispatch;
|
|
const obj3 = { duration: 1000, intensity: result };
|
|
ComponentDispatch.dispatch(ComponentActions.SHAKE_APP, obj3);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
const poggermodeStore = new PoggermodeStore(DispatcherDefault, obj);
|
|
let result = size.fileFinishedImporting("modules/poggermode/PoggermodeStore.tsx");
|
|
|
|
export default poggermodeStore;
|
|
export const isComboing = function isComboing(value) {
|
|
let tmp = null != value;
|
|
if (tmp) {
|
|
let tmp2 = value.value > 0;
|
|
if (!tmp2) {
|
|
let multiplier;
|
|
if (value != null) {
|
|
multiplier = value.multiplier;
|
|
}
|
|
tmp2 = multiplier > 1;
|
|
}
|
|
tmp = tmp2;
|
|
}
|
|
return tmp;
|
|
};
|
|
export const getComboId = function getComboId(userId) {
|
|
return "" + userId.userId + "-" + userId.channelId;
|
|
};
|
|
export const shouldTrackMessage = function shouldTrackMessage(arg0, arg1, arg2, has) {
|
|
let tmp = arg0 === arg1;
|
|
if (tmp) {
|
|
let flag = null != arg2 && !has.has(arg2);
|
|
if (flag) {
|
|
has.add(arg2);
|
|
flag = true;
|
|
}
|
|
tmp = flag;
|
|
}
|
|
return tmp;
|
|
};
|