270 lines
17 KiB
TypeScript
270 lines
17 KiB
TypeScript
/* Metro module 6951; source: modules/soundboard/SoundboardUtils.tsx; dependencies: [5, 1348, 1383, 3784, 1878, 4613, 4614, 661, 1346, 3829, 3802, 6952, 6944, 6639, 6953, 6980, 6981, 6982, 632, 3995, 1365, 1362, 683, 4863, 2] */
|
|
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
|
|
import AnalyticsUtils from '../../utils/AnalyticsUtils.tsx'; /* Metro dependency 683 */
|
|
import UserSettingsProtoStore from '../user_settings/UserSettingsProtoStore.tsx'; /* Metro dependency 1348 */
|
|
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
|
|
import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */
|
|
import SoundboardStore from './SoundboardStore.tsx'; /* Metro dependency 4613 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ExpressionPickerConstantsModule from '../expression_picker/ExpressionPickerConstants.tsx'; /* Metro dependency 1346 */
|
|
import * as UserSettingsProtoActionCreatorsModule from '../user_settings/UserSettingsProtoActionCreators.tsx'; /* Metro dependency 1362 */
|
|
import * as ChannelRecordModule from '../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */
|
|
import * as UserSettingsModule from '../user_settings/UserSettings.tsx'; /* Metro dependency 3829 */
|
|
import * as SoundboardConstantsModule from './SoundboardConstants.tsx'; /* Metro dependency 4614 */
|
|
import * as SoundboardTypesModule from './SoundboardTypes.tsx'; /* Metro dependency 6639 */
|
|
import * as SoundboardActionCreatorsModule from './SoundboardActionCreators.tsx'; /* Metro dependency 6944 */
|
|
import * as UseMuteStatesModule from '../video_calls/useMuteStates.tsx'; /* Metro dependency 6952 */
|
|
import * as VoiceChannelEffectsActionCreatorsModule from '../voice_channel_effects/VoiceChannelEffectsActionCreators.tsx'; /* Metro dependency 6953 */
|
|
|
|
function _fun55284(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#55284, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:6, offset: 0x0137a8b2, size: 459 bytes, params: 8, frame: 23
|
|
const env0_0 = require;
|
|
const closure = function(a0, a1) {
|
|
var r0;
|
|
var value = undefined;
|
|
r0 = (a1 == null ? value : a1.guild_id) == null || PermissionStore.can(Permissions.USE_EXTERNAL_SOUNDS, a1);
|
|
r0 = !r0 ? a0.guildId === DEFAULT_SOUND_GUILD_ID : r0;
|
|
r0 = !r0 ? a0.guildId === (a1 == null ? value : a1.guild_id) : r0;
|
|
return r0;
|
|
};
|
|
const canUseSoundboardSound2 = canUseSoundboardSound;
|
|
const canMakeSound2 = canMakeSound;
|
|
const hasSetAnyCustomJoinSound2 = hasSetAnyCustomJoinSound;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = SoundboardConstantsModule;
|
|
const env0_9 = value.CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID;
|
|
const env0_10 = value.DEFAULT_SOUND_GUILD_ID;
|
|
value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_11 = value.Permissions;
|
|
const env0_12 = value.AnalyticEvents;
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/soundboard/SoundboardUtils.tsx');
|
|
exports.getAmplitudinalSoundboardVolume = getAmplitudinalSoundboardVolume;
|
|
exports.hasPermissionToPlaySound = closure;
|
|
exports.canUseSoundboardSound = canUseSoundboardSound2;
|
|
exports.canMakeSound = canMakeSound2;
|
|
exports.playSound = playSound;
|
|
exports.hasSetAnyCustomJoinSound = hasSetAnyCustomJoinSound2;
|
|
exports.maybePlayCustomJoinSound = function() {
|
|
return _maybePlayCustomJoinSound.apply(this, arguments);
|
|
};
|
|
exports.useSoundBoardDismissContentTypes = useSoundBoardDismissContentTypes;
|
|
exports.removeCustomJoinSound = removeCustomJoinSound;
|
|
exports.updateCustomJoinSound = updateCustomJoinSound;
|
|
exports.trackCustomCallSoundExternallyDeleted = function({location}) {
|
|
var defaultImport = importDefault(dependencyMap[22]);
|
|
var USER_CUSTOM_CALL_SOUND_SETTING_GUILD_REMOVED = AnalyticEvents.USER_CUSTOM_CALL_SOUND_SETTING_GUILD_REMOVED;
|
|
defaultImport.track(USER_CUSTOM_CALL_SOUND_SETTING_GUILD_REMOVED, {location_stack: location});
|
|
};
|
|
exports.trackSoundFavorited = function({sound, location}) {
|
|
var defaultImport = importDefault(dependencyMap[23]);
|
|
var EXPRESSION_FAVORITED = AnalyticEvents.EXPRESSION_FAVORITED;
|
|
defaultImport.trackWithMetadata(EXPRESSION_FAVORITED, {location: location,
|
|
expression_type: ExpressionPickerViewType.SOUNDBOARD, expression_id: sound.soundId,
|
|
expression_name: sound.name,
|
|
expression_guild_id: sound.guildId});
|
|
};
|
|
function canUseSoundboardSound(a0, a1, a2) { // fn#55286, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:511, offset: 0x0137aae6, size: 131 bytes, params: 4, frame: 18
|
|
const value = a3;
|
|
const value2 = undefined;
|
|
const r1 = !(value !== value2) || value;
|
|
let r0 = (importDefault(3802) /* metro dependency 3802: PremiumUtils */).canUseSoundboardEverywhere(a0) || a1.guildId === (a2 == null ? value2 : a2.guild_id);
|
|
r0 = (!r0 ? a1.guildId === DEFAULT_SOUND_GUILD_ID : r0) && hasPermissionToPlaySound(a1,
|
|
a2) && (r1 ? a1.available : !r1);
|
|
return r0;
|
|
}
|
|
|
|
function canMakeSound(a0) { // fn#55287, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:707, offset: 0x0137ab69, size: 68 bytes, params: 2, frame: 12
|
|
let value = UseMuteStatesModule;
|
|
value = value.getMuteStates({channel: a0});
|
|
return !value.mute && !value.suppress;
|
|
}
|
|
|
|
function hasSetAnyCustomJoinSound() { // fn#55288, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:809, offset: 0x0137abad, size: 80 bytes, params: 1, frame: 12
|
|
let guilds = UserSettingsProtoStore.settings.guilds;
|
|
guilds = guilds?.guilds;
|
|
const r2 = guilds ?? ({});
|
|
const Object = global.Object;
|
|
return Object.values(r2).some(function(a0) {
|
|
return a0.joinSound != null;
|
|
});
|
|
}
|
|
|
|
function _maybePlayCustomJoinSound() { // fn#55290, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:967, offset: 0x0137ac0e, size: 48 bytes, params: 1, frame: 14
|
|
return Module00005(_fun55292).apply(this, arguments);
|
|
function* _fun55292(a0) { // fn#55292, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:1040, offset: 0x0137ac47, size: 450 bytes, params: 2, frame: 23
|
|
var r10;
|
|
var r3;
|
|
var value10;
|
|
var value11;
|
|
var value14;
|
|
var id;
|
|
var binding3;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
value = environment.__proto__.__proto__;
|
|
let binding = env2_7;
|
|
const currentUser = binding.getCurrentUser();
|
|
binding = env2_1;
|
|
const binding2 = env2_2;
|
|
const value4 = undefined;
|
|
const value5 = binding(binding2[15])();
|
|
const customJoinSound = env2_0(binding2[16]).getCustomJoinSound(a0);
|
|
const value8 = null;
|
|
if (value8 != value5) {
|
|
binding = env2_5;
|
|
if (binding.has(value5.type)) {
|
|
return value4;
|
|
}
|
|
if (value8 == customJoinSound) {
|
|
return value4;
|
|
}
|
|
var value9 = env2_1(env2_2[10]);
|
|
if (value9.canUseCustomCallSounds(currentUser)) {
|
|
binding = env2_0;
|
|
value10 = binding(env2_2[17]);
|
|
if (value10.canSelectedVoiceChannelUseSoundboard()) {
|
|
binding = env2_0;
|
|
value11 = binding(env2_2[12]);
|
|
yield value11.maybeFetchSoundboardSounds();
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
r10 = customJoinSound.guildId === env2_9 ? env2_10 : customJoinSound.guildId;
|
|
binding = env2_8;
|
|
value14 = binding.getSound(r10, customJoinSound.soundId);
|
|
if (value8 == value14) {
|
|
return value4;
|
|
}
|
|
if (env2_14(value14, value5)) {
|
|
if (env2_15(currentUser, value14, value5, true)) {
|
|
if (env2_16(value5)) {
|
|
id = value5.id;
|
|
binding = env2_0;
|
|
binding3 = env2_2;
|
|
value = binding(binding3[12]);
|
|
value.playSoundLocally(id, value14,
|
|
binding(binding3[13]).LocalSoundTrigger.JOINED_VOICE_CHANNEL);
|
|
value = binding(binding3[14]);
|
|
value.sendVoiceChannelCustomCallSoundEffect(id, value14, false);
|
|
r3 = value4;
|
|
} else {
|
|
r3 = value8;
|
|
}
|
|
} else {
|
|
r3 = value8;
|
|
}
|
|
} else {
|
|
r3 = value8;
|
|
}
|
|
return r3;
|
|
}
|
|
return value4;
|
|
}
|
|
}
|
|
return value4;
|
|
}
|
|
|
|
}
|
|
|
|
function trackCustomCallSettingsChanged({guildId, changeType, soundType, soundSource, location}) { // fn#55293, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:1660, offset: 0x0137ae09, size: 130 bytes, params: 2, frame: 20
|
|
const defaultImport = AnalyticsUtils;
|
|
const track = defaultImport.track;
|
|
const USER_CUSTOM_CALL_SOUND_SETTING_UPDATED = AnalyticEvents.USER_CUSTOM_CALL_SOUND_SETTING_UPDATED;
|
|
const object = {location_stack: location};
|
|
object.guild_id = guildId === '' ? 0 : global.Number(guildId);
|
|
object.change_type = changeType;
|
|
object.sound_type = soundType;
|
|
object.sound_source = soundSource;
|
|
Reflect.apply(track, defaultImport, [USER_CUSTOM_CALL_SOUND_SETTING_UPDATED, object]);
|
|
}
|
|
|
|
function getAmplitudinalSoundboardVolume() { // fn#55294, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:2016, offset: 0x0137ae8b, size: 71 bytes, params: 1, frame: 12
|
|
const value = undefined;
|
|
const SoundboardSettings = (UserSettingsModule).SoundboardSettings;
|
|
const setting = SoundboardSettings.getSetting();
|
|
return (setting == null ? value : setting.volume) ?? 100;
|
|
}
|
|
|
|
function playSound(a0, a1, a2, a3) { // fn#55295, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:2293, offset: 0x0137aed2, size: 109 bytes, params: 5, frame: 20
|
|
const playSoundLocally = SoundboardActionCreatorsModule.playSoundLocally;
|
|
const LocalSoundTrigger = (SoundboardTypesModule).LocalSoundTrigger;
|
|
const SOUNDBOARD = LocalSoundTrigger.SOUNDBOARD;
|
|
Reflect.apply(playSoundLocally, SoundboardActionCreatorsModule, [a1, a0, SOUNDBOARD]);
|
|
(VoiceChannelEffectsActionCreatorsModule).sendVoiceChannelSoundboardEffect(a1,
|
|
a0, false, a2, a3);
|
|
}
|
|
|
|
function useSoundBoardDismissContentTypes({isSoundboardButtonDisabled}) { // fn#55297, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:2651, offset: 0x0137af3f, size: 201 bytes, params: 2, frame: 17
|
|
isSoundboardButtonDisabled = !(isSoundboardButtonDisabled === undefined) && isSoundboardButtonDisabled;
|
|
const currentUser = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([UserStore],
|
|
function() {
|
|
return UserStore.getCurrentUser();
|
|
});
|
|
items2 = [];
|
|
if (!isSoundboardButtonDisabled) {
|
|
if (!hasSetAnyCustomJoinSound()) {
|
|
if ((importDefault(3802) /* metro dependency 3802: PremiumUtils */).canUseCustomCallSounds(currentUser) || (require(3995) /* metro dependency 3995: UserUtils */).ageEligibleForPremiumUpsell(currentUser)) {
|
|
items2.push((require(1365) /* metro dependency 1365: dismissible_content */).DismissibleContent.CUSTOM_CALL_SOUNDS_PICKER_UPSELL);
|
|
}
|
|
}
|
|
}
|
|
return items2;
|
|
}
|
|
|
|
function removeCustomJoinSound(a0, a1) { // fn#55299, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:3023, offset: 0x0137b01a, size: 82 bytes, params: 3, frame: 18
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const updateUserGuildSettings = UserSettingsProtoActionCreatorsModule.updateUserGuildSettings;
|
|
const UserSettingsDelay = (UserSettingsProtoActionCreatorsModule).UserSettingsDelay;
|
|
const INFREQUENT_USER_ACTION = UserSettingsDelay.INFREQUENT_USER_ACTION;
|
|
Reflect.apply(updateUserGuildSettings, UserSettingsProtoActionCreatorsModule, [a0, _fun55300, INFREQUENT_USER_ACTION]);
|
|
function _fun55300(a0) { // fn#55300, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:3095, offset: 0x0137b06c, size: 109 bytes, params: 2, frame: 16
|
|
a0.joinSound = undefined;
|
|
const trackCustomCallSettingsChangedBinding = trackCustomCallSettingsChanged;
|
|
const object = {};
|
|
object.guildId = env0_0;
|
|
const AnalyticsChangeType = (SoundboardTypesModule).AnalyticsChangeType;
|
|
const REMOVED = AnalyticsChangeType.REMOVED;
|
|
object.changeType = REMOVED;
|
|
const AnalyticsSoundType = (SoundboardTypesModule).AnalyticsSoundType;
|
|
const ENTRY = AnalyticsSoundType.ENTRY;
|
|
object.soundType = ENTRY;
|
|
object.location = require;
|
|
trackCustomCallSettingsChangedBinding(object);
|
|
}
|
|
|
|
}
|
|
|
|
function updateCustomJoinSound(a0, a1, a2) { // fn#55301, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:3343, offset: 0x0137b0d9, size: 89 bytes, params: 4, frame: 18
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const env0_2 = a2;
|
|
const updateUserGuildSettings = UserSettingsProtoActionCreatorsModule.updateUserGuildSettings;
|
|
const UserSettingsDelay = (UserSettingsProtoActionCreatorsModule).UserSettingsDelay;
|
|
const INFREQUENT_USER_ACTION = UserSettingsDelay.INFREQUENT_USER_ACTION;
|
|
Reflect.apply(updateUserGuildSettings, UserSettingsProtoActionCreatorsModule, [a0, _fun55302, INFREQUENT_USER_ACTION]);
|
|
function _fun55302(a0) { // fn#55302, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7129:3417, offset: 0x0137b132, size: 261 bytes, params: 2, frame: 18
|
|
const AnalyticsChangeType = (SoundboardTypesModule).AnalyticsChangeType;
|
|
const value3 = require.guildId === DEFAULT_SOUND_GUILD_ID;
|
|
const AnalyticsSoundSource = (SoundboardTypesModule).AnalyticsSoundSource;
|
|
const r5 = value3 ? AnalyticsSoundSource.DEFAULT : AnalyticsSoundSource.CUSTOM;
|
|
const r7 = a0.joinSound != null ? AnalyticsChangeType.UPDATED : AnalyticsChangeType.ADDED;
|
|
a0.joinSound = {soundId: require.soundId, guildId: value3 ? CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID : require.guildId};
|
|
const trackCustomCallSettingsChangedBinding = trackCustomCallSettingsChanged;
|
|
object = {guildId: env0_0, changeType: r7, soundSource: r5};
|
|
const AnalyticsSoundType = (SoundboardTypesModule).AnalyticsSoundType;
|
|
const ENTRY = AnalyticsSoundType.ENTRY;
|
|
object.soundType = ENTRY;
|
|
object.location = importDefault;
|
|
trackCustomCallSettingsChangedBinding(object);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun55284, 6951, [5, 1348, 1383, 3784, 1878, 4613, 4614, 661, 1346, 3829, 3802, 6952, 6944, 6639, 6953,
|
|
6980, 6981, 6982, 632, 3995, 1365, 1362, 683, 4863,
|
|
2]) /* metro module 6951, dependencies: [5, 1348, 1383, 3784, 1878, 4613, 4614, 661, 1346, 3829, 3802, 6952, 6944, 6639, 6953, 6980, 6981, 6982, 632, 3995, 1365, 1362, 683, 4863, 2] */;
|