This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,36 @@
// Metro module 13593 (f13594).
import AuthenticationStore from "../../stores/AuthenticationStore";
import MediaEngineStore from "../../stores/MediaEngineStore";
import LifecycleManager from "../../lib/LifecycleManager";
import Dispatcher from "../../Dispatcher";
class BaseSoundboardManager extends LifecycleManager {
_playSound = () => {};
_stopAndClearSounds = () => {};
_handleToggleSelfDeafened = () => {
if (MediaEngineStore.isDeaf()) {
this._stopAndClearSounds();
}
};
_handleSoundboardSoundReceived = ({ soundId, soundVolume, userId, channelId }) => {
if (soundId != null && userId !== AuthenticationStore.getId()) {
return this._playSound(soundId, soundVolume, userId, channelId);
}
};
_handleSoundboardSoundPlayLocally = ({ sound, channelId }) => this._playSound(sound.soundId, sound.volume, AuthenticationStore.getId(), channelId);
_handleVoiceChannelSelect = () => {
this._stopAndClearSounds();
};
_initialize() {
Dispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived);
Dispatcher.subscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally);
Dispatcher.subscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect);
Dispatcher.subscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened);
}
_terminate() {
Dispatcher.unsubscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived);
Dispatcher.unsubscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally);
Dispatcher.unsubscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect);
Dispatcher.unsubscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened);
}
}
export default BaseSoundboardManager;
@@ -0,0 +1,311 @@
// Metro module 8048 (f8049).
import SoundboardStore from "./SoundboardStore";
import { DEFAULT_SOUND_GUILD_ID } from "./SoundboardConstants";
import { Endpoints, AnalyticEvents } from "../../Constants";
import { MAX_FAVORITES, UserSettingsDelay } from "../user_settings/UserSettingsConstants";
import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest";
import { soundboardSoundFromAPI } from "./SoundboardTypes";
import Dispatcher from "../../Dispatcher";
import { captureOrIgnoreApiError } from "../errors/ErrorHandlingUtils";
import APIError from "../../errors/APIError";
import { getGuildIdsToFetchSoundsFor } from "./useGuildIdsToFetchSoundsFor";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import { FrecencyUserSettingsActionCreators } from "../user_settings/UserSettingsProtoActionCreators";
import Module12 from "../../_bundle/Module12";
import AlertActionCreators from "../../actions/AlertActionCreators";
import { intl, t } from "../../intl/index.native";
import { makeDiscoverableGuild } from "../../utils/GuildDiscoveryUtils";
function $mk79754($env) {
return (a0) => {
let env26092 = {
$parent: $env
};
env26092[0] = a0;
const r6 = $env.$parent;
const r4 = (0, r6[1])(r6[2][7]);
const r10 = $env[0];
const onSoundboardActionCompleted = function onSoundboardActionCompleted() {
const r3 = env26092.$parent.$parent;
(0, r3[1])(r3[2][7]).unsubscribe(env26092.$parent[0], env26092[1]);
setTimeout(env26092[0], 0);
};
env26092[1] = onSoundboardActionCompleted;
r4.subscribe(r10, onSoundboardActionCompleted);
};
}
function $mk115098($env) {
return (a0) => soundboardSoundFromAPI(a0, DEFAULT_SOUND_GUILD_ID);
}
let _maybeFetchDefaultSounds, _maybeFetchGuildSoundboardSounds;
let env5100 = {};
env5100[11] = function _fetchDefaultSoundsFromApi2() {
const r8 = async () => {
let c26091_0, c26091_1, c26091_2;
let c26091_3 = 0;
const r10 = env5100;
L10: {
try {
let env29881;
c26091_1 = r10;
const r26 = env29881 = {
$parent: r10
};
c26091_0 = r26;
env29881[0] = void 0;
c26091_3 = 1;
env29881[0] = (await HTTP.get({
url: Endpoints.SOUNDBOARD_DEFAULT_SOUNDS,
rejectWithError: rejectWithMigratedError()
})).body.map($mk115098(env5100));
Dispatcher.dispatch({
type: "SOUNDBOARD_FETCH_DEFAULT_SOUNDS_SUCCESS",
soundboardSounds: env29881[0]
});
c26091_3 = 0;
} catch ($e) {
const r24 = $e;
let r7 = r24;
c26091_2 = r24;
if (c26091_3 !== 0) {
while (true) {
try {
const r77 = c26091_2;
c26091_3 = 0;
env29881[1] = r77;
Dispatcher.dispatch({
type: "SOUNDBOARD_FETCH_DEFAULT_SOUNDS_FAILURE"
});
captureOrIgnoreApiError(new APIError(env29881[1]));
break L10;
} catch (r73) {
r7 = r73;
c26091_2 = r73;
if (c26091_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
};
env5100[11] = r8;
return r8.apply(this, arguments);
};
_maybeFetchDefaultSounds = function _maybeFetchDefaultSounds() {
if (SoundboardStore.shouldFetchDefaultSounds()) {
let env16214;
Dispatcher.dispatch({
type: "SOUNDBOARD_FETCH_DEFAULT_SOUNDS"
});
const r18 = env16214 = {
$parent: env5100
};
env16214[0] = "SOUNDBOARD_FETCH_DEFAULT_SOUNDS_SUCCESS";
const promise = new Promise($mk79754(r18));
(function _fetchDefaultSoundsFromApi() {
return env5100[11].apply(this, arguments);
})();
return promise;
}
return Promise.resolve();
};
_maybeFetchGuildSoundboardSounds = function _maybeFetchGuildSoundboardSounds() {
const guildIdsToFetchSoundsFor = getGuildIdsToFetchSoundsFor();
if (guildIdsToFetchSoundsFor.length === 0) {
return Promise.resolve();
}
let env16215;
const r15 = env16215 = {
$parent: env5100
};
env16215[0] = "SOUNDBOARD_SOUNDS_RECEIVED";
const promise = new Promise($mk79754(r15));
Dispatcher.dispatch({
type: "GUILD_SOUNDBOARD_FETCH"
});
Dispatcher.dispatch({
type: "REQUEST_SOUNDBOARD_SOUNDS",
guildIds: guildIdsToFetchSoundsFor
});
return promise;
};
env5100[10] = false;
export async function maybeFetchSoundboardSounds(c26093_0) {
let disableAnalytics;
let c29882_3;
c29882_3 = void 0;
let c29882_0 = performance.now();
const r29 = env5100[10];
let r30 = !r29;
if (!r29) {
const disableAnalytics2 = c26093_0?.disableAnalytics;
disableAnalytics = disableAnalytics2;
if (disableAnalytics2 == null) {
disableAnalytics = false;
}
r30 = !disableAnalytics;
}
let c29882_1 = r30;
if (r30) {
env5100[10] = true;
}
let c29882_2 = await Promise.all([_maybeFetchDefaultSounds(), _maybeFetchGuildSoundboardSounds()]);
if (c29882_1) {
c29882_3 = performance.now();
AnalyticsUtils.track(AnalyticEvents.EXPRESSION_PICKER_SOUNDBOARD_SOUNDS_LOADED, {
elapsed_ms: c29882_3 - c29882_0
});
}
return c29882_2;
}
export async function uploadSound(c26094_0) {
let c29883_0 = c26094_0.guildId;
let c29883_1 = c26094_0.name;
let c29883_2 = c26094_0.sound;
let c29883_3 = c26094_0.volume;
let c29883_4 = c26094_0.emojiId;
let c29883_5 = c26094_0.emojiName;
await void 0;
let c29883_6 = await HTTP.post({
url: Endpoints.GUILD_SOUNDBOARD_SOUNDS(c29883_0),
body: {
name: c29883_1,
sound: c29883_2,
volume: c29883_3,
emoji_id: c29883_4,
emoji_name: c29883_5
},
rejectWithError: rejectWithMigratedError()
});
return soundboardSoundFromAPI(c29883_6.body, c29883_0);
}
export async function updateSound(c26095_0) {
let c29884_0 = c26095_0.guildId;
let c29884_1 = c26095_0.soundId;
let c29884_2 = c26095_0.name;
let c29884_3 = c26095_0.volume;
let c29884_4 = c26095_0.emojiId;
let c29884_5 = c26095_0.emojiName;
await void 0;
let c29884_6 = await HTTP.patch({
url: Endpoints.GUILD_SOUNDBOARD_SOUND(c29884_0, c29884_1),
body: {
name: c29884_2,
volume: c29884_3,
emoji_id: c29884_4,
emoji_name: c29884_5
},
rejectWithError: rejectWithMigratedError()
});
return soundboardSoundFromAPI(c29884_6.body, c29884_0);
}
export async function deleteSound(c26096_0, c26096_1) {
await HTTP.del({
url: Endpoints.GUILD_SOUNDBOARD_SOUND(c26096_0, c26096_1),
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
});
}
export function addFavoriteSound(c16216_0) {
FrecencyUserSettingsActionCreators.updateAsync("favoriteSoundboardSounds", (a0) => {
let r0;
if (Module12.size(a0.soundIds) >= MAX_FAVORITES) {
AlertActionCreators.show({
title: intl.string(t["+XYXtZ"]),
body: intl.formatToPlainString(t.JaIyFi, {
count: MAX_FAVORITES
})
});
r0 = false;
} else {
const soundIds = a0.soundIds;
const r18 = soundIds.includes(c16216_0);
r0 = !r18;
if (!r18) {
a0.soundIds.push(c16216_0);
r0 = void 0;
}
}
return r0;
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
export function removeFavoriteSound(c16217_0) {
FrecencyUserSettingsActionCreators.updateAsync("favoriteSoundboardSounds", (a0) => {
a0.soundIds = a0.soundIds.filter((soundId) => soundId !== c16217_0);
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
export async function fetchSoundGuildData(c26097_0, c26097_1) {
let r65;
let c26097_4;
let c26097_5 = 0;
let c29885_0, c29885_1;
try {
c29885_0 = void 0;
c26097_5 = 1;
c29885_0 = await HTTP.get({
url: Endpoints.SOUNDBOARD_SOUND_GUILD_DATA(c26097_0, c26097_1),
rejectWithError: rejectWithMigratedError()
});
r65 = c29885_0.body != null ? makeDiscoverableGuild(c29885_0.body) : null;
c26097_5 = 0;
} catch ($e) {
const r29 = $e;
let r8 = r29;
c26097_4 = r29;
if (c26097_5 !== 0) {
while (true) {
try {
const r83 = c26097_4;
c26097_5 = 0;
c29885_1 = r83;
throw new APIError(c29885_1);
} catch (r79) {
r8 = r79;
c26097_4 = r79;
if (c26097_5 === 0) {
break;
}
}
}
}
throw r8;
}
return r65;
}
export function playSoundLocally(a0, a1, a2) {
Dispatcher.dispatch({
type: "GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY",
sound: a1,
channelId: a0,
trigger: a2
});
}
export function reportSoundStartedPlaying(a0, a1) {
Dispatcher.dispatch({
type: "GUILD_SOUNDBOARD_SOUND_PLAY_START",
soundId: a0,
userId: a1
});
}
export function reportSoundFinishedPlaying(a0, a1) {
Dispatcher.dispatch({
type: "GUILD_SOUNDBOARD_SOUND_PLAY_END",
soundId: a0,
userId: a1
});
}
export function updateUserSoundboardVolume(a0, a1) {
Dispatcher.dispatch({
type: "USER_SOUNDBOARD_SET_VOLUME",
volume: a0,
location: a1
});
}
export function muteCustomJoinSound(a0) {
Dispatcher.dispatch({
type: "SOUNDBOARD_MUTE_JOIN_SOUND",
channelId: a0
});
}
@@ -0,0 +1,23 @@
// Metro module 4636 (f4637).
const r14 = {
SUCCESS: 0,
0: "SUCCESS",
INTERRUPTED: 1,
1: "INTERRUPTED"
};
const set = new Set([r14.SUCCESS, r14.INTERRUPTED]);
export const MAX_LENGTH_SOUND_NAME = 32;
export const MAX_SOUND_FILE_SIZE_KILO_BYTES = 512;
export const MAX_SOUND_FILE_SIZE_BYTES = 524288;
export const MAX_SOUND_LENGTH_SECONDS = 5;
export const DEFAULT_SOUND_GUILD_ID = "0";
export { r14 as SoundboardPlaybackStatus };
export { set as SUCCESSFUL_SOUNDBOARD_PLAYBACKS };
export const SoundboardWheelSize = {
width: 424,
height: 424,
padding: 100
};
export const DEFAULT_KEYBIND = "ctrl+`";
export const EMPTY_SOUND_LIST = [];
export const CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID = "0";
@@ -0,0 +1,15 @@
// Metro module 15895 (f15896).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
kind: "user",
name: "2026-06-soundboard-frequently-used",
defaultConfig: {
enabled: false
},
variations: {
1: {
enabled: true
}
}
});
export default apexExperiment;
+319
View File
@@ -0,0 +1,319 @@
// Metro module 4635 (f4636).
import _slicedToArray from "../../_bundle/_slicedToArray";
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import UserStore from "../../stores/UserStore";
import { DEFAULT_SOUND_GUILD_ID } from "./SoundboardConstants";
import { AnalyticEvents } from "../../Constants";
import { UserSettingsTypes } from "../user_settings/UserSettingsConstants";
import Frecency from "../../lib/Frecency";
import Module3771 from "../../_bundle/Module3771";
import Module12 from "../../_bundle/Module12";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import { amplitudeToPerceptual } from "../../utils/PerceptualVolumeUtils";
import { SoundboardSettings } from "../user_settings/UserSettings";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c2830_9, c2830_10, c2830_11, c2830_12, NOT_FETCHED, NOT_FETCHED2, c2830_15, c2830_16, c2830_17, c2830_18, c2830_19, c2830_20, c2830_21, c2830_22, syncLocalSoundboardMutesFromUserSettings;
const handleSoundCreateOrUpdate = function handleSoundCreateOrUpdate({ sound }) {
const r16 = c2830_10.get(sound.guildId);
const r17 = r16 == null ? void 0 : r16.findIndex((item) => item.soundId === sound.soundId);
if (r16 != null && (r17 != null && r17 !== -1)) {
r16[r17] = sound;
c2830_10.set(sound.guildId, [...r16]);
} else if (r16 != null) {
if (r16 != null) {
r16.push(sound);
}
c2830_10.set(sound.guildId, [...r16]);
}
};
syncLocalSoundboardMutesFromUserSettings = function syncLocalSoundboardMutesFromUserSettings(a0) {
let r3 = a0 == null ? void 0 : a0.audioContextSettings?.user;
if (r3 == null) {
r3 = {};
}
for (const item of Object.entries(r3)) {
const r36 = _slicedToArray(item, 2);
const r37 = r36[0];
const soundboardMuted = r36[1].soundboardMuted;
if (soundboardMuted) {
c2830_12.add(r37);
} else {
c2830_12.delete(r37);
}
}
for (const item2 of c2830_12.keys()) {
if (r3[item2] == null) {
c2830_12.delete(item2);
}
}
};
c2830_9 = {
NOT_FETCHED: 0,
0: "NOT_FETCHED",
FETCHING: 1,
1: "FETCHING",
FETCHED: 2,
2: "FETCHED"
};
c2830_10 = new Map();
c2830_11 = new Map();
c2830_12 = new Set();
NOT_FETCHED = c2830_9.NOT_FETCHED;
NOT_FETCHED2 = c2830_9.NOT_FETCHED;
c2830_15 = new Set();
c2830_16 = new Map();
c2830_17 = Date.UTC(2026, 5, 29);
c2830_18 = new Frecency({
computeBonus: () => 100,
computeWeight: (a0) => {
if (a0 > Module3771().diff(c2830_17, "days")) {
return 0;
}
return a0 <= 3 ? 100 : a0 <= 15 ? 70 : a0 <= 30 ? 50 : a0 <= 45 ? 30 : a0 <= 80 ? 10 : 1;
},
lookupKey: (a0) => a0,
afterCompute: () => {}
});
c2830_19 = [];
c2830_20 = false;
c2830_21 = false;
c2830_22 = Module12.debounce((a0, a1) => {
AnalyticsUtils.track(AnalyticEvents.UPDATE_SOUNDBOARD_SETTINGS, {
volume: Math.round(amplitudeToPerceptual(a0)),
location_stack: a1
});
SoundboardSettings.updateSetting({
volume: a0
});
}, 1000);
class SoundboardStore extends Module589.Store {
static displayName = "SoundboardStore";
initialize() {
this.waitFor(UserSettingsProtoStore, UserStore);
syncLocalSoundboardMutesFromUserSettings(UserSettingsProtoStore.settings);
c2830_21 = SoundboardSettings.getSetting()?.volume === 0;
}
getOverlaySerializedState() {
return {
soundboardSounds: Object.fromEntries(c2830_10),
favoritedSoundIds: Array.from(c2830_15),
localSoundboardMutes: Array.from(c2830_12)
};
}
getSounds() {
return c2830_10;
}
getSoundsForGuild(a0) {
return c2830_10.get(a0);
}
getSound(a0, c14373_0) {
let r7 = c2830_10.get(a0);
if (r7 == null) {
r7 = [];
}
return r7.find((item) => item.soundId === c14373_0);
}
getSoundById(c14374_0) {
return Array.from(c2830_10.values()).flat().find((item) => item.soundId === c14374_0);
}
isFetchingSounds() {
return NOT_FETCHED2 === c2830_9.FETCHING;
}
isFetchingDefaultSounds() {
return NOT_FETCHED === c2830_9.FETCHING;
}
isFetching() {
return this.isFetchingSounds() || this.isFetchingDefaultSounds();
}
shouldFetchDefaultSounds() {
return NOT_FETCHED === c2830_9.NOT_FETCHED;
}
hasFetchedDefaultSounds() {
return NOT_FETCHED === c2830_9.FETCHED;
}
isUserPlayingSounds(a0) {
const r7 = c2830_16.get(a0);
return r7 != null && r7 > 0;
}
isPlayingSound(a0) {
return c2830_11.get(a0) != null;
}
isFavoriteSound(a0) {
return c2830_15.has(a0);
}
getFavorites() {
return c2830_15;
}
getFrequentlyUsedSoundIds() {
return c2830_18.frequently;
}
hasPendingUsage() {
return c2830_19.length > 0;
}
get playedSoundFrecencyWithoutFetchingLatest() {
return c2830_18;
}
isLocalSoundboardMuted(a0) {
return c2830_12.has(a0);
}
isSoundboardVolumeMuted() {
return c2830_21;
}
hasHadOtherUserPlaySoundInSession() {
return c2830_20;
}
hasFetchedAllSounds() {
return NOT_FETCHED2 === c2830_9.FETCHED && NOT_FETCHED === c2830_9.FETCHED;
}
isFetchingAnySounds() {
return NOT_FETCHED2 === c2830_9.FETCHING || NOT_FETCHED === c2830_9.FETCHING;
}
}
const soundboardStore = new SoundboardStore(Dispatcher, {
LOGOUT: function handleReset() {
c2830_10.clear();
c2830_11.clear();
c2830_16.clear();
c2830_20 = false;
NOT_FETCHED2 = c2830_9.NOT_FETCHED;
NOT_FETCHED = c2830_9.NOT_FETCHED;
c2830_21 = false;
c2830_19 = [];
c2830_18.overwriteHistory({});
},
GUILD_SOUNDBOARD_FETCH: function handleSoundboardFetch() {
NOT_FETCHED2 = c2830_9.FETCHING;
},
GUILD_SOUNDBOARD_SOUND_CREATE: handleSoundCreateOrUpdate,
GUILD_SOUNDBOARD_SOUND_UPDATE: handleSoundCreateOrUpdate,
GUILD_SOUNDBOARD_SOUND_DELETE: function handleSoundDelete({ soundId, guildId }) {
const r15 = c2830_10.get(guildId);
const r16 = r15 == null ? void 0 : r15.findIndex((item) => item.soundId === soundId);
if (!(r15 == null || r16 == null || r16 < 0)) {
r15.splice(r16, 1);
c2830_10.set(guildId, [...r15]);
}
},
GUILD_SOUNDBOARD_SOUND_PLAY_START: function handleSoundPlayStart({ soundId: soundId2, userId }) {
let r13 = c2830_11.get(soundId2);
if (r13 == null) {
r13 = 0;
}
const r9 = r13 + 1;
let r15 = c2830_16.get(userId);
if (r15 == null) {
r15 = 0;
}
const r7 = r15 + 1;
c2830_11.set(soundId2, r9);
c2830_16.set(userId, r7);
if (userId !== UserStore.getCurrentUser()?.id) {
c2830_20 = true;
}
},
GUILD_SOUNDBOARD_SOUND_PLAY_END: function handleSoundPlayEnd({ soundId: soundId2, userId }) {
let r10 = c2830_11.get(soundId2);
if (r10 == null) {
r10 = 0;
}
const r1 = r10 - 1;
let r13 = c2830_16.get(userId);
if (r13 == null) {
r13 = 0;
}
const r14 = r13 - 1;
if (r1 <= 0) {
c2830_11.delete(soundId2);
} else {
c2830_11.set(soundId2, r1);
}
if (r14 <= 0) {
c2830_16.delete(userId);
} else {
c2830_16.set(userId, r14);
}
},
GUILD_SOUNDBOARD_SOUNDS_UPDATE: function handleSoundsUpdate(a0) {
c2830_10.set(a0.guildId, a0.soundboardSounds);
},
USER_SOUNDBOARD_SET_VOLUME: function handleSetLocalVolume({ volume, location: location2 }) {
const r2 = c2830_21;
c2830_21 = volume === 0;
c2830_22(volume, location2);
if (r2 !== c2830_21) {
c2830_22.flush();
}
},
SOUNDBOARD_TRACK_USAGE: function handleTrackUsage({ soundId: soundId2 }) {
c2830_18.track(soundId2);
c2830_19.push({
key: soundId2,
timestamp: Date.now()
});
c2830_18.compute();
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect() {
c2830_11.clear();
c2830_16.clear();
},
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate({ settings, wasSaved }) {
const { type, proto } = settings;
if (UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS === type) {
const r30 = Set;
let r33 = proto == null ? void 0 : proto.favoriteSoundboardSounds?.soundIds;
if (r33 == null) {
r33 = [];
}
c2830_15 = new r30(r33);
if (wasSaved) {
c2830_19 = [];
}
if (proto?.playedSoundFrecency != null) {
let playedSounds = proto.playedSoundFrecency.playedSounds;
if (playedSounds == null) {
playedSounds = {};
}
c2830_18.overwriteHistory(Module12.mapValues(playedSounds, (a0) => ({
...a0,
recentUses: a0.recentUses.map(Number).filter((item) => item > 0)
})), c2830_19);
}
} else if (UserSettingsTypes.PRELOADED_USER_SETTINGS === type) {
syncLocalSoundboardMutesFromUserSettings(proto);
c2830_21 = SoundboardSettings.getSetting()?.volume === 0;
}
},
SOUNDBOARD_FETCH_DEFAULT_SOUNDS: function handleFetchDefaultSounds() {
NOT_FETCHED = c2830_9.FETCHING;
},
SOUNDBOARD_FETCH_DEFAULT_SOUNDS_SUCCESS: function handleFetchDefaultSoundsSuccess(a0) {
c2830_10.set(DEFAULT_SOUND_GUILD_ID, a0.soundboardSounds);
NOT_FETCHED = c2830_9.FETCHED;
},
SOUNDBOARD_SOUNDS_RECEIVED: function handleSoundboardSoundsReceived(a0) {
a0.updates.forEach((update) => {
c2830_10.set(update.guildId, update.sounds);
});
NOT_FETCHED2 = c2830_9.FETCHED;
},
GUILD_DELETE: function handleGuildDelete(a0) {
c2830_10.delete(a0.guild.id);
},
AUDIO_TOGGLE_LOCAL_SOUNDBOARD_MUTE: function handleToggleLocalSoundboardMute({ userId }) {
const r6 = c2830_12.has(userId);
if (r6) {
c2830_12.delete(userId);
} else {
c2830_12.add(userId);
}
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ soundboardStoreState }) {
c2830_10 = new Map(SnowflakeUtils.entries(soundboardStoreState.soundboardSounds));
c2830_15 = new Set(soundboardStoreState.favoritedSoundIds);
c2830_12 = new Set(soundboardStoreState.localSoundboardMutes);
}
});
export default soundboardStore;
export { c2830_9 as FetchState };
+86
View File
@@ -0,0 +1,86 @@
// Metro module 4642 (f4643).
const r13 = {
NONE: 0,
0: "NONE",
PLAY: 1,
1: "PLAY",
ADD: 2,
2: "ADD",
SOUNDMOJI: 3,
3: "SOUNDMOJI"
};
const r12 = {
ENTRY: "entry_sound",
EXIT: "exit_sound",
DEFAULT: "default"
};
const r11 = {
ADDED: "added",
UPDATED: "updated",
REMOVED: "removed"
};
const r28 = {
DEFAULT: "default",
CUSTOM: "custom"
};
const r30 = {
FAVORITES: 0,
0: "FAVORITES",
GUILD: 1,
1: "GUILD",
DEFAULTS: 2,
2: "DEFAULTS",
SEARCH: 3,
3: "SEARCH",
FREQUENTLY_USED: 4,
4: "FREQUENTLY_USED"
};
const r36 = {
SOUND: 0,
0: "SOUND",
ADD_SOUND: 1,
1: "ADD_SOUND"
};
const r39 = {
GIFT_CODE: 0,
0: "GIFT_CODE",
SOUNDBOARD: 1,
1: "SOUNDBOARD",
JOINED_VOICE_CHANNEL: 2,
2: "JOINED_VOICE_CHANNEL",
SOUNDMOJI: 3,
3: "SOUNDMOJI"
};
export { r13 as SoundButtonOverlay };
export { r12 as AnalyticsSoundType };
export { r11 as AnalyticsChangeType };
export { r28 as AnalyticsSoundSource };
export function soundboardSoundFromAPI(a0, a1) {
const { sound_id, emoji_id, emoji_name, user_id, available: _available, ...rest } = a0;
let available = a0.available;
if (available == null) {
available = true;
}
return {
...rest,
soundId: sound_id,
guildId: a1,
emojiId: emoji_id,
emojiName: emoji_name,
userId: user_id,
available
};
}
export function soundboardSoundToAPI({ soundId, guildId, emojiId, emojiName, userId, ...rest }) {
return {
...rest,
sound_id: soundId,
guild_id: guildId,
emoji_id: emojiId,
emoji_name: emojiName,
user_id: userId
};
}
export { r30 as SoundboardSoundGridSectionType };
export { r36 as SoundboardSoundItemType };
export { r39 as LocalSoundTrigger };
+227
View File
@@ -0,0 +1,227 @@
// Metro module 10776 (f10777).
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import { SILENT_JOIN_LEAVE_CHANNEL_TYPES } from "../../records/ChannelRecord";
import PermissionStore from "../../stores/PermissionStore";
import UserStore from "../../stores/UserStore";
import SoundboardStore from "./SoundboardStore";
import { DEFAULT_SOUND_GUILD_ID, CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID } from "./SoundboardConstants";
import { Permissions, AnalyticEvents } from "../../Constants";
import { ExpressionPickerViewType } from "../expression_picker/ExpressionPickerConstants";
import { SoundboardSettings } from "../user_settings/UserSettings";
import PremiumUtils from "../../utils/PremiumUtils";
import { getMuteStates } from "../video_calls/useMuteStates";
import { playSoundLocally, maybeFetchSoundboardSounds } from "./SoundboardActionCreators";
import { LocalSoundTrigger, AnalyticsChangeType, AnalyticsSoundType, AnalyticsSoundSource } from "./SoundboardTypes";
import { sendVoiceChannelCustomCallSoundEffect, sendVoiceChannelSoundboardEffect } from "../voice_channel_effects/VoiceChannelEffectsActionCreators";
import Dispatcher from "../../Dispatcher";
import getCurrentVoiceChannel from "../rpc/helpers/getCurrentVoiceChannel";
import { getCustomJoinSound } from "./useCustomJoinSound";
import { canSelectedVoiceChannelUseSoundboard } from "./canChannelUseSoundboard";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
import { ageEligibleForPremiumUpsell } from "../../utils/UserUtils";
import { DismissibleContent } from "../../_bundle/Module1358";
import { updateUserGuildSettings, UserSettingsDelay } from "../user_settings/UserSettingsProtoActionCreators";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import AppAnalyticsUtils from "../app_analytics/AppAnalyticsUtils";
function $mk85512() {
return (a0) => a0.joinSound != null;
}
function $mk116049($env) {
return function playCustomJoinSound(a0, a1) {
playSoundLocally(a1, a0, LocalSoundTrigger.JOINED_VOICE_CHANNEL);
sendVoiceChannelCustomCallSoundEffect(a1, a0, false);
};
}
let canUseSoundboardSound, canMakeSound;
let env7239 = {};
export function hasPermissionToPlaySound(a0, a1) {
return a1?.guild_id == null || PermissionStore.can(Permissions.USE_EXTERNAL_SOUNDS, a1) || a0.guildId === DEFAULT_SOUND_GUILD_ID || a0.guildId === a1?.guild_id;
}
canUseSoundboardSound = function canUseSoundboardSound(a0, a1, a2, r6 = true) {
return (PremiumUtils.canUseSoundboardEverywhere(a0) || a1.guildId === a2?.guild_id || a1.guildId === DEFAULT_SOUND_GUILD_ID) && (a2?.guild_id == null || PermissionStore.can(Permissions.USE_EXTERNAL_SOUNDS, a2) || a1.guildId === DEFAULT_SOUND_GUILD_ID || a1.guildId === a2?.guild_id) && (r6 ? a1.available : !r6);
};
canMakeSound = function canMakeSound(a0) {
const muteStates = getMuteStates({
channel: a0
});
const { mute, suppress } = muteStates;
return mute ? !mute : !suppress;
};
export function getAmplitudinalSoundboardVolume() {
let r12 = SoundboardSettings.getSetting()?.volume;
if (r12 == null) {
r12 = 100;
}
return r12;
}
export { canUseSoundboardSound };
export { canMakeSound };
export function playSound(a0, a1, a2, a3) {
playSoundLocally(a1, a0, LocalSoundTrigger.SOUNDBOARD);
sendVoiceChannelSoundboardEffect(a1, a0, false, a2, a3);
Dispatcher.dispatch({
type: "SOUNDBOARD_TRACK_USAGE",
soundId: a0.soundId
});
}
export function hasSetAnyCustomJoinSound() {
let r5 = UserSettingsProtoStore.settings.guilds?.guilds;
if (r5 == null) {
r5 = {};
}
return Object.values(r5).some($mk85512());
}
export async function maybePlayCustomJoinSound(c26811_0) {
let r98;
let c26811_1, c26811_2;
L26: {
L25: {
L24: {
let env30288;
const r17 = env7239;
c26811_2 = r17;
const r12 = env30288 = {
$parent: r17
};
c26811_1 = r12;
env30288[0] = void 0;
env30288[1] = void 0;
env30288[2] = void 0;
env30288[3] = void 0;
env30288[4] = void 0;
const currentUser = UserStore.getCurrentUser();
env30288[0] = currentUser;
const currentVoiceChannel = getCurrentVoiceChannel();
env30288[1] = currentVoiceChannel;
const customJoinSound = getCustomJoinSound(c26811_0);
env30288[2] = customJoinSound;
if (currentVoiceChannel == null) {
break L26;
}
if (SILENT_JOIN_LEAVE_CHANNEL_TYPES.has(currentVoiceChannel.type)) {
break L26;
}
if (customJoinSound == null) {
break L26;
}
if (!PremiumUtils.canUseCustomCallSounds(currentUser)) {
break L26;
}
if (!canSelectedVoiceChannelUseSoundboard()) {
break L26;
}
await maybeFetchSoundboardSounds();
env30288[3] = env30288[2].guildId === CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID ? DEFAULT_SOUND_GUILD_ID : env30288[2].guildId;
env30288[4] = SoundboardStore.getSound(env30288[3], env30288[2].soundId);
if (env30288[4] == null) {
break L25;
}
const r97 = (0, hasPermissionToPlaySound)(env30288[4], env30288[1]);
r98 = null;
if (!r97) {
break L24;
}
const r103 = (0, canUseSoundboardSound)(env30288[0], env30288[4], env30288[1], true);
r98 = null;
if (!r103) {
break L24;
}
const r108 = (0, canMakeSound)(env30288[1]);
r98 = null;
if (!r108) {
break L24;
}
const r110 = env30288[4];
const id = env30288[1].id;
$mk116049(env7239)(r110, id);
r98 = void 0;
}
return r98;
}
return void 0;
}
}
export function useSoundBoardDismissContentTypes({ isSoundboardButtonDisabled }) {
if (isSoundboardButtonDisabled === void 0) {
isSoundboardButtonDisabled = false;
}
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const r15 = [];
if (!isSoundboardButtonDisabled) {
let r19 = UserSettingsProtoStore.settings.guilds?.guilds;
if (r19 == null) {
r19 = {};
}
if (!Object.values(r19).some($mk85512())) {
const r30 = ageEligibleForPremiumUpsell(stateFromStores);
if (PremiumUtils.canUseCustomCallSounds(stateFromStores) || r30) {
r15.push(DismissibleContent.CUSTOM_CALL_SOUNDS_PICKER_UPSELL);
}
}
}
return r15;
}
export function removeCustomJoinSound(a0, location2) {
const guildId = a0;
updateUserGuildSettings(a0, (a0) => {
a0.joinSound = void 0;
const r3 = {
guildId,
changeType: AnalyticsChangeType.REMOVED,
soundType: AnalyticsSoundType.ENTRY,
location: location2
};
const { guildId: guildId2, changeType, soundType, soundSource } = r3;
AnalyticsUtils.track(AnalyticEvents.USER_CUSTOM_CALL_SOUND_SETTING_UPDATED, {
location_stack: r3.location,
guild_id: guildId2 !== "" ? Number(guildId2) : 0,
change_type: changeType,
sound_type: soundType,
sound_source: soundSource
});
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
export function updateCustomJoinSound(a0, c18257_1, location_stack) {
let c18257_0 = a0;
updateUserGuildSettings(a0, (a0) => {
let r8, r16, DEFAULT;
const r2 = c18257_1.guildId === DEFAULT_SOUND_GUILD_ID;
if (r2) {
DEFAULT = AnalyticsSoundSource.DEFAULT;
r16 = dependencyMap;
r8 = require;
} else {
DEFAULT = AnalyticsSoundSource.CUSTOM;
r16 = dependencyMap;
r8 = require;
}
const change_type = a0.joinSound != null ? r8(r16[13]).AnalyticsChangeType.UPDATED : r8(r16[13]).AnalyticsChangeType.ADDED;
a0.joinSound = {
soundId: c18257_1.soundId,
guildId: r2 ? CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID : c18257_1.guildId
};
const ENTRY = r8(r16[13]).AnalyticsSoundType.ENTRY;
importDefault(r16[23]).track(AnalyticEvents.USER_CUSTOM_CALL_SOUND_SETTING_UPDATED, {
location_stack,
guild_id: c18257_0 !== "" ? Number(c18257_0) : 0,
change_type,
sound_type: ENTRY,
sound_source: DEFAULT
});
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
export function trackCustomCallSoundExternallyDeleted(a0) {
AnalyticsUtils.track(AnalyticEvents.USER_CUSTOM_CALL_SOUND_SETTING_GUILD_REMOVED, {
location_stack: a0.location
});
}
export function trackSoundFavorited(a0) {
const sound = a0.sound;
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.EXPRESSION_FAVORITED, {
location: a0.location,
expression_type: ExpressionPickerViewType.SOUNDBOARD,
expression_id: sound.soundId,
expression_name: sound.name,
expression_guild_id: sound.guildId
});
}
@@ -0,0 +1,48 @@
// Metro module 10783 (f10784).
import ChannelStore from "../../stores/ChannelStore";
import PermissionStore from "../../stores/PermissionStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import { ChannelTypesSets, Permissions } from "../../Constants";
import { useStateFromStores } from "../../_bundle/Module589";
export default function canChannelUseSoundboard(a0) {
if (a0 == null) {
return false;
}
if (ChannelTypesSets.CALLABLE.has(a0.type)) {
return true;
}
const r12 = PermissionStore.can(Permissions.USE_SOUNDBOARD, a0);
const r15 = PermissionStore.can(Permissions.SPEAK, a0);
return a0.isGuildVoiceOrThread() && r12 && r15;
};
export function canSelectedVoiceChannelUseSoundboard() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
const r9 = channel == null;
let r10 = false;
if (!r9) {
const r14 = ChannelTypesSets.CALLABLE.has(channel.type);
r10 = true;
if (!r14) {
const r19 = PermissionStore.can(Permissions.USE_SOUNDBOARD, channel);
const r22 = PermissionStore.can(Permissions.SPEAK, channel);
r10 = channel.isGuildVoiceOrThread() && r19 && r22;
}
}
return r10;
}
export function useCanChannelUseSoundboard(a0) {
return useStateFromStores([PermissionStore], () => {
const r7 = a0 == null;
let r8 = false;
if (!r7) {
const r10 = ChannelTypesSets.CALLABLE.has(a0.type);
r8 = true;
if (!r10) {
const r15 = PermissionStore.can(Permissions.USE_SOUNDBOARD, a0);
const r18 = PermissionStore.can(Permissions.SPEAK, a0);
r8 = a0.isGuildVoiceOrThread() && r15 && r18;
}
}
return r8;
}, [a0]);
}
@@ -0,0 +1,7 @@
// Metro module 13595 (f13596).
import { Endpoints } from "../../Constants";
export default function getSoundboardSoundURL(a0) {
const GLOBAL_ENV = window.GLOBAL_ENV;
const CDN_HOST = GLOBAL_ENV.CDN_HOST;
return GLOBAL_ENV.PROJECT_ENV !== "development" ? `https://${CDN_HOST}${Endpoints.SOUNDBOARD_SOUND(a0)}` : `${location.protocol}${window.GLOBAL_ENV.API_ENDPOINT}${Endpoints.SOUNDBOARD_SOUND(a0)}`;
};
+17
View File
@@ -0,0 +1,17 @@
// Metro module 13594 (f13595).
import MediaEngineStore from "../../stores/MediaEngineStore";
import { amplitudeToPerceptual } from "../../utils/PerceptualVolumeUtils";
import { SoundboardSettings } from "../user_settings/UserSettings";
export default function getVolumeForSound(a0, r8) {
if (r8 === void 0) {
let r17 = SoundboardSettings.getSetting()?.volume;
if (r17 == null) {
r17 = 100;
}
r8 = r17;
}
return Math.min(a0 * (amplitudeToPerceptual(r8) / 100) * Math.min(MediaEngineStore.getOutputVolume() / 100, 1), 1);
};
export function getPerceptualSoundboardVolume(a0) {
return amplitudeToPerceptual(a0 == null ? 100 : a0) / 100;
}
+312
View File
@@ -0,0 +1,312 @@
// Metro module 15897 (f15898).
import { memo, useCallback, useEffect } from "react";
import { View } from "react-native";
import UserStore from "../../../stores/UserStore";
import { SOUND_BUTTON_HEIGHT } from "./SoundboardStyleConstants";
import { jsx } from "react/jsx-runtime";
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useAnimatedStyle, useSharedValue } from "../../reanimated/ReanimatedRexport";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isIOS } from "../../../utils/PlatformUtils";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import * as _spring from "../../../design/animation/reanimated/spring/spring";
import Emoji from "../../emojis/native/Emoji";
import getSoundboardEmojiUrl from "./utils/getSoundboardEmojiUrl";
import { useSoundButtonStyleConfig } from "./SoundboardHooks";
import { useStateFromStores } from "../../../_bundle/Module589";
import useSoundboardSoundPlayer_native from "../useSoundboardSoundPlayer.native";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import * as _SoundboardUtils from "../SoundboardUtils";
import PremiumUtils from "../../../utils/PremiumUtils";
import openPremiumUpsellActionSheet from "../../premium/roadblocks/native/utils/openPremiumUpsellActionSheet";
import { EntitlementFeatureNames } from "../../../_bundle/Module6201";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import Module10861 from "../../../_bundle/Module10861";
import * as _index_native from "../../../intl/index.native";
import { intl } from "../../../intl/index.native";
import openSoundboardSoundPreviewActionSheet from "./utils/openSoundboardSoundPreviewActionSheet";
import { Text } from "../../../design/components/Text/native/Text";
import { LockIcon } from "../../../design/components/Icon/native/redesign/generated/LockIcon";
function $mk98093($env) {
return function t() {
const r19 = $env[0];
const r10 = r19.sharedValues.pressed.get();
const r2 = r19.sharedValues.playing.get() > 0;
const r12 = $env.$parent;
const r7 = r12[0];
const r25 = r12[2];
const r11 = r7(r25[5]);
let playingAnimationDelay = r19.playingAnimationDelay;
if (playingAnimationDelay == null) {
playingAnimationDelay = 0;
}
const r14 = r7(r25[10]);
const r35 = r7(r25[5]).interpolate(r19.sharedValues.playing.get(), [0, 1], [1, r19.scaleFactors.playing]);
const r36 = r12[9];
const r38 = r11.withDelay(playingAnimationDelay, r14.withSpring(r35, r36));
const r54 = r7(r25[10]).withSpring(r7(r25[5]).interpolate(r19.sharedValues.pressed.get(), [0, 1], [1, r19.scaleFactors.pressed]), r36);
const transform = [{
scale: r10 === 0 ? r2 ? r38 : r54 : r54
}, ,];
const r59 = r7(r25[5]);
const r64 = r19.sharedValues.pressed.get();
let pressedRotationDegrees = r19.pressedRotationDegrees;
if (pressedRotationDegrees == null) {
pressedRotationDegrees = 0;
}
transform[1] = {
rotate: `${r59.interpolate(r64, [0, 1], [0, pressedRotationDegrees])}deg`
};
return {
transform
};
};
}
let Component, c11383_9, useStyles, Component2, c11383_12;
let env11383 = {};
const SoundButtonEmoji = function SoundButtonEmoji(props) {
let env22580;
let env22581;
const { sound: sound2, sharedValues } = props;
const styles = useStyles();
const animationConfig = {
sharedValues,
scaleFactors: {
pressed: 0.8,
playing: 1.2
}
};
const r18 = env22580 = {
$parent: env11383
};
env22580[0] = animationConfig;
const r20 = $mk98093(r18);
const SPRING_CONFIG = c11383_9;
r20.__closure = {
animationConfig,
withDelay: _ReanimatedRexport.withDelay,
withSpring: _spring.withSpring,
interpolate: _ReanimatedRexport.interpolate,
SPRING_CONFIG
};
r20.__workletHash = 13932429225740;
const __initData = c11383_12;
r20.__initData = __initData;
const animatedStyle = useAnimatedStyle(r20);
const animationConfig2 = {
sharedValues,
scaleFactors: {
pressed: 0.7200000000000001,
playing: 1.08
},
playingAnimationDelay: 100,
pressedRotationDegrees: -15
};
const r33 = env22581 = {
$parent: env11383
};
env22581[0] = animationConfig2;
const r37 = $mk98093(r33);
r37.__closure = {
animationConfig: animationConfig2,
withDelay: _ReanimatedRexport.withDelay,
withSpring: _spring.withSpring,
interpolate: _ReanimatedRexport.interpolate,
SPRING_CONFIG
};
r37.__workletHash = 13932429225740;
r37.__initData = __initData;
const animatedStyle2 = useAnimatedStyle(r37);
const props2 = {
fastImageStyle: styles.emoji,
textEmojiStyle: styles.emoji,
src: getSoundboardEmojiUrl(sound2, 24),
name: null
};
let emojiName = sound2.emojiName;
if (emojiName == null) {
emojiName = "";
}
props2.name = emojiName;
return <Component style={[styles.emojiWrapper, animatedStyle]}>
<Component style={animatedStyle2}>
<Emoji {...props2} />
</Component>
</Component>;
};
Component = ReanimatedRexport.createAnimatedComponent(View);
c11383_9 = {
damping: 10,
stiffness: 300,
mass: 1
};
useStyles = createStyles({
button: {
marginTop: 4,
height: SOUND_BUTTON_HEIGHT,
backgroundColor: Module712.colors.CARD_BACKGROUND_DEFAULT,
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
borderRadius: Module712.radii.lg,
borderWidth: 1,
borderColor: Module712.colors.BORDER_MUTED,
...Module712.shadows.SHADOW_LOW
},
buttonPressed: {
backgroundColor: Module712.colors.CARD_PRIMARY_PRESSED_BG
},
buttonDisabled: {
opacity: 0.5
},
buttonPlaying: {
borderStyle: "solid",
borderWidth: 2,
borderColor: Module712.colors.STATUS_SPEAKING,
backgroundColor: Module712.colors.CARD_SECONDARY_BG
},
emoji: {
height: 24,
width: 24,
fontSize: isIOS() ? 24 : void 0,
lineHeight: 28
},
emojiWrapper: {
display: "flex",
alignItems: "center",
justifyContent: "center",
height: 40,
width: 40,
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED,
backgroundSize: 32,
borderRadius: Module712.radii.round,
marginBottom: 8
},
text: {
marginHorizontal: 8
},
textPlaying: {
marginHorizontal: 6
},
lock: {
position: "absolute",
top: Module712.space.PX_12,
end: Module712.space.PX_12,
width: 12,
height: 12,
tintColor: Module712.colors.WHITE
}
});
Component2 = ReanimatedRexport.createAnimatedComponent(PressableOpacity);
c11383_12 = {
code: "function SoundButtonTsx1(){const{animationConfig,withDelay,withSpring,interpolate,SPRING_CONFIG}=this.__closure;var _animationConfig$play,_animationConfig$pres,_animationConfig;const isNotPressed=animationConfig.sharedValues.pressed.get()===0;const isPlaying=animationConfig.sharedValues.playing.get()>0;const shouldDoPlayingAnimation=isNotPressed&&isPlaying;const playingAnimationScaleValue=withDelay((_animationConfig$play=animationConfig.playingAnimationDelay)!==null&&_animationConfig$play!==void 0?_animationConfig$play:0,withSpring(interpolate(animationConfig.sharedValues.playing.get(),[0,1],[1,animationConfig.scaleFactors.playing]),SPRING_CONFIG));const pressedAnimationScaleValue=withSpring(interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[1,animationConfig.scaleFactors.pressed]),SPRING_CONFIG);const rotationScaleValue=interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[0,(_animationConfig$pres=(_animationConfig=animationConfig)===null||_animationConfig===void 0?void 0:_animationConfig.pressedRotationDegrees)!==null&&_animationConfig$pres!==void 0?_animationConfig$pres:0]);return{transform:[{scale:shouldDoPlayingAnimation?playingAnimationScaleValue:pressedAnimationScaleValue},{rotate:rotationScaleValue+\"deg\"}]};}"
};
const r114 = memo(function SoundButtonComponent(props) {
let playSoundboardSound, analyticsLocations, c22582_5;
const { sound, channel, style, isSectionLocked = false } = props;
playSoundboardSound = void 0;
analyticsLocations = void 0;
c22582_5 = void 0;
const buttonWidth = useSoundButtonStyleConfig().buttonWidth;
let r17 = sound.emojiId != null || sound.emojiName != null;
let isPlayingSound, sharedValue, sharedValue2;
let env22584;
const styles = useStyles();
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const soundboardSoundPlayer_native = useSoundboardSoundPlayer_native(sound, channel.id);
playSoundboardSound = soundboardSoundPlayer_native.playSoundboardSound;
const isPlayingSound2 = soundboardSoundPlayer_native.isPlayingSound;
analyticsLocations = useAnalyticsLocations(AnalyticsLocation.SOUNDBOARD_BUTTON).analyticsLocations;
const canUseSoundboardSound = _SoundboardUtils.canUseSoundboardSound(stateFromStores, sound, channel);
let r55 = !canUseSoundboardSound;
c22582_5 = r55;
const callback = useCallback(() => {
L7: {
if (c22582_5) {
if (!PremiumUtils.canUseSoundboardEverywhere(stateFromStores) && sound.guildId !== channel.guild_id) {
openPremiumUpsellActionSheet(EntitlementFeatureNames.SOUNDBOARD_EVERYWHERE);
break L7;
}
if (!sound.available) {
ToastActionCreators.open({
key: "DISABLED_SOUND_PRESSED",
icon: Module10861,
content: intl.string(_index_native.t.MDOXJR),
toastDurationMs: 3000
});
}
} else {
playSoundboardSound(analyticsLocations);
}
}
}, [analyticsLocations, channel.guild_id, stateFromStores, playSoundboardSound, sound, r55]);
isPlayingSound = isPlayingSound2;
sharedValue = void 0;
sharedValue2 = void 0;
sharedValue = useSharedValue(0);
sharedValue2 = useSharedValue(0);
const callback2 = useCallback(() => {
sharedValue.set(1);
}, [sharedValue]);
const callback3 = useCallback(() => {
sharedValue.set(0);
}, [sharedValue]);
useEffect(() => {
sharedValue2.set(isPlayingSound ? 1 : 0);
}, [isPlayingSound, sharedValue2, sharedValue]);
const sharedValues = {
pressed: sharedValue,
playing: sharedValue2
};
const animationConfig = {
sharedValues,
scaleFactors: {
pressed: 0.95,
playing: 1.05
}
};
const r80 = env22584 = {
$parent: env11383
};
env22584[0] = animationConfig;
const r84 = $mk98093(r80);
r84.__closure = {
animationConfig,
withDelay: _ReanimatedRexport.withDelay,
withSpring: _spring.withSpring,
interpolate: _ReanimatedRexport.interpolate,
SPRING_CONFIG: c11383_9
};
r84.__workletHash = 13932429225740;
r84.__initData = c11383_12;
const animatedStyle = useAnimatedStyle(r84);
const r3 = sharedValues.pressed.get() > 0;
const callback4 = useCallback(() => {
openSoundboardSoundPreviewActionSheet(channel.id, sound);
}, [channel.id, sound]);
const style2 = [styles.button, {
width: buttonWidth
}, r3 ? styles.buttonPressed : null, animatedStyle, isPlayingSound ? styles.buttonPlaying : null, canUseSoundboardSound ? null : isSectionLocked ? null : styles.buttonDisabled, style];
if (r17) {
r17 = (0, jsx)(SoundButtonEmoji, {
sharedValues,
sound
});
}
const r132 = [<Component2 style={style2} accessibilityRole="button" accessibilityLabel={sound.name} onPressIn={callback2} onPressOut={callback3} onPress={callback} onLongPress={callback4}>
{r17}
<Text lineClamp={1} style={[styles.text, isPlayingSound ? styles.textPlaying : null]} variant="text-sm/semibold">{sound.name}</Text>
</Component2>, ,];
if (!canUseSoundboardSound) {
r55 = !isSectionLocked;
}
if (r55) {
r55 = <LockIcon style={styles.lock} />;
}
r132[1] = r55;
return <View>{r132}</View>;
});
export { r114 as SoundButton };
@@ -0,0 +1,14 @@
// Metro module 15888 (f15889).
import { ComponentActions } from "../../../Constants";
import { ComponentDispatch } from "../../../utils/ComponentDispatchUtils";
import { UNSAFE_markDismissibleContentAsDismissed } from "../../dismissible_content/DismissibleContentUnsafeUtils";
import { DismissibleContent } from "../../../_bundle/Module1358";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
export function showSoundboardSoundPickerActionSheet({ channel, analyticsSource }) {
ComponentDispatch.dispatch(ComponentActions.TOGGLE_CALL_CONTROL_DRAWER);
UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.SOUNDBOARD_MOBILE_NEW_BADGE);
ActionSheetActionCreators.openLazy(import("./SoundboardSoundPicker"), "SoundboardSoundPickerActionSheet", {
channel,
analyticsSource
});
}
@@ -0,0 +1,37 @@
// Metro module 15898 (f15899).
import { useEffect } from "react";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import ThemeStore from "../../user_settings/ThemeStore";
import { SOUNDS_PER_ROW, SOUND_ROW_PADDING } from "./SoundboardStyleConstants";
import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import { useStateFromStores } from "../../../_bundle/Module589";
import { isThemeDark } from "../../../design/shared";
import { FrecencyUserSettingsActionCreators } from "../../user_settings/UserSettingsProtoActionCreators";
import { maybeFetchSoundboardSounds } from "../SoundboardActionCreators";
export function useSoundButtonStyleConfig() {
return {
buttonWidth: (Math.min(ACTION_SHEET_MAX_WIDTH, useWindowDimensions_native().width) - SOUND_ROW_PADDING) / SOUNDS_PER_ROW
};
}
export function useMaybeFetchSoundboardSounds({ shouldFetch }) {
useEffect(() => {
let _fetchAndHydrateColors2 = function _fetchAndHydrateColors() {
const r9 = async () => {
L11: {
if (shouldFetch) {
FrecencyUserSettingsActionCreators.loadIfNecessary();
await maybeFetchSoundboardSounds();
break L11;
}
return void 0;
}
};
_fetchAndHydrateColors2 = r9;
return r9.apply(this, arguments);
};
(function fetchAndHydrateColors() {
return _fetchAndHydrateColors2.apply(this, arguments);
})();
}, [useStateFromStores([AccessibilityStore], () => AccessibilityStore.saturation), useStateFromStores([ThemeStore], () => isThemeDark(ThemeStore.theme)), shouldFetch]);
}
@@ -0,0 +1,112 @@
// Metro module 13592 (f13593).
import MediaEngineStore from "../../../stores/MediaEngineStore";
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
import SoundboardStore from "../SoundboardStore";
import Logger from "../../debug/Logger";
import BaseSoundboardManager from "../BaseSoundboardManager";
import getVolumeForSound from "../getVolumeForSound";
import getSoundboardSoundURL from "../getSoundboardSoundURL";
import { createSound } from "../../sound_playback/SoundUtils";
import { reportSoundStartedPlaying, reportSoundFinishedPlaying } from "../SoundboardActionCreators";
let c9438_7 = new Map();
let c9438_8 = new Logger("SoundboardManagerNative");
class SoundboardManager extends BaseSoundboardManager {
constructor() {
let c20568_0;
super(...arguments);
const _this = this;
this._stopAndClearSounds = () => {
c9438_7.forEach((item) => {
item.stop();
});
c9438_7 = new Map();
};
this._playSound = function _playSound(a0, r5 = 1) {
const r3 = arguments[3];
if (!(SelectedChannelStore.getVoiceChannelId() !== r3 && r3 != null) && !MediaEngineStore.isDeaf()) {
const userId = arguments[2];
if (!SoundboardStore.isLocalSoundboardMuted(userId)) {
const volumeForSound = getVolumeForSound(r5);
const soundKey = `${userId}-${a0}`;
const r33 = c9438_7.get(soundKey);
if (r33 != null) {
r33.stop();
}
const sound = createSound(getSoundboardSoundURL(a0), "soundboard_sound", volumeForSound);
sound.volume = volumeForSound;
c9438_7.set(soundKey, sound);
reportSoundStartedPlaying(a0, userId);
_this._playSoundWithListener({
sound,
soundKey,
soundId: a0,
userId
});
}
}
};
c20568_0 = void 0;
c20568_0 = async (c30650_0) => {
let c30650_3;
let c30650_4 = 0;
let c31694_0, c31694_1, c31694_2, c31694_3, c31694_4, c31694_5;
L14: {
try {
c31694_0 = void 0;
c31694_1 = void 0;
c31694_2 = void 0;
c31694_3 = void 0;
c31694_0 = c30650_0.sound;
c31694_1 = c30650_0.soundKey;
c31694_2 = c30650_0.soundId;
c31694_3 = c30650_0.userId;
c31694_4 = void 0;
await void 0;
c31694_4 = false;
c30650_4 = 1;
c31694_4 = await c31694_0.playWithListener();
c30650_4 = 0;
if (c31694_4) {
c9438_7.delete(c31694_1);
reportSoundFinishedPlaying(c31694_2, c31694_3);
}
} catch ($e) {
const r29 = $e;
let r7 = r29;
c30650_3 = r29;
if (c30650_4 !== 0) {
while (true) {
try {
const r98 = c30650_3;
c30650_4 = 0;
c31694_5 = r98;
c9438_8.error("Failed to play sound", {
error: c31694_5
});
c31694_4 = true;
if (!c31694_4) {
break L14;
}
c9438_7.delete(c31694_1);
reportSoundFinishedPlaying(c31694_2, c31694_3);
break L14;
} catch (r94) {
r7 = r94;
c30650_3 = r94;
if (c30650_4 === 0) {
break;
}
}
}
}
throw r7;
}
}
};
this._playSoundWithListener = function() {
return c20568_0.apply(this, arguments);
};
}
}
const soundboardManager = new SoundboardManager();
export default soundboardManager;
@@ -0,0 +1,106 @@
// Metro module 15889 (f15890).
import { memo, useState, useRef, useCallback } from "react";
import { View } from "react-native";
import { setSearchQuery, useExpressionPickerStore } from "../../expression_picker/ExpressionPickerStore";
import RTCConnectionStore from "../../../stores/RTCConnectionStore";
import UserStore from "../../../stores/UserStore";
import { SOUND_ROW_HORIZONTAL_PADDING } from "./SoundboardStyleConstants";
import { EXPRESSION_FOOTER_HEIGHT } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useSharedValue } from "../../reanimated/ReanimatedRexport";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import useSoundGrid, { useSearchCategories } from "../useSoundGrid";
import { searchSounds } from "../searchSounds";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import useTrackImpression from "../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../_bundle/Module503";
import { isIOS, isAndroid } from "../../../utils/PlatformUtils";
import PortalKeyboardFooterIOS_ios from "../../keyboard/native/PortalKeyboardFooterIOS.ios";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { PortalHost } from "../../../_bundle/Module4060";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { SearchField } from "../../../design/components/TextField/native/SearchField.native";
import { SoundboardSoundPickerList } from "./SoundboardSoundPickerList";
import PremiumSoundboardFeatureUpsell from "../../premium/roadblocks/native/views/PremiumSoundboardFeatureUpsell";
import SoundboardSoundPickerCategories from "./SoundboardSoundPickerCategories";
const useStyles = createStyles({
title: {
marginBottom: 8
},
container: {
flex: 1,
alignItems: "center"
},
header: {
paddingHorizontal: SOUND_ROW_HORIZONTAL_PADDING,
padding: Module712.space.PX_8,
width: "100%"
},
body: {
flex: 1,
width: "100%"
}
});
const r53 = memo(function SoundboardSoundPicker(props) {
let availableSounds, setState;
const { channel, analyticsSource } = props;
availableSounds = void 0;
setState = void 0;
const styles = useStyles();
const [categoryIndex, setCategoryIndex] = useState(0);
const ref = useRef(null);
const sharedValue2 = useSharedValue(0);
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const stateFromStores2 = useStateFromStores([RTCConnectionStore], () => RTCConnectionStore.getMediaSessionId());
const soundGrid = useSoundGrid(channel, {
filterOutEmptyCurrentGuild: true
});
const categories = soundGrid.categories;
availableSounds = soundGrid.availableSounds;
const expressionPickerStore = useExpressionPickerStore((a0) => a0.searchQuery);
let state;
[state, setState] = useState(searchSounds(expressionPickerStore, availableSounds, stateFromStores, channel));
const searchCategories = useSearchCategories(categories, state, expressionPickerStore);
const insets = useSafeAreaInsetsKeyboardAware_native({
isKeyboardAwareOnAndroid: false
}).insets;
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.SOUNDBOARD_ACTION_SHEET).analyticsLocations;
const callback = useCallback((a0) => {
setSearchQuery(a0);
setState(searchSounds(a0, availableSounds, stateFromStores, channel));
}, [channel, stateFromStores, availableSounds]);
useTrackImpression({
type: ImpressionTypes.HALFSHEET,
name: ImpressionNames.SOUNDBOARD_POPOUT,
properties: {
source: analyticsSource,
guild_id: channel.guild_id,
media_session_id: stateFromStores2
}
});
const sharedValue3 = useSharedValue(-1);
const sharedValue = useSharedValue(false);
return <AnalyticsLocationProvider value={analyticsLocations}>
{isIOS() && <PortalKeyboardFooterIOS_ios animatedSheetIndex={sharedValue3} portalHostName="soundboard-footer" followSystemKeyboard />}
<BottomSheet animatedIndex={sharedValue3} scrollable startExpanded footer={isAndroid() ? <PortalHost name="soundboard-footer" /> : void 0}>
<View style={styles.container}>
<Text accessibilityRole="header" variant="heading-lg/bold" style={styles.title}>
{intl.string(t.ABjMWI)}
</Text>
<View style={styles.header}>
<SearchField size="md" placeholder={intl.string(t.sKt3xS)} onChange={callback} />
</View>
<View style={styles.body}>
<SoundboardSoundPickerList listRef={ref} channel={channel} insetBottom={EXPRESSION_FOOTER_HEIGHT + insets.bottom + Module712.space.PX_16} scrollPosition={sharedValue2} setCategoryIndex={setCategoryIndex} categories={searchCategories} shouldShowPremiumUpsell={sharedValue} />
</View>
<PremiumSoundboardFeatureUpsell shouldShow={sharedValue} />
</View>
<SoundboardSoundPickerCategories guildId={channel.guild_id} listRef={ref} categories={categories} categoryIndex={categoryIndex} />
</BottomSheet>
</AnalyticsLocationProvider>;
});
export default r53;
@@ -0,0 +1,199 @@
// Metro module 15905 (f15906).
import { memo, forwardRef, useRef, useEffect, useCallback } from "react";
import { FlatList, StyleSheet, View } from "react-native";
import { setSearchQuery } from "../../expression_picker/ExpressionPickerStore";
import UserStore from "../../../stores/UserStore";
import * as _Constants from "../../../Constants";
import { EXPRESSION_FOOTER_HEIGHT } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { SoundboardSoundGridSectionType } from "../SoundboardTypes";
import GuildIcon from "../../guild/native/GuildIcon";
import { intl, t } from "../../../intl/index.native";
import Module9624 from "../../../_bundle/Module9624";
import { ClockIcon } from "../../../design/components/Icon/native/redesign/generated/ClockIcon";
import Module15903 from "../../../_bundle/Module15903";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { Icon } from "../../../design/void/native";
import { LockIcon } from "../../../design/components/Icon/native/redesign/generated/LockIcon";
import { triggerHapticFeedback } from "../../haptics/HapticUtils.native";
import HapticFeedbackTypes from "../../haptics/HapticFeedbackTypes";
import { useStateFromStores } from "../../../_bundle/Module589";
import PremiumUtils from "../../../utils/PremiumUtils";
import { isSoundboardSectionNitroLocked } from "../../premium/roadblocks/native/utils/PremiumFeatureUpsellUtils";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import { Portal } from "../../../_bundle/Module4060";
import VisualEffectViewThemed from "../../visual_effect_view/native/VisualEffectViewThemed";
let useStyles, Component, getItemLayout;
const SoundCategoryItem = function SoundCategoryItem(props) {
let r9, r11, name, source;
const { category, handlePressCategory, index, style } = props;
let locked = props.locked;
if (locked === void 0) {
locked = false;
}
const styles2 = useStyles();
const type = category.categoryInfo.type;
if (SoundboardSoundGridSectionType.GUILD === type) {
const guild = category.categoryInfo.guild;
name = guild.name;
r11 = <GuildIcon guild={guild} style={styles2.guildItem} />;
source = null;
r9 = null;
} else if (SoundboardSoundGridSectionType.FAVORITES === type) {
name = intl.string(t.y3LQCG);
source = Module9624;
r9 = null;
r11 = null;
} else if (SoundboardSoundGridSectionType.FREQUENTLY_USED === type) {
name = intl.string(t["+cGVV6"]);
r9 = <ClockIcon style={styles2.keyboardItem} />;
source = null;
r11 = null;
} else if (SoundboardSoundGridSectionType.DEFAULTS === type) {
name = intl.string(t.Rtvk9X);
source = Module15903;
r9 = null;
r11 = null;
} else {
const SEARCH = SoundboardSoundGridSectionType.SEARCH;
source = null;
r9 = null;
r11 = null;
name = null;
if (SEARCH === type) {
name = intl.string(t.sKt3xS);
source = Module15903;
r9 = null;
r11 = null;
}
}
if (r11 == null) {
r11 = r9;
}
if (r11 == null) {
r11 = <Icon style={styles2.keyboardItem} source={source} />;
}
const r108 = [r11, ,];
if (locked) {
locked = <View style={styles2.lockContainer}>
<LockIcon style={styles2.lock} />
</View>;
}
r108[1] = locked;
return <PressableOpacity key={name} onPress={() => handlePressCategory(index)} accessibilityRole="button" accessibilityLabel={name}>
<View style={[styles2.item, style]}>{r108}</View>
</PressableOpacity>;
};
getItemLayout = function getItemLayout(a0, a1) {
return {
length: EXPRESSION_FOOTER_HEIGHT,
offset: EXPRESSION_FOOTER_HEIGHT * a1,
index: a1
};
};
const { CATEGORY_ICON_SIZE, NODE_MARGIN, NODE_SIZE } = _Constants;
useStyles = createStyles({
container: {
borderTopWidth: StyleSheet.hairlineWidth,
paddingHorizontal: 8,
flexDirection: "row",
alignItems: "center",
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
borderTopColor: Module712.colors.BACKGROUND_BASE_LOWEST
},
item: {
margin: NODE_MARGIN,
height: NODE_SIZE,
width: NODE_SIZE,
borderRadius: NODE_SIZE / 2,
alignItems: "center",
justifyContent: "center"
},
fadedItem: {
opacity: 0.5
},
activeItem: {
opacity: 1,
backgroundColor: Module712.colors.INTERACTIVE_BACKGROUND_ACTIVE
},
guildItem: {
height: CATEGORY_ICON_SIZE,
width: CATEGORY_ICON_SIZE,
borderRadius: CATEGORY_ICON_SIZE / 2
},
keyboardItem: {
height: CATEGORY_ICON_SIZE,
width: CATEGORY_ICON_SIZE
},
lockContainer: {
width: 12,
height: 12,
position: "absolute",
bottom: 0,
end: 0,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
borderRadius: Module712.radii.round,
alignItems: "center",
justifyContent: "center"
},
lock: {
width: 7.5,
height: 7.5,
tintColor: Module712.colors.TEXT_DEFAULT
}
});
Component = memo(forwardRef((a0, a1) => <FlatList {...a0} ref={a1} />));
const r85 = memo(function SoundboardSoundPickerCategories(props) {
let callback, stateFromStores;
const { guildId, categories, categoryIndex, style, listRef } = props;
callback = void 0;
stateFromStores = void 0;
const styles = useStyles();
const ref = useRef(null);
const ref2 = useRef(null);
const ref3 = useRef(null);
useEffect(() => {
if (ref2.current != null && ref3.current != null && ref.current != null) {
const offset = categoryIndex * EXPRESSION_FOOTER_HEIGHT;
if (offset > ref3.current || offset < ref2.current) {
ref.current.scrollToOffset({
offset
});
}
}
}, [categoryIndex]);
const callback3 = useCallback((a0) => {
const layout = a0.nativeEvent.layout;
ref2.current = 0;
ref3.current = layout.width;
}, []);
const callback2 = useCallback(({ nativeEvent }) => {
const { contentOffset, layoutMeasurement } = nativeEvent;
ref2.current = contentOffset.x;
ref3.current = contentOffset.x + layoutMeasurement.width;
}, []);
callback = useCallback((section) => {
setSearchQuery("");
setImmediate(() => {
if (listRef?.current != null) {
listRef.current.scrollToLocation({
section,
item: 0
});
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
}
});
}, [listRef]);
stateFromStores = useStateFromStores([UserStore], () => PremiumUtils.canUseSoundboardEverywhere(UserStore.getCurrentUser()));
const callback4 = useCallback(({ item, index: index2 }) => <SoundCategoryItem category={item} index={index2} style={categoryIndex != null && index2 === categoryIndex ? styles.activeItem : styles.fadedItem} handlePressCategory={callback} locked={stateFromStores ? !stateFromStores : isSoundboardSectionNitroLocked(guildId, item.categoryInfo)} />, [stateFromStores, guildId, callback, categoryIndex, styles.activeItem, styles.fadedItem]);
return <Portal hostName="soundboard-footer">
<View style={[styles.container, {
paddingBottom: useSafeAreaInsets_native().bottom
}, style]}>
<VisualEffectViewThemed style={StyleSheet.absoluteFill} />
<Component ref={ref} getItemLayout={getItemLayout} onLayout={callback3} onScroll={callback2} data={categories} keyboardShouldPersistTaps="always" horizontal keyExtractor={(item) => String(item.key)} renderItem={callback4} showsHorizontalScrollIndicator={false} />
</View>
</Portal>;
});
export default r85;
@@ -0,0 +1,241 @@
// Metro module 15896 (f15897).
import * as Module19 from "react";
import { useMemo, useCallback } from "react";
import { View } from "react-native";
import UserStore from "../../../stores/UserStore";
import * as _SoundboardStyleConstants from "./SoundboardStyleConstants";
import { SOUNDS_PER_ROW } from "./SoundboardStyleConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { SoundboardSoundGridSectionType, SoundboardSoundItemType } from "../SoundboardTypes";
import { intl, t } from "../../../intl/index.native";
import chunk from "../../../_bundle/chunk";
import { useStateFromStores } from "../../../_bundle/Module589";
import PremiumUtils from "../../../utils/PremiumUtils";
import * as _PremiumFeatureUpsellUtils from "../../premium/roadblocks/native/utils/PremiumFeatureUpsellUtils";
import { PremiumUpsellGradientBackground } from "../../premium/roadblocks/native/views/PremiumUpsellGradientBackground";
import { SoundButton } from "./SoundButton";
import { useFontScale } from "../../screen/native/useFontScale";
import { debounce } from "../../../_bundle/Module12";
import GuildIcon, { GuildIconSizes } from "../../guild/native/GuildIcon";
import { Icon } from "../../../design/void/native";
import Module15903 from "../../../_bundle/Module15903";
import Module9624 from "../../../_bundle/Module9624";
import { ClockIcon } from "../../../design/components/Icon/native/redesign/generated/ClockIcon";
import PremiumUpsellSectionDivider, { PremiumUpsellSectionDividerPosition, PREMIUM_UPSELL_SECTION_DIVIDER_HEIGHT, PREMIUM_UPSELL_SECTION_DIVIDER_MARGIN } from "../../premium/roadblocks/native/views/PremiumUpsellSectionDivider";
import FastList from "../../../lib/native/FastList";
import { Text } from "../../../design/components/Text/native/Text";
let c11382_9, useStyles, SoundPickerButtonRow;
const getSectionLabel = function getSectionLabel(a0) {
const type = a0.category.categoryInfo.type;
if (SoundboardSoundGridSectionType.GUILD === type) {
return a0.category.categoryInfo.guild.name;
}
if (SoundboardSoundGridSectionType.DEFAULTS === type) {
return intl.string(t.Rtvk9X);
}
if (SoundboardSoundGridSectionType.FAVORITES === type) {
return intl.string(t.y3LQCG);
}
if (SoundboardSoundGridSectionType.FREQUENTLY_USED === type) {
return intl.string(t["+cGVV6"]);
}
if (SoundboardSoundGridSectionType.SEARCH === type) {
return null;
}
};
SoundPickerButtonRow = function SoundPickerButtonRow(props) {
let isSoundboardSectionNitroLocked;
const { row, section, channel } = props;
isSoundboardSectionNitroLocked = void 0;
const styles = useStyles();
const stateFromStores2 = useStateFromStores([UserStore], () => PremiumUtils.canUseSoundboardEverywhere(UserStore.getCurrentUser()));
if (section == null) {
return null;
}
let r19 = stateFromStores2 ? !stateFromStores2 : _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel.guild_id, section.category.categoryInfo);
isSoundboardSectionNitroLocked = r19;
if (isSoundboardSectionNitroLocked) {
r19 = <PremiumUpsellGradientBackground />;
}
return <View style={[styles.row]}>
{r19}
{section.soundsByRow[row].map((item, index) => {
const type = item.type;
if (SoundboardSoundItemType.SOUND === type) {
const sound = item.sound;
return <SoundButton key={`${section.category.key}-${sound.soundId}`} sound={sound} channel={channel} style={index > 0 ? styles.soundButtonNotFirst : null} isSectionLocked={isSoundboardSectionNitroLocked} />;
}
if (SoundboardSoundItemType.ADD_SOUND === type) {
throw new Error("ADD_SOUND Not implemented");
}
})}
</View>;
};
const { SOUND_BUTTON_HEIGHT, SOUND_ROW_HORIZONTAL_PADDING, SOUND_ROW_SPACING } = _SoundboardStyleConstants;
c11382_9 = SOUND_BUTTON_HEIGHT + 8;
useStyles = createStyles({
row: {
height: c11382_9,
display: "flex",
flexDirection: "row",
paddingHorizontal: SOUND_ROW_HORIZONTAL_PADDING
},
sectionHeader: {
flex: 1,
display: "flex",
flexDirection: "row",
alignItems: "center",
paddingTop: 16,
paddingBottom: 8,
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND,
paddingHorizontal: SOUND_ROW_HORIZONTAL_PADDING
},
sectionIcon: {
height: 16,
width: 16,
borderRadius: 8,
marginRight: 4
},
soundButtonNotFirst: {
marginLeft: SOUND_ROW_SPACING
}
});
const r49 = Module19.memo(function SoundboardSoundPickerListComponent(props) {
let styles2, fastListSectionsFromCategories, memo, c22579_8, c22579_9, stateFromStores;
const { channel: channel2, insetBottom = 0, listRef, scrollPosition, onScroll: onScroll2, setCategoryIndex, shouldShowPremiumUpsell, categories } = props;
styles2 = void 0;
fastListSectionsFromCategories = void 0;
memo = void 0;
c22579_8 = void 0;
c22579_9 = void 0;
stateFromStores = void 0;
const getSectionPosition2 = function getSectionPosition(a0) {
const r0 = a0 - 1;
const r3 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r0].category.categoryInfo);
const r23 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[a0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[a0].category.categoryInfo);
const r39 = a0 + 1;
const r40 = (stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r39] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r39].category.categoryInfo);
return !r23 && (r40 && !r3) ? PremiumUpsellSectionDividerPosition.START : r23 ? r40 ? null : PremiumUpsellSectionDividerPosition.END : null;
};
styles2 = useStyles();
const fontScale = useFontScale();
const sections = (function calculateRowsPerSection(a0, a1) {
const r0 = [];
for (const item of a0) {
r0.push(Math.ceil(item.items.length / a1));
}
return r0;
})(categories, SOUNDS_PER_ROW);
fastListSectionsFromCategories = (function getFastListSectionsFromCategories(a0, a1, a2) {
const r0 = [];
for (const item of a0) {
const soundsByRow = chunk(item.items, a1);
r0.push({
category: item,
height: soundsByRow.length * c11382_9 + (18 * a2 + 8),
soundsByRow
});
}
return r0;
})(categories, SOUNDS_PER_ROW, fontScale);
memo = useMemo(() => fastListSectionsFromCategories.map((fastListSectionsFromCategory) => fastListSectionsFromCategory.height), [fastListSectionsFromCategories]);
const callback = useCallback((a0, a1) => <SoundPickerButtonRow row={a1} section={fastListSectionsFromCategories[a0]} channel={channel2} />, [fastListSectionsFromCategories, channel2]);
c22579_8 = debounce((a0) => {
const r14 = Math.round(a0);
const r6 = 0 < memo.length;
let r4 = 0;
if (r6) {
let r18 = 0 + memo[0];
const r19 = r14 >= r18;
let r1 = 0;
let r0 = 0;
r4 = 0;
if (r19) {
do {
const r20 = r0 + 1;
const r3 = r1 + 1;
const length = memo.length;
const r11 = r18;
r4 = r20;
if (!(r3 < length)) {
break;
}
r18 = r11 + memo[r3];
r1 = r3;
r0 = r20;
r4 = r0;
} while (r14 >= r18);
}
}
setCategoryIndex(r4);
});
c22579_9 = debounce((a0, a1) => {
const r16 = -a1 / 2;
const r18 = Math.round(a0);
const r6 = 0 < memo.length;
let r4 = 0;
if (r6) {
let r22 = r16 + memo[0];
const r23 = r18 >= r22;
let r1 = 0;
let r24 = 0;
r4 = 0;
if (r23) {
do {
const r26 = r24 + 1;
const r3 = r1 + 1;
const length = memo.length;
const r14 = r22;
r4 = r26;
if (!(r3 < length)) {
break;
}
r22 = r14 + memo[r3];
r1 = r3;
r24 = r26;
r4 = r24;
} while (r18 >= r22);
}
}
const r38 = Math.min(r4, memo.length - 1);
shouldShowPremiumUpsell.set((stateFromStores ? !stateFromStores : fastListSectionsFromCategories[r38] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[r38].category.categoryInfo));
});
stateFromStores = useStateFromStores([UserStore], () => PremiumUtils.canUseSoundboardEverywhere(UserStore.getCurrentUser()));
return <FastList onLayout={(event) => c22579_9(0, event.nativeEvent.layout.height)} sections={sections} sectionSize={function sectionSize(a0) {
const r6 = fastListSectionsFromCategories[a0];
return r6 != null ? getSectionLabel(r6) == null ? 0 : 42 : 0;
}} itemSize={function itemSize(a0) {
return fastListSectionsFromCategories[a0] == null ? 0 : c11382_9;
}} sectionFooterSize={function sectionFooterSize(a0) {
return getSectionPosition2(a0) == null ? 0 : PREMIUM_UPSELL_SECTION_DIVIDER_HEIGHT + PREMIUM_UPSELL_SECTION_DIVIDER_MARGIN;
}} ref={listRef} renderItem={callback} renderSection={function renderSection(a0) {
const r3 = fastListSectionsFromCategories[a0];
const r39 = [(stateFromStores ? !stateFromStores : fastListSectionsFromCategories[a0] != null) && _PremiumFeatureUpsellUtils.isSoundboardSectionNitroLocked(channel2.guild_id, fastListSectionsFromCategories[a0].category.categoryInfo) && <PremiumUpsellGradientBackground />, , ,];
const type = r3.category.categoryInfo.type;
r39[1] = SoundboardSoundGridSectionType.GUILD === type ? <GuildIcon size={GuildIconSizes.XXSMALL_12} guild={r3.category.categoryInfo.guild} style={styles2.sectionIcon} /> : SoundboardSoundGridSectionType.DEFAULTS === type ? <Icon source={Module15903} style={styles2.sectionIcon} /> : SoundboardSoundGridSectionType.FAVORITES === type ? <Icon source={Module9624} style={styles2.sectionIcon} /> : SoundboardSoundGridSectionType.FREQUENTLY_USED === type ? <ClockIcon style={styles2.sectionIcon} /> : SoundboardSoundGridSectionType.SEARCH === type ? null : void 0;
r39[2] = <Text accessibilityRole="header" lineClamp={1} variant="heading-sm/semibold">
{getSectionLabel(r3)}
</Text>;
return <View key={r3.category.key}>
<View style={styles2.sectionHeader}>{r39}</View>
</View>;
}} renderSectionFooter={function renderSectionFooter(a0) {
const sectionPosition2 = getSectionPosition2(a0);
return sectionPosition2 != null ? <PremiumUpsellSectionDivider position={sectionPosition2} /> : null;
}} insetEnd={insetBottom} onScroll={function onScroll(event) {
const nativeEvent = event.nativeEvent;
const r7 = nativeEvent.contentOffset.y;
c22579_8(r7);
c22579_9(r7, nativeEvent.layoutMeasurement.height);
if (!(nativeEvent.layoutMeasurement.height + nativeEvent.contentOffset.y >= nativeEvent.contentSize.height - 20)) {
if (scrollPosition != null) {
scrollPosition.set(r7);
}
if (onScroll2 != null) {
onScroll2(event);
}
}
}} keyboardShouldPersistTaps="handled" optimizeListItemRender inActionSheet />;
});
export { r49 as SoundboardSoundPickerList };
@@ -0,0 +1,129 @@
// Metro module 15902 (f15903).
import { useCallback } from "react";
import { Image as Image2, View, StyleSheet } from "react-native";
import UserStore from "../../../stores/UserStore";
import SoundboardStore from "../SoundboardStore";
import { AnalyticsObjects } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isIOS } from "../../../utils/PlatformUtils";
import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import { removeFavoriteSound, addFavoriteSound, playSoundLocally } from "../SoundboardActionCreators";
import { trackSoundFavorited } from "../SoundboardUtils";
import { LocalSoundTrigger } from "../SoundboardTypes";
import { useButtonPressAnimationProps } from "../../../design/components/Button/native/ButtonHooks.native";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import Emoji from "../../emojis/native/Emoji";
import getSoundboardEmojiUrl from "./utils/getSoundboardEmojiUrl";
import { Text } from "../../../design/components/Text/native/Text";
import { Button } from "../../../design/components/Button/native/Button.native";
import { StarIcon } from "../../../design/components/Icon/native/redesign/generated/StarIcon";
import { StarOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/StarOutlineIcon";
import { intl, t } from "../../../intl/index.native";
import Module7684 from "../../../_bundle/Module7684";
import ReanimatedRexport from "../../reanimated/ReanimatedRexport";
const _excluded = ["style"];
const useStyles = createStyles({
emoji: {
marginTop: Module712.space.PX_16,
width: 64,
height: 64,
alignSelf: "center"
},
emojiFastImage: {
width: 128,
height: 128
},
emojiText: {
fontSize: isIOS() ? 60 : void 0,
lineHeight: 74
},
text: {
marginTop: Module712.space.PX_16,
alignSelf: "center"
},
buttonContainer: {
gap: Module712.space.PX_8,
marginTop: Module712.space.PX_24
},
star: {
width: 16,
height: 16,
tintColor: Module712.colors.TEXT_DEFAULT
},
border: {
borderColor: "transparent",
borderWidth: 1,
borderRadius: Module712.radii.round,
pointerEvents: "none",
...StyleSheet.absoluteFillObject
},
borderPlaying: {
borderColor: Module712.colors.TEXT_FEEDBACK_POSITIVE
}
});
export default function SoundboardSoundPreviewActionSheet(props) {
let analyticsLocations, isPlayingSound, isFavorite;
const { channelId, sound } = props;
analyticsLocations = void 0;
isPlayingSound = void 0;
isFavorite = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser()?.id);
analyticsLocations = useAnalyticsLocations().analyticsLocations;
const stateFromStoresObject = useStateFromStoresObject([SoundboardStore], () => ({
isPlayingSound: stateFromStores != null && SoundboardStore.isUserPlayingSounds(stateFromStores),
isFavorite: SoundboardStore.isFavoriteSound(sound.soundId)
}));
let isPlayingSound2 = stateFromStoresObject.isPlayingSound;
isPlayingSound = isPlayingSound2;
isFavorite = stateFromStoresObject.isFavorite;
const callback = useCallback(() => {
if (isFavorite) {
removeFavoriteSound(sound.soundId);
} else {
trackSoundFavorited({
sound,
location: {
...analyticsLocations,
object: AnalyticsObjects.SOUNDBOARD_SOUND
}
});
addFavoriteSound(sound.soundId);
}
}, [isFavorite, sound, analyticsLocations]);
const callback2 = useCallback(() => {
if (!isPlayingSound) {
playSoundLocally(channelId, sound, LocalSoundTrigger.SOUNDBOARD);
}
}, [channelId, sound, isPlayingSound]);
const buttonPressAnimationProps = useButtonPressAnimationProps();
const { style, ...rest } = buttonPressAnimationProps;
const props2 = {
fastImageStyle: [styles.emoji, styles.emojiFastImage],
textEmojiStyle: [styles.emoji, styles.emojiText],
src: getSoundboardEmojiUrl(sound, 64),
name: null
};
let emojiName = sound.emojiName;
if (emojiName == null) {
emojiName = "";
}
props2.name = emojiName;
const r74 = [<Emoji {...props2} />, <Text style={styles.text} variant="heading-lg/extrabold">{sound.name}</Text>, ,];
const r105 = [<Button variant="primary" icon={isFavorite ? <StarIcon style={styles.star} /> : <StarOutlineIcon style={styles.star} />} text={isFavorite ? intl.string(t.aBUcp3) : intl.string(t.yZFibY)} onPress={callback} />, ,];
const r128 = [<Button {...rest} variant="secondary" icon={<Image2 style={styles.star} source={Module7684} />} text={intl.string(t.Kd4uxG)} onPress={callback2} />, ,];
const style2 = [styles.border, , ,];
if (isPlayingSound) {
isPlayingSound2 = styles.borderPlaying;
}
style2[1] = isPlayingSound2;
style2[2] = style;
r128[1] = <ReanimatedRexport.View style={style2} />;
r105[1] = <View>{r128}</View>;
r74[2] = <View style={styles.buttonContainer}>{r105}</View>;
return <ActionSheet startExpanded>
<View>{r74}</View>
</ActionSheet>;
};
@@ -0,0 +1,6 @@
// Metro module 15891 (f15892).
export const SOUND_BUTTON_HEIGHT = 88;
export const SOUND_ROW_HORIZONTAL_PADDING = 12;
export const SOUND_ROW_SPACING = 8;
export const SOUNDS_PER_ROW = 3;
export const SOUND_ROW_PADDING = 40;
@@ -0,0 +1,9 @@
// Metro module 11128 (f11129).
import AvatarUtils from "../../../../utils/AvatarUtils";
export default function getSoundboardEmojiUrl({ emojiId }, a1) {
return emojiId == null ? void 0 : AvatarUtils.getEmojiURL({
id: emojiId,
animated: false,
size: a1
});
};
@@ -0,0 +1,8 @@
// Metro module 15901 (f15902).
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
export default function openSoundboardSoundPreviewActionSheet(a0, a1) {
ActionSheetActionCreators.openLazy(import("../SoundboardSoundPreviewActionSheet"), "SoundboardSoundPreviewActionSheet", {
channelId: a0,
sound: a1
});
};
+66
View File
@@ -0,0 +1,66 @@
// Metro module 12633 (f12634).
import EmojiStore from "../emojis/EmojiStore";
import { AnalyticEvents, SearchTypes } from "../../Constants";
import debounce from "../../_bundle/debounce";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import UnicodeEmojis from "../emojis/UnicodeEmojis";
import fuzzysearch from "../../_bundle/fuzzysearch";
import { canUseSoundboardSound } from "./SoundboardUtils";
let c8720_6, c8720_7;
export function trackSearchStart(a0, a1) {
AnalyticsUtils.track(AnalyticEvents.SEARCH_STARTED, {
channel_id: a1,
search_type: SearchTypes.SOUNDBOARD,
location_stack: a0
});
}
export function trackSearchResultViewed(a0, a1, a2, a3) {
AnalyticsUtils.track(AnalyticEvents.SEARCH_RESULT_VIEWED, {
search_type: SearchTypes.SOUNDBOARD,
channel_id: a2,
query: a3,
total_results: a0.length,
location_stack: a1
});
}
c8720_6 = debounce(trackSearchStart, 350);
c8720_7 = debounce(trackSearchResultViewed, 350);
export function searchSounds(a0, a1, c19944_1, a3, a4) {
let c19944_4 = a1.reduce((acc, a1) => {
let r48;
const id = a3?.id;
c8720_6(a4, id);
const soundId = a1.soundId;
const r17 = a0.toLocaleLowerCase();
let c27348_0 = r17;
const r27 = a1.name.toLocaleLowerCase();
const r30 = a1.emojiId != null ? EmojiStore.getCustomEmojiById(a1.emojiId) : null;
const r19 = a1.emojiName != null ? UnicodeEmojis.convertSurrogateToName(a1.emojiName, false) : null;
const r41 = r19 != null ? UnicodeEmojis.getByName(r19) : null;
if (r30 != null) {
r48 = [r30.name];
} else {
r48 = r41?.names;
if (r48 == null) {
r48 = [];
}
}
const r1 = r17 === r27 ? 8 : 0;
const r0 = r48.includes(r17) ? r1 + 7 : r1;
const r55 = r27.startsWith(r17) ? r0 + 6 : r0;
const r60 = r48.some((item) => item.startsWith(c27348_0)) ? r55 + 5 : r55;
const r64 = r27.endsWith(r17) ? r60 + 4 : r60;
const r69 = r48.some((item) => item.endsWith(c27348_0)) ? r64 + 3 : r64;
const r79 = fuzzysearch(r17, a1.name.toLocaleLowerCase()) ? r69 + 2 : r69;
const r84 = r48.some((item) => fuzzysearch(c27348_0, item)) ? r79 + 1 : r79;
let r86 = r84 > 0;
if (0 < r84) {
r86 = canUseSoundboardSound(c19944_1, a1, a3);
}
acc[soundId] = r86 ? r84 + 100 : r84;
return acc;
}, {});
const r22 = a1.filter((item) => c19944_4[item.soundId] > 0).sort((a, b) => c19944_4[b.soundId] - c19944_4[a.soundId]);
c8720_7(r22, a4, a3?.id, a0);
return r22;
}
+33
View File
@@ -0,0 +1,33 @@
// Metro module 10780 (f10781).
import RunningGameStore_native from "../game_detection/RunningGameStore.native";
import ChannelStore from "../../stores/ChannelStore";
import RTCConnectionStore from "../../stores/RTCConnectionStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import { DEFAULT_SOUND_GUILD_ID } from "./SoundboardConstants";
import { AnalyticEvents } from "../../Constants";
import { AnalyticsPremiumFeatureNames, AnalyticsPremiumFeatureTiers } from "../premium/PremiumConstants";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
export default function trackSoundPlayed(a0, a1, a2, a3, a4) {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
const guild_id = channel == null ? void 0 : channel.getGuildId();
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
const rTCConnectionId = RTCConnectionStore.getRTCConnectionId();
const name = RunningGameStore_native.getCurrentGameForAnalytics()?.name;
const r30 = guild_id !== a2.guildId && a2.guildId !== DEFAULT_SOUND_GUILD_ID;
AnalyticsUtils.track(AnalyticEvents.PREMIUM_FEATURE_USAGE, {
feature_name: AnalyticsPremiumFeatureNames.SOUNDBOARD_PLAY,
feature_tier: r30 ? AnalyticsPremiumFeatureTiers.PREMIUM_STANDARD : AnalyticsPremiumFeatureTiers.FREE,
guild_id,
home_guild_id: a2.guildId,
location_stack: a0,
rtc_connection_id: rTCConnectionId,
media_session_id: mediaSessionId,
in_overlay: a1,
application_name: name,
emoji_count: a2.emojiId == null ? a2.emojiName != null ? 1 : 0 : 1,
feature_selection: a2.guildId !== DEFAULT_SOUND_GUILD_ID ? r30 ? "custom-external" : "custom" : "default",
feature_selection_id: a2.soundId,
sound_type: a3,
sequence_number: a4 != null ? a4 + 1 : null
});
};
+45
View File
@@ -0,0 +1,45 @@
// Metro module 10782 (f10783).
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import { CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID } from "./SoundboardConstants";
import { useStateFromStores } from "../../_bundle/Module589";
let c7245_4 = {
GLOBAL: 0,
0: "GLOBAL",
GUILD: 1,
1: "GUILD"
};
export { c7245_4 as CustomSoundType };
export function useCustomJoinSound(c18263_0) {
return useStateFromStores([UserSettingsProtoStore], () => {
let r6 = UserSettingsProtoStore.settings.guilds?.guilds;
if (r6 == null) {
r6 = {};
}
const joinSound = r6[c18263_0]?.joinSound;
const joinSound2 = r6[CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID]?.joinSound;
let r18 = joinSound;
if (r18 == null) {
r18 = joinSound2;
}
return r18 != null ? {
...r18,
type: joinSound != null ? c7245_4.GUILD : c7245_4.GLOBAL
} : void 0;
});
}
export function getCustomJoinSound(a0) {
let r6 = UserSettingsProtoStore.settings.guilds?.guilds;
if (r6 == null) {
r6 = {};
}
const joinSound = r6[a0]?.joinSound;
const joinSound2 = r6[CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID]?.joinSound;
let r17 = joinSound;
if (r17 == null) {
r17 = joinSound2;
}
return r17 != null ? {
...r17,
type: joinSound != null ? c7245_4.GUILD : c7245_4.GLOBAL
} : void 0;
}
@@ -0,0 +1,27 @@
// Metro module 8049 (f8050).
import { useMemo } from "react";
import GuildStore from "../../stores/GuildStore";
import SoundboardStore from "./SoundboardStore";
import { useStateFromStoresArray, useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
function $mk79763($env) {
return (a0) => $env[0].get(a0) == null;
}
export function useGuildIdsToFetchSoundsFor() {
let stateFromStores;
const stateFromStoresArray = useStateFromStoresArray([GuildStore], () => GuildStore.getGuildIds());
stateFromStores = useStateFromStores([SoundboardStore], () => SoundboardStore.getSounds());
return useMemo(() => {
let env26098;
const r3 = env26098 = {};
env26098[0] = stateFromStores;
return stateFromStoresArray.filter($mk79763(r3));
}, [stateFromStoresArray, stateFromStores]);
}
export function getGuildIdsToFetchSoundsFor() {
let env16219;
const guildIds = GuildStore.getGuildIds();
const sounds = SoundboardStore.getSounds();
const r7 = env16219 = {};
env16219[0] = sounds;
return guildIds.filter($mk79763(r7));
}
@@ -0,0 +1,31 @@
// Metro module 15894 (f15895).
import { useMemo } from "react";
import PermissionStore from "../../stores/PermissionStore";
import SortedGuildStore from "../../stores/SortedGuildStore";
import UserStore from "../../stores/UserStore";
import { EMPTY_STRING_SNOWFLAKE_ID } from "../../Constants";
import { Permissions } from "../../_bundle/Module505";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
import PremiumUtils from "../../utils/PremiumUtils";
export function useSortedGuildIdsForSoundboard(a0, a1) {
let EMPTY_STRING_SNOWFLAKE_ID2, stateFromStores2, stateFromStores3;
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
let r17 = a0?.guild_id;
if (r17 == null) {
r17 = EMPTY_STRING_SNOWFLAKE_ID;
}
EMPTY_STRING_SNOWFLAKE_ID2 = r17;
stateFromStores2 = useStateFromStores([SortedGuildStore], () => SortedGuildStore.getFlattenedGuildIds());
stateFromStores3 = useStateFromStores([PermissionStore], () => a0 == null || a0.guild_id == null || PermissionStore.can(Permissions.USE_EXTERNAL_SOUNDS, a0));
return useMemo(() => {
if (!(!PremiumUtils.canUseSoundboardEverywhere(stateFromStores) && a1) && stateFromStores3) {
const r17 = EMPTY_STRING_SNOWFLAKE_ID2 !== "";
const r18 = r17 ? stateFromStores2.filter((item) => item !== EMPTY_STRING_SNOWFLAKE_ID2) : stateFromStores2;
if (r17) {
r18.unshift(EMPTY_STRING_SNOWFLAKE_ID2);
}
return r18;
}
return [EMPTY_STRING_SNOWFLAKE_ID2];
}, [stateFromStores, a1, EMPTY_STRING_SNOWFLAKE_ID2, stateFromStores2, stateFromStores3]);
}
+288
View File
@@ -0,0 +1,288 @@
// Metro module 15892 (f15893).
import { useMemo } from "react";
import GuildStore from "../../stores/GuildStore";
import PermissionStore from "../../stores/PermissionStore";
import UserStore from "../../stores/UserStore";
import SoundboardStore from "./SoundboardStore";
import { DEFAULT_SOUND_GUILD_ID, EMPTY_SOUND_LIST } from "./SoundboardConstants";
import { PremiumTypes } from "../premium/PremiumConstants";
import { SoundboardSoundItemType, SoundboardSoundGridSectionType } from "./SoundboardTypes";
import { getMaxSoundboardSlots } from "../../utils/GuildBoostingUtils";
import { useSoundOrganizer, sortSoundsOldestToNewestCreationDate } from "./useSoundOrganizer";
import { useStateFromStores, useStateFromStoresArray } from "../../_bundle/Module589";
import PremiumUtils from "../../utils/PremiumUtils";
import { useSortedGuildIdsForSoundboard } from "./useSortedGuildIdsForSoundboard";
import { getManageResourcePermissions } from "../permissions/useManageResourcePermissions";
import SoundboardFrequentlyUsedExperiment from "./SoundboardFrequentlyUsedExperiment";
let _addSectionForPotentialSoundIds, $mk98061 = function() {
return (a0, a1) => ({
type: SoundboardSoundItemType.SOUND,
sound: a0,
index: a1
});
};
const createSoundItems = function createSoundItems(a0, sortSoundsFn) {
return (sortSoundsFn != null ? sortSoundsFn(a0) : a0).map($mk98061());
};
_addSectionForPotentialSoundIds = function _addSectionForPotentialSoundIds({ sections, guildIds, allSounds: allSounds2, potentialSoundIdsForSection, sectionType, sortSoundsFn }) {
const r10 = {};
let c22574_1 = r10;
for (const item of [...guildIds, DEFAULT_SOUND_GUILD_ID]) {
let r17 = allSounds2.get(item);
if (r17 == null) {
r17 = [];
}
const _loop = function _loop(a0) {
if (potentialSoundIdsForSection.find((item) => item === a0.soundId) != null) {
c22574_1[a0.soundId] = a0;
}
};
for (const item2 of r17) {
_loop(item2);
}
}
const r51 = [];
for (const item3 of potentialSoundIdsForSection) {
const r58 = r10[item3];
if (r58 != null) {
r51.push(r58);
}
}
const soundItems = createSoundItems(r51, sortSoundsFn);
if (soundItems.length > 0) {
sections.push({
key: sectionType,
categoryInfo: {
type: sectionType
},
items: soundItems
});
}
};
export default function useSoundGrid(a0) {
let isPremium, allSounds, c22575_5, c22575_6, isFetching, soundOrganizer, sortedGuildIdsForSoundboard, stateFromStoresArray, canUseSoundboardEverywhere, stateFromStores, stateFromStores2, memo, enabled;
let r4 = arguments[1];
if (r4 === void 0) {
r4 = {};
}
let filterOutEmptyCurrentGuild = r4.filterOutEmptyCurrentGuild;
if (filterOutEmptyCurrentGuild === void 0) {
filterOutEmptyCurrentGuild = false;
}
let c22575_1 = filterOutEmptyCurrentGuild;
let r11 = arguments[2];
if (r11 === void 0) {
r11 = false;
}
let c22575_2 = r11;
isPremium = void 0;
allSounds = void 0;
c22575_5 = void 0;
c22575_6 = void 0;
isFetching = void 0;
soundOrganizer = void 0;
sortedGuildIdsForSoundboard = void 0;
stateFromStoresArray = void 0;
canUseSoundboardEverywhere = void 0;
stateFromStores = void 0;
stateFromStores2 = void 0;
memo = void 0;
enabled = void 0;
const stateFromStores3 = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
isPremium = PremiumUtils.isPremium(stateFromStores3, PremiumTypes.TIER_2);
let r18, r41;
[allSounds, r18, r41, isFetching] = useStateFromStoresArray([SoundboardStore], () => [SoundboardStore.getSounds(), SoundboardStore.getFavorites(), SoundboardStore.getFrequentlyUsedSoundIds(), SoundboardStore.isFetching()]);
c22575_5 = r18;
c22575_6 = r41;
soundOrganizer = useSoundOrganizer();
sortedGuildIdsForSoundboard = useSortedGuildIdsForSoundboard(a0, false);
stateFromStoresArray = useStateFromStoresArray([GuildStore], () => {
const r4 = [];
let c28175_0 = r4;
sortedGuildIdsForSoundboard.forEach((item) => {
const guild = GuildStore.getGuild(item);
if (guild != null) {
c28175_0.push(guild);
}
});
return r4;
});
canUseSoundboardEverywhere = PremiumUtils.canUseSoundboardEverywhere(stateFromStores3);
stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(a0?.guild_id));
stateFromStores2 = useStateFromStores([PermissionStore], () => getManageResourcePermissions(stateFromStores).canCreateExpressions, [stateFromStores]);
memo = useMemo(() => c22575_6.filter((item) => !c22575_5.has(item)).slice(0, 3), [r41, r18]);
enabled = SoundboardFrequentlyUsedExperiment.useConfig({
location: memo.length > 0 ? "useSoundGrid" : "useSoundGridNoFrequentlyUsed"
}).enabled;
return useMemo(() => {
let r138;
let unlockedCustomSoundCount = 0;
let lockedCustomSoundCount = 0;
const categories = [];
if (c22575_2) {
let r147 = allSounds.get(DEFAULT_SOUND_GUILD_ID);
if (r147 == null) {
r147 = EMPTY_SOUND_LIST;
}
categories.push({
key: SoundboardSoundGridSectionType.DEFAULTS,
categoryInfo: {
type: SoundboardSoundGridSectionType.DEFAULTS
},
items: (sortSoundsOldestToNewestCreationDate != null ? sortSoundsOldestToNewestCreationDate(r147) : r147).map($mk98061())
});
let availableSounds = allSounds.get(DEFAULT_SOUND_GUILD_ID);
if (availableSounds == null) {
availableSounds = EMPTY_SOUND_LIST;
}
r138 = {
categories,
availableSounds,
isFetching,
soundCounts: {
favoriteSoundCount: 0,
unlockedCustomSoundCount: 0,
lockedCustomSoundCount: 0
}
};
} else {
const r15 = Array;
_addSectionForPotentialSoundIds({
sections: categories,
guildIds: sortedGuildIdsForSoundboard,
allSounds,
potentialSoundIdsForSection: r15.from(c22575_5),
sectionType: SoundboardSoundGridSectionType.FAVORITES,
sortSoundsFn: sortSoundsOldestToNewestCreationDate
});
let r30 = enabled;
if (enabled) {
r30 = memo.length > 0;
}
if (r30) {
_addSectionForPotentialSoundIds({
sections: categories,
guildIds: sortedGuildIdsForSoundboard,
allSounds,
potentialSoundIdsForSection: memo,
sectionType: SoundboardSoundGridSectionType.FREQUENTLY_USED
});
}
if (stateFromStores !== void 0) {
let r42 = c22575_1;
let r44 = allSounds.get(stateFromStores.id);
if (r44 == null) {
r44 = [];
}
const items = (soundOrganizer != null ? soundOrganizer(r44) : r44).map($mk98061());
const r54 = r44.length < getMaxSoundboardSlots(stateFromStores) && stateFromStores2;
const r56 = items.length === 0;
if (!((r54 ? !r54 : !r56) || r42)) {
items.push({
type: SoundboardSoundItemType.ADD_SOUND,
guild: stateFromStores
});
}
if (r42) {
r42 = r56;
}
if (!r42) {
categories.push({
categoryInfo: {
type: SoundboardSoundGridSectionType.GUILD,
guild: stateFromStores,
isNitroLocked: false
},
key: stateFromStores.id,
items
});
}
}
if (!canUseSoundboardEverywhere) {
let r77 = allSounds.get(DEFAULT_SOUND_GUILD_ID);
if (r77 == null) {
r77 = EMPTY_SOUND_LIST;
}
categories.push({
key: SoundboardSoundGridSectionType.DEFAULTS,
categoryInfo: {
type: SoundboardSoundGridSectionType.DEFAULTS
},
items: (sortSoundsOldestToNewestCreationDate != null ? sortSoundsOldestToNewestCreationDate(r77) : r77).map($mk98061())
});
}
(function addGuildsSections({ sections, guilds, currentGuildId, allSounds: allSounds2, hasNitro, sortSoundsFn }) {
for (const item of guilds) {
if (item.id !== currentGuildId) {
let r39 = allSounds2.get(item.id);
if (r39 == null) {
r39 = [];
}
const items = createSoundItems(r39, sortSoundsFn);
if (items.length > 0) {
const guild = item;
sections.push({
categoryInfo: {
type: SoundboardSoundGridSectionType.GUILD,
guild,
isNitroLocked: !hasNitro
},
key: guild.id,
items
});
}
}
}
})({
sections: categories,
guilds: stateFromStoresArray,
currentGuildId: stateFromStores?.id,
allSounds,
hasNitro: isPremium,
sortSoundsFn: soundOrganizer
});
if (canUseSoundboardEverywhere) {
let r108 = allSounds.get(DEFAULT_SOUND_GUILD_ID);
if (r108 == null) {
r108 = EMPTY_SOUND_LIST;
}
categories.push({
key: SoundboardSoundGridSectionType.DEFAULTS,
categoryInfo: {
type: SoundboardSoundGridSectionType.DEFAULTS
},
items: (sortSoundsOldestToNewestCreationDate != null ? sortSoundsOldestToNewestCreationDate(r108) : r108).map($mk98061())
});
}
categories.forEach((category) => {
if (category.categoryInfo.type === SoundboardSoundGridSectionType.GUILD) {
if (category.categoryInfo.isNitroLocked) {
lockedCustomSoundCount = lockedCustomSoundCount + category.items.length;
} else {
unlockedCustomSoundCount = unlockedCustomSoundCount + category.items.length;
}
}
});
r138 = {
categories,
availableSounds: Array.from(allSounds.values()).flat(),
isFetching,
soundCounts: {
favoriteSoundCount: c22575_5.size,
unlockedCustomSoundCount,
lockedCustomSoundCount
}
};
}
return r138;
}, [sortedGuildIdsForSoundboard, allSounds, r18, enabled, stateFromStores, stateFromStores2, filterOutEmptyCurrentGuild, canUseSoundboardEverywhere, stateFromStoresArray, r11, isFetching, isPremium, soundOrganizer, memo]);
};
export function useSearchCategories(a0, a1, a2) {
return useMemo(() => a2.length > 0 ? [{
key: SoundboardSoundGridSectionType.SEARCH,
categoryInfo: {
type: SoundboardSoundGridSectionType.SEARCH
},
items: a1.map($mk98061())
}] : a0, [a0, a2.length, a1]);
}
+10
View File
@@ -0,0 +1,10 @@
// Metro module 15893 (f15894).
import SnowflakeUtils from "../../utils/SnowflakeUtils";
const sortSoundsOldestToNewestCreationDate = function sortSoundsOldestToNewestCreationDate(a0, r6 = true) {
const r12 = [...a0].sort((a, b) => SnowflakeUtils.compare(a.soundId, b.soundId));
return r6 ? [...r12].sort((a, b) => a.available ? b.available ? a.available ? 0 : b.available ? 1 : 0 : -1 : a.available ? 0 : b.available ? 1 : 0) : r12;
};
export { sortSoundsOldestToNewestCreationDate };
export function useSoundOrganizer() {
return sortSoundsOldestToNewestCreationDate;
}
@@ -0,0 +1,32 @@
// Metro module 15899 (f15900).
import { useContext, useCallback } from "react";
import SoundboardStore from "./SoundboardStore";
import { SoundOutputChannel } from "../sound_playback/Constants";
import { SoundboardSettings } from "../user_settings/UserSettings";
import SoundPlayerContext from "../soundplayer/SoundPlayerContext";
import { useStateFromStores } from "../../_bundle/Module589";
import { playSound } from "./SoundboardUtils";
export default function useSoundboardSoundPlayer(a0, a1) {
let c22586_0 = a0;
if (arguments[2] === void 0) {
SoundboardSettings.getSetting()?.volume == null;
}
if (arguments[3] === void 0) {
SoundOutputChannel.DEFAULT;
}
const audioRef = useContext(SoundPlayerContext).audioRef;
const stateFromStores = useStateFromStores([SoundboardStore], () => SoundboardStore.isPlayingSound(c22586_0.soundId), [a0]);
return {
playSoundboardSound: useCallback((a0) => {
if (audioRef.current != null) {
audioRef.current.pause();
}
if (a1 != null) {
playSound(c22586_0, a1, a0);
}
}, [a0, audioRef, a1]),
isPlayingSound: stateFromStores,
previewSound: () => Promise.resolve(),
isPreviewingSound: false
};
};