90 lines
2.7 KiB
TypeScript
90 lines
2.7 KiB
TypeScript
// Metro module 10571 (f10572).
|
|
import { EMOJI_PICKER_EMOJI_TO_SHOW_COUNT } from "../calls/CallConstants";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import Durations from "../../utils/Durations";
|
|
import { debounce, uniqBy } from "../../_bundle/Module12";
|
|
import { getEffectAnnouncement } from "./VoiceChannelEffectsUtils";
|
|
import { AccessibilityAnnouncer } from "../../design/shared";
|
|
import Module589 from "../../_bundle/Module589";
|
|
let c7106_3;
|
|
let c7106_5 = [];
|
|
let c7106_6 = {};
|
|
let c7106_7 = [];
|
|
let c7106_8 = [];
|
|
let c7106_9 = 10 * Durations.Millis.SECOND;
|
|
let c7106_10 = debounce(() => {
|
|
AccessibilityAnnouncer.announce(getEffectAnnouncement(c7106_7), "polite");
|
|
c7106_7 = [];
|
|
}, 500);
|
|
class VoiceChannelEffectsStore extends Module589.Store {
|
|
static displayName = "VoiceChannelEffectsStore";
|
|
get recentlyUsedEmojis() {
|
|
return c7106_5;
|
|
}
|
|
get isOnCooldown() {
|
|
return c7106_3 != null && new Date() < c7106_3;
|
|
}
|
|
get effectCooldownEndTime() {
|
|
return c7106_3;
|
|
}
|
|
getEffectForUserId(a0) {
|
|
return c7106_6[a0];
|
|
}
|
|
}
|
|
const voiceChannelEffectsStore = new VoiceChannelEffectsStore(Dispatcher, {
|
|
VOICE_CHANNEL_EFFECT_CLEAR: function handleClearVoiceChannelEffect({ userId }) {
|
|
if (c7106_6[userId] != null) {
|
|
delete c7106_6[userId];
|
|
}
|
|
},
|
|
VOICE_CHANNEL_EFFECT_RECENT_EMOJI: function handleAddRecentlyUsedEmojis({ emoji }) {
|
|
if (emoji != null) {
|
|
c7106_5.unshift(emoji);
|
|
const r16 = uniqBy(c7106_5, "name");
|
|
c7106_5 = r16;
|
|
if (r16.length > EMOJI_PICKER_EMOJI_TO_SHOW_COUNT + 1) {
|
|
c7106_5.pop();
|
|
}
|
|
}
|
|
},
|
|
VOICE_CHANNEL_EFFECT_SEND: function handleReceivedVoiceChannelEffect({ emoji, userId, animationType }) {
|
|
if (emoji != null && animationType != null) {
|
|
c7106_6[userId] = {
|
|
emoji,
|
|
sentAt: Date.now(),
|
|
animationType
|
|
};
|
|
c7106_7 = [...c7106_7, {
|
|
emojiName: emoji.name,
|
|
userId
|
|
}];
|
|
c7106_10();
|
|
}
|
|
},
|
|
VOICE_CHANNEL_EFFECT_SENT_LOCAL: function handleVoiceChannelEffectSentLocal() {
|
|
const date = new Date();
|
|
const r18 = [date, ...c7106_8].slice(0, 20);
|
|
c7106_8 = r18;
|
|
if (r18.length >= 20) {
|
|
const r20 = c7106_8;
|
|
const r9 = r20[r20.length - 1];
|
|
const r27 = date.getTime() - r9.getTime();
|
|
if (r27 < c7106_9) {
|
|
c7106_3 = new Date(date.getTime() + c7106_9 - r27);
|
|
}
|
|
}
|
|
},
|
|
VOICE_CHANNEL_EFFECT_UPDATE_TIME_STAMP: function handleTimestampUpdate({ cooldownEndsAtMs }) {
|
|
c7106_3 = new Date(Date.now() + cooldownEndsAtMs);
|
|
}
|
|
});
|
|
export default voiceChannelEffectsStore;
|
|
export function clearVoiceChannelEffectForUser(a0) {
|
|
if (a0 != null) {
|
|
Dispatcher.dispatch({
|
|
type: "VOICE_CHANNEL_EFFECT_CLEAR",
|
|
userId: a0
|
|
});
|
|
}
|
|
}
|