345 lines
21 KiB
TypeScript
345 lines
21 KiB
TypeScript
/* Metro module 11592; source: modules/app_launcher/native/AppLauncherNativeUtils.tsx; dependencies: [31, 1379, 1878, 1483, 661, 5066, 4863, 5068, 11593, 5065, 1909, 7166, 1860, 8046, 1423, 8774, 8620, 11598, 6777, 8092, 4081, 2] */
|
|
import ChannelStore from '../../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
|
|
import UserStore from '../../../stores/UserStore.tsx'; /* Metro dependency 1878 */
|
|
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
|
|
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as AppLauncherNativeConstantsModule from './AppLauncherNativeConstants.tsx'; /* Metro dependency 1483 */
|
|
import * as ServerModule from '../../../flow/Server.tsx'; /* Metro dependency 1909 */
|
|
import * as AppAnalyticsUtilsModule from '../../app_analytics/AppAnalyticsUtils.tsx'; /* Metro dependency 4863 */
|
|
import * as ApplicationCommandUtilsModule from '../../application_commands/ApplicationCommandUtils.tsx'; /* Metro dependency 5065 */
|
|
import * as ApplicationCommandConstantsModule from '../../application_commands/ApplicationCommandConstants.tsx'; /* Metro dependency 5066 */
|
|
import * as ApplicationCommandTypesModule from '../../application_commands/ApplicationCommandTypes.tsx'; /* Metro dependency 5068 */
|
|
import * as UseGetOrFetchApplicationsModule from '../../applications/useGetOrFetchApplications.tsx'; /* Metro dependency 6777 */
|
|
import * as AnalyticsModule from '../../../hooks/analytics.tsx'; /* Metro dependency 8620 */
|
|
import * as AppLauncherContextModule from './AppLauncherContext.tsx'; /* Metro dependency 8774 */
|
|
import * as FrecencySectionModule from './screens/home/FrecencySection.tsx'; /* Metro dependency 11593 */
|
|
import * as UseActivityShelfItemModule from '../../activities/utils/useActivityShelfItem.tsx'; /* Metro dependency 11598 */
|
|
|
|
function _fun88751(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#88751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:6, offset: 0x01ff04d6, size: 311 bytes, params: 8, frame: 20
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/app_launcher/native/AppLauncherNativeUtils.tsx');
|
|
exports.handleApplicationSelected = handleApplicationSelected;
|
|
exports.handleViewAllSelected = handleViewAllSelected;
|
|
exports.handleApplicationCommandSelected = handleApplicationCommandSelected;
|
|
exports.getInitialOptionValues = getInitialOptionValues;
|
|
exports.getAppLauncherIconSource = getAppLauncherIconSource;
|
|
exports.useLogAppLauncherEmptyStateView = useLogAppLauncherEmptyStateView;
|
|
exports.useHandleActivityItemSelected = useHandleActivityItemSelected;
|
|
function handleApplicationSelected({location, application, navigation, context, sectionName, installOnDemand, query, searchResultsPosition, navigates, entrypoint}) { // fn#88752, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:369, offset: 0x01ff060d, size: 302 bytes, params: 2, frame: 28
|
|
const ApplicationCommandTriggerSections = (ApplicationCommandTypesModule).ApplicationCommandTriggerSections;
|
|
navigates = navigates === undefined || navigates;
|
|
const trackWithMetadata = AppAnalyticsUtilsModule.trackWithMetadata;
|
|
const APPLICATION_COMMAND_SECTION_SELECTED = AnalyticEvents.APPLICATION_COMMAND_SECTION_SELECTED;
|
|
const id = application.id;
|
|
const BUILT_IN = BuiltInSectionId.BUILT_IN;
|
|
Reflect.apply(trackWithMetadata, AppAnalyticsUtilsModule, [APPLICATION_COMMAND_SECTION_SELECTED,
|
|
{location: location,
|
|
section: id === BUILT_IN ? ApplicationCommandTriggerSections.BUILT_IN : ApplicationCommandTriggerSections.APP,
|
|
application_id: application.id ?? null, section_name: sectionName, query: query,
|
|
search_results_position: searchResultsPosition, source: entrypoint}]);
|
|
if (navigates) {
|
|
navigation.navigate(AppLauncherRouteName.APPLICATION_VIEW, {application: application, context: context,
|
|
installOnDemand: installOnDemand, sectionName: sectionName, entrypoint: entrypoint});
|
|
}
|
|
}
|
|
|
|
function handleViewAllSelected({location, navigation, context, sectionName, sectionOverallPosition, applications, sectionItemType, commands, sectionDescriptors, title, promotedApplicationIds}) { // fn#88753, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:980, offset: 0x01ff073b, size: 239 bytes, params: 2, frame: 29
|
|
const trackWithMetadata = AppAnalyticsUtilsModule.trackWithMetadata;
|
|
const APP_LAUNCHER_SECTION_VIEW_MORE = AnalyticEvents.APP_LAUNCHER_SECTION_VIEW_MORE;
|
|
const object = {section_name: sectionName};
|
|
const SectionItemType = (FrecencySectionModule).SectionItemType;
|
|
const APPS = SectionItemType.APPS;
|
|
object.num = sectionItemType === APPS ? applications.length : commands.length;
|
|
Reflect.apply(trackWithMetadata, AppAnalyticsUtilsModule, [APP_LAUNCHER_SECTION_VIEW_MORE, object]);
|
|
const navigate = navigation.navigate;
|
|
const APP_LIST_VIEW = AppLauncherRouteName.APP_LIST_VIEW;
|
|
Reflect.apply(navigate, navigation, [APP_LIST_VIEW, {analyticsLocation: location, context: context,
|
|
sectionName: sectionName, sectionOverallPosition: sectionOverallPosition, applications: applications,
|
|
sectionItemType: sectionItemType, commands: commands, sectionDescriptors: sectionDescriptors, title: title,
|
|
promotedApplicationIds: promotedApplicationIds}]);
|
|
}
|
|
|
|
function handleApplicationCommandSelected({location, context, command, section, sectionDescriptors, query, navigation, installOnDemand, sectionName, searchResultsPosition, entrypoint, onCommandExecuted}) { // fn#88754, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:1550, offset: 0x01ff082a, size: 439 bytes, params: 2, frame: 31
|
|
var r13;
|
|
var navigate;
|
|
const trackCommandSelected = ApplicationCommandUtilsModule.trackCommandSelected;
|
|
const object = {command: command, location: location};
|
|
object.triggerSection = ApplicationCommandUtilsModule.getCommandTriggerSection(section);
|
|
object.queryLength = query.length;
|
|
object.sectionName = sectionName;
|
|
object.query = query;
|
|
object.searchResultsPosition = searchResultsPosition;
|
|
object.source = entrypoint;
|
|
Reflect.apply(trackCommandSelected, ApplicationCommandUtilsModule, [object]);
|
|
const type = command.type;
|
|
const ApplicationCommandType = (ServerModule).ApplicationCommandType;
|
|
const PRIMARY_ENTRY_POINT = ApplicationCommandType.PRIMARY_ENTRY_POINT;
|
|
if (type === PRIMARY_ENTRY_POINT) {
|
|
navigation.navigate(AppLauncherRouteName.APPLICATION_VIEW, {application: section.application, context: context,
|
|
installOnDemand: installOnDemand, sectionName: sectionName, entrypoint: entrypoint});
|
|
} else {
|
|
var id = section.id;
|
|
var FRECENCY = BuiltInSectionId.FRECENCY;
|
|
r13 = id !== FRECENCY ? section : sectionDescriptors.find(function({id}) {
|
|
return id === command.applicationId;
|
|
}) ?? section;
|
|
if (context.type !== 'channel') {
|
|
return undefined;
|
|
}
|
|
var moduleValue3 = importAll(7166) /* metro dependency 7166: ApplicationCommandActionCreators */;
|
|
var setAppLauncherActiveCommand = moduleValue3.setAppLauncherActiveCommand;
|
|
id = context.channel.id;
|
|
Reflect.apply(setAppLauncherActiveCommand, moduleValue3, [id, command]);
|
|
navigate = navigation.navigate;
|
|
var COMMAND_VIEW = AppLauncherRouteName.COMMAND_VIEW;
|
|
Reflect.apply(navigate, navigation, [COMMAND_VIEW, {command: command, section: r13, context: context,
|
|
installOnDemand: installOnDemand, sectionName: sectionName, analyticsLocation: location,
|
|
onCommandExecuted: onCommandExecuted}]);
|
|
}
|
|
}
|
|
|
|
function getInitialOptionValues({option, prefilledValues, guildId, roles}) { // fn#88756, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:2449, offset: 0x01ff09fb, size: 1142 bytes, params: 2, frame: 20
|
|
var items4;
|
|
var items2;
|
|
var items3;
|
|
var object;
|
|
var userStoreBinding;
|
|
var channelStoreBinding;
|
|
var choices;
|
|
const r1 = prefilledValues?.find(_fun88757);
|
|
const type = option.type;
|
|
const ApplicationCommandOptionType = (ServerModule).ApplicationCommandOptionType;
|
|
const BOOLEAN = ApplicationCommandOptionType.BOOLEAN;
|
|
if (BOOLEAN === type) {
|
|
if (r1 != null) {
|
|
object = {type: 'text'};
|
|
object.text = global.String(global.Boolean(r1.value));
|
|
items3 = [object];
|
|
} else {
|
|
items3 = [{'type': 'text', 'text': 'false'}];
|
|
}
|
|
return items3;
|
|
}
|
|
const STRING = ApplicationCommandOptionType.STRING;
|
|
if (STRING === type) {
|
|
if (r1 == null) {
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
choices = option.choices;
|
|
if (choices == null) {
|
|
object = {type: 'text'};
|
|
object.text = global.String(r1.value);
|
|
return [object];
|
|
}
|
|
choices = option.choices;
|
|
if (choices.some(_fun88758)) {
|
|
choices = option.choices;
|
|
return [{type: 'text', text: choices.find(_fun88759).displayName}];
|
|
}
|
|
} else {
|
|
var INTEGER = ApplicationCommandOptionType.INTEGER;
|
|
if (INTEGER === type) {
|
|
if (r1 == null) {
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
choices = option.choices;
|
|
if (choices == null) {
|
|
object = {type: 'text'};
|
|
object.text = global.String(r1.value);
|
|
return [object];
|
|
}
|
|
choices = option.choices;
|
|
if (choices.some(_fun88758)) {
|
|
choices = option.choices;
|
|
return [{type: 'text', text: choices.find(_fun88759).displayName}];
|
|
}
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
var NUMBER = ApplicationCommandOptionType.NUMBER;
|
|
if (NUMBER === type) {
|
|
if (r1 == null) {
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
choices = option.choices;
|
|
if (choices == null) {
|
|
object = {type: 'text'};
|
|
object.text = global.String(r1.value);
|
|
return [object];
|
|
}
|
|
choices = option.choices;
|
|
if (choices.some(_fun88758)) {
|
|
choices = option.choices;
|
|
return [{type: 'text', text: choices.find(_fun88759).displayName}];
|
|
}
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
var CHANNEL = ApplicationCommandOptionType.CHANNEL;
|
|
if (CHANNEL === type) {
|
|
if (r1 == null) {
|
|
items2 = [{'type': 'text', 'text': ''}];
|
|
} else {
|
|
channelStoreBinding = ChannelStore;
|
|
if (channelStoreBinding.getChannel(global.String(r1.value)) != null) {
|
|
object = {type: 'channelMention'};
|
|
object.channelId = global.String(r1.value);
|
|
items2 = [object];
|
|
} else {
|
|
items2 = [{'type': 'text', 'text': ''}];
|
|
}
|
|
}
|
|
return items2;
|
|
}
|
|
var USER = ApplicationCommandOptionType.USER;
|
|
if (USER === type) {
|
|
if (r1 == null) {
|
|
items4 = [{'type': 'text', 'text': ''}];
|
|
} else {
|
|
userStoreBinding = UserStore;
|
|
if (userStoreBinding.getUser(global.String(r1.value)) != null) {
|
|
object = {type: 'userMention'};
|
|
object.userId = global.String(r1.value);
|
|
items4 = [object];
|
|
} else {
|
|
items4 = [{'type': 'text', 'text': ''}];
|
|
}
|
|
}
|
|
return items4;
|
|
}
|
|
var ROLE = ApplicationCommandOptionType.ROLE;
|
|
if (ROLE === type) {
|
|
return r1 == null || typeof r1.value !== 'string' ? [{'type': 'text',
|
|
'text': ''}] : r1.value in roles ? [{type: 'roleMention', roleId: r1.value}] : [{'type': 'text',
|
|
'text': ''}];
|
|
}
|
|
var MENTIONABLE = ApplicationCommandOptionType.MENTIONABLE;
|
|
if (MENTIONABLE === type) {
|
|
if (r1 == null) {
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
if (r1.value === guildId) {
|
|
return [{'type': 'textMention', 'text': '@everyone'}];
|
|
}
|
|
if (typeof r1.value !== 'string') {
|
|
userStoreBinding = UserStore;
|
|
if (userStoreBinding.getUser(global.String(r1.value)) != null) {
|
|
object = {type: 'userMention'};
|
|
object.userId = global.String(r1.value);
|
|
return [object];
|
|
}
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
if (r1.value in roles) {
|
|
return [{type: 'roleMention', roleId: r1.value}];
|
|
}
|
|
userStoreBinding = UserStore;
|
|
if (userStoreBinding.getUser(global.String(r1.value)) != null) {
|
|
object = {type: 'userMention'};
|
|
object.userId = global.String(r1.value);
|
|
return [object];
|
|
}
|
|
return [{'type': 'text', 'text': ''}];
|
|
}
|
|
}
|
|
return [{'type': 'text', 'text': ''}];
|
|
function _fun88757(a0) { // fn#88757, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:2529, offset: 0x01ff0e71, size: 47 bytes, params: 2, frame: 4
|
|
return a0.name === option.name && a0.type === option.type;
|
|
}
|
|
|
|
function _fun88758({value}) { // fn#88758, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:2967, offset: 0x01ff0ea0, size: 26 bytes, params: 2, frame: 2
|
|
return value === env0_1.value;
|
|
}
|
|
|
|
function _fun88759({value}) { // fn#88759, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:3031, offset: 0x01ff0ea0, size: 26 bytes, params: 2, frame: 2
|
|
return value === env0_1.value;
|
|
}
|
|
|
|
}
|
|
|
|
function getAppLauncherIconSource(a0) { // fn#88760, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:4008, offset: 0x01ff0eba, size: 166 bytes, params: 2, frame: 15
|
|
var r0;
|
|
var isRealApplication2;
|
|
var defaultImport;
|
|
if (a0 == null) {
|
|
r0 = importDefault(1860) /* metro dependency 1860 */;
|
|
} else {
|
|
isRealApplication2 = (require(8046) /* metro dependency 8046: AppLauncherUtils */).isRealApplication(a0);
|
|
defaultImport = importDefault(1423) /* metro dependency 1423: AvatarUtils */;
|
|
r0 = isRealApplication2 ? defaultImport.getApplicationIconSource({id: a0.id, icon: a0.icon, bot: a0.bot,
|
|
botIconFirst: false}) : defaultImport.makeSource(APP_LAUNCHER_BUILT_IN_SECTION_ICON);
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function useLogAppLauncherEmptyStateView(a0, a1) { // fn#88761, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:4198, offset: 0x01ff0f60, size: 97 bytes, params: 3, frame: 16
|
|
const env0_0 = a0;
|
|
const useAppLauncherContext = AppLauncherContextModule.useAppLauncherContext;
|
|
ReactModule.useEffect(_fun88762, [a0, a1, Reflect.apply(useAppLauncherContext, AppLauncherContextModule, []).entrypoint]);
|
|
function _fun88762() { // fn#88762, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:4307, offset: 0x01ff0fc1, size: 82 bytes, params: 1, frame: 15
|
|
var value2;
|
|
var moduleValue;
|
|
if (env0_0 != null) {
|
|
value2 = environment.__proto__;
|
|
moduleValue = require(4863) /* metro dependency 4863: AppAnalyticsUtils */;
|
|
moduleValue.trackWithMetadata(AnalyticEvents.APP_LAUNCHER_EMPTY_STATE_ENCOUNTERED, {type: env0_0,
|
|
source: entrypoint});
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function useHandleActivityItemSelected({applicationId, context, sectionName, onActivityItemSelected, location, entrypoint, launchingComponentId, fetchesApplication}) { // fn#88763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:4449, offset: 0x01ff1013, size: 392 bytes, params: 2, frame: 26
|
|
fetchesApplication = fetchesApplication === undefined || fetchesApplication;
|
|
const value4 = (AnalyticsModule).useAnalyticsContext();
|
|
const env0_4 = (UseActivityShelfItemModule).useActivityAction({context: context,
|
|
applicationId: applicationId, fetchesApplication: fetchesApplication});
|
|
const value5 = (UseGetOrFetchApplicationsModule).useGetOrFetchApplication(applicationId,
|
|
fetchesApplication);
|
|
const useAppLauncherContext = AppLauncherContextModule.useAppLauncherContext;
|
|
const entrypointParams = Reflect.apply(useAppLauncherContext, AppLauncherContextModule, []).entrypointParams;
|
|
const useOnActivityItemSelected = UseActivityShelfItemModule.useOnActivityItemSelected;
|
|
object = {application: value5, context: context};
|
|
object.embeddedActivitiesManager = importDefault(8092) /* metro dependency 8092: EmbeddedActivitiesNativeManager */;
|
|
object.locationObject = value4.location;
|
|
object.onActivityItemSelectedProp = onActivityItemSelectedProp;
|
|
object.launchingComponentId = launchingComponentId;
|
|
const CommandOrigin = (ApplicationCommandTypesModule).CommandOrigin;
|
|
const APPLICATION_LAUNCHER = CommandOrigin.APPLICATION_LAUNCHER;
|
|
object.commandOrigin = APPLICATION_LAUNCHER;
|
|
object.sectionName = sectionName;
|
|
object.source = entrypoint;
|
|
object.fetchesApplication = fetchesApplication;
|
|
object.customId = entrypointParams?.customId;
|
|
object.referrerId = entrypointParams?.referrerId;
|
|
const env0_5 = Reflect.apply(useOnActivityItemSelected, UseActivityShelfItemModule, [object]);
|
|
return {handleActivityItemSelected: handleActivityItemSelected};
|
|
function onActivityItemSelectedProp({applicationId}) { // fn#88764, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:4986, owner: useHandleActivityItemSelected.onActivityItemSelectedProp, offset: 0x01ff119b, size: 127 bytes, params: 2, frame: 17
|
|
if (onActivityItemSelected != null) {
|
|
onActivityItemSelected({applicationId: applicationId});
|
|
}
|
|
const trackWithMetadata = AppAnalyticsUtilsModule.trackWithMetadata;
|
|
const APP_LAUNCHER_ACTIVITY_ITEM_SELECTED = AnalyticEvents.APP_LAUNCHER_ACTIVITY_ITEM_SELECTED;
|
|
Reflect.apply(trackWithMetadata, AppAnalyticsUtilsModule, [APP_LAUNCHER_ACTIVITY_ITEM_SELECTED, {location: location,
|
|
application_id: applicationId, section_name: sectionName, action: env0_4, source: entrypoint}]);
|
|
}
|
|
|
|
function handleActivityItemSelected() { // fn#88765, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11778:5401, owner: useHandleActivityItemSelected.handleActivityItemSelected, offset: 0x01ff121a, size: 70 bytes, params: 1, frame: 14
|
|
let value = environment.__proto__;
|
|
value = require(4081) /* metro dependency 4081: HapticUtilsNative */;
|
|
const triggerHapticFeedback = value.triggerHapticFeedback;
|
|
const HapticFeedbackTypes = (require(4081) /* metro dependency 4081: HapticUtilsNative */).HapticFeedbackTypes;
|
|
const IMPACT_MEDIUM = HapticFeedbackTypes.IMPACT_MEDIUM;
|
|
Reflect.apply(triggerHapticFeedback, value, [IMPACT_MEDIUM]);
|
|
env0_5();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun88751, 11592, [31, 1379, 1878, 1483, 661, 5066, 4863, 5068, 11593, 5065, 1909, 7166, 1860, 8046,
|
|
1423, 8774, 8620, 11598, 6777, 8092, 4081,
|
|
2]) /* metro module 11592, dependencies: [31, 1379, 1878, 1483, 661, 5066, 4863, 5068, 11593, 5065, 1909, 7166, 1860, 8046, 1423, 8774, 8620, 11598, 6777, 8092, 4081, 2] */;
|