decord/source/modules/app_launcher/native/AppLauncherNativeUtils.tsx
github-actions 777dc50a28 chore: update source for alpha 346.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4790.js (118.4 MB)
2026-09-10 19:12:31 +00:00

296 lines
13 KiB
TypeScript

// Module ID: 12121
// Function ID: 12122
// Name: AppLauncherNativeUtils
// Dependencies: [19, 1957, 1371, 1482, 1074, 5049, 4785, 7575, 12122, 7573, 1894, 7829, 1884, 9358, 1396, 11287, 9689, 12127, 7220, 9585, 4573, 2]
// Exports: getAppLauncherIconSource, getInitialOptionValues, handleApplicationCommandSelected, handleApplicationSelected, handleViewAllSelected, useHandleActivityItemSelected, useLogAppLauncherEmptyStateView
// Module 12121 (AppLauncherNativeUtils)
import AvatarUtilsDefault from "AvatarUtils" /* 1396 */;
import _modDef1884 from "module_1884" /* 1884 */;
import Server from "Server" /* 1894 */;
import HapticUtils from "HapticUtils" /* 4573 */;
import AppAnalyticsUtils from "AppAnalyticsUtils" /* 4785 */;
import ApplicationCommandUtils from "ApplicationCommandUtils" /* 7573 */;
import ApplicationCommandActionCreatorsAll from "ApplicationCommandActionCreators" /* 7829 */;
import AppLauncherUtils from "AppLauncherUtils" /* 9358 */;
import FrecencySection from "FrecencySection" /* 12122 */;
import noop from "module_19" /* 19 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import UserStore from "UserStore" /* 1371 */;
const require = globalThis.__r;
require = fn;
const AppLauncherNativeConstants = fn(1482);
({ APP_LAUNCHER_BUILT_IN_SECTION_ICON: closure_7, AppLauncherRouteName: closure_8 } = AppLauncherNativeConstants);
const AnalyticEvents = fn(1074).AnalyticEvents;
const BuiltInSectionId = fn(5049).BuiltInSectionId;
const size = fn(2);
let result = size.fileFinishedImporting("modules/app_launcher/native/AppLauncherNativeUtils.tsx");
export const handleApplicationSelected = function handleApplicationSelected(entrypoint) {
({ application, navigation, sectionName, navigates } = entrypoint);
({ location: _location, context, installOnDemand, query, searchResultsPosition } = entrypoint);
if (navigates === undefined) {
navigates = true;
}
entrypoint = entrypoint.entrypoint;
const obj2 = { location: _location, section: null, application_id: null, section_name: null, query: null, search_results_position: null, source: null };
if (application.id === BuiltInSectionId.BUILT_IN) {
let APP = tmp(7575).ApplicationCommandTriggerSections.BUILT_IN;
} else {
APP = tmp(7575).ApplicationCommandTriggerSections.APP;
}
obj2.section = APP;
let id = application.id;
if (id == null) {
id = null;
}
obj2.application_id = id;
obj2.section_name = sectionName;
obj2.query = query;
obj2.search_results_position = searchResultsPosition;
obj2.source = entrypoint;
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.APPLICATION_COMMAND_SECTION_SELECTED, obj2);
if (navigates) {
const obj3 = { application, context, installOnDemand, sectionName, entrypoint };
navigation.navigate(constants.APPLICATION_VIEW, obj3);
}
};
export const handleViewAllSelected = function handleViewAllSelected(arg0) {
({ navigation, sectionName, applications, sectionItemType, commands } = arg0);
({ location: _location, context, sectionOverallPosition, sectionDescriptors, title, promotedApplicationIds } = arg0);
const obj = AppAnalyticsUtils;
obj.trackWithMetadata(AnalyticEvents.APP_LAUNCHER_SECTION_VIEW_MORE, { section_name: sectionName, num: sectionItemType === FrecencySection.SectionItemType.APPS ? applications.length : commands.length });
navigation.navigate(constants.APP_LIST_VIEW, { analyticsLocation: _location, context, sectionName, sectionOverallPosition, applications, sectionItemType, commands, sectionDescriptors, title, promotedApplicationIds });
};
export const handleApplicationCommandSelected = function handleApplicationCommandSelected(arg0) {
({ location: _location, context, command } = arg0);
({ section, sectionDescriptors, query, navigation, installOnDemand, sectionName, entrypoint } = arg0);
({ searchResultsPosition, onCommandExecuted } = arg0);
const obj2 = { command, location: _location, triggerSection: null, queryLength: null, sectionName: null, query: null, searchResultsPosition: null, source: null };
const obj = ApplicationCommandUtils;
obj2.triggerSection = ApplicationCommandUtils.getCommandTriggerSection(section);
obj2.queryLength = query.length;
obj2.sectionName = sectionName;
obj2.query = query;
obj2.searchResultsPosition = searchResultsPosition;
obj2.source = entrypoint;
obj.trackCommandSelected(obj2);
if (command.type === Server.ApplicationCommandType.PRIMARY_ENTRY_POINT) {
const obj5 = { application: section.application, context, installOnDemand, sectionName, entrypoint };
navigation.navigate(constants.APPLICATION_VIEW, obj5);
} else {
let tmp5 = section;
if (section.id === BuiltInSectionId.FRECENCY) {
const found = sectionDescriptors.find((id) => id.id === command.applicationId);
tmp5 = section;
if (null != found) {
tmp5 = found;
}
}
if ("channel" === context.type) {
const result = ApplicationCommandActionCreatorsAll.setAppLauncherActiveCommand(context.channel.id, command);
const obj6 = { command, section: tmp5, context, installOnDemand, sectionName, analyticsLocation: _location, onCommandExecuted };
navigation.navigate(constants.COMMAND_VIEW, obj6);
}
}
};
export const getInitialOptionValues = function getInitialOptionValues(option) {
option = option.option;
({ prefilledValues, roles } = option);
let found;
if (prefilledValues != null) {
found = prefilledValues.find((name) => name.name === option.name && name.type === tmp.type);
}
const type = option.type;
if (Server.ApplicationCommandOptionType.BOOLEAN === type) {
if (null != found) {
const obj2 = { type: "text", text: null };
const _String8 = String;
const _Boolean = Boolean;
obj2.text = String(Boolean(found.value));
const items = [obj2];
let items1 = items;
} else {
items1 = [{ type: "text", text: "false" }];
}
return items1;
} else {
if (tmp2(1894).ApplicationCommandOptionType.STRING !== type) {
if (tmp2(1894).ApplicationCommandOptionType.INTEGER !== type) {
if (tmp2(1894).ApplicationCommandOptionType.NUMBER !== type) {
if (tmp2(1894).ApplicationCommandOptionType.CHANNEL === type) {
if (null != found) {
const _String5 = String;
if (null != ChannelStore.getChannel(String(found.value))) {
const obj3 = { type: "channelMention", channelId: null };
const _String6 = String;
obj3.channelId = String(found.value);
const items2 = [obj3];
let items3 = items2;
}
return items3;
}
items3 = [{ type: "text", text: "" }];
} else if (tmp2(1894).ApplicationCommandOptionType.USER === type) {
if (null != found) {
const _String3 = String;
if (null != UserStore.getUser(String(found.value))) {
const obj4 = { type: "userMention", userId: null };
const _String4 = String;
obj4.userId = String(found.value);
const items4 = [obj4];
let items5 = items4;
}
return items5;
}
items5 = [{ type: "text", text: "" }];
} else if (tmp2(1894).ApplicationCommandOptionType.ROLE === type) {
if (null != found) {
if (typeof found.value === "string") {
if (found.value in roles) {
const obj5 = { type: "roleMention", roleId: found.value };
const items6 = [obj5];
let items7 = items6;
}
return items7;
}
}
items7 = [{ type: "text", text: "" }];
} else if (tmp2(1894).ApplicationCommandOptionType.MENTIONABLE === type) {
if (null != found) {
if (found.value === option.guildId) {
const items8 = [{ type: "textMention", text: "@everyone" }];
return items8;
} else {
if (typeof found.value === "string") {
if (found.value in roles) {
const obj6 = { type: "roleMention", roleId: found.value };
const items9 = [obj6];
return items9;
}
}
const _String = String;
if (null != UserStore.getUser(String(found.value))) {
const obj = { type: "userMention", userId: null };
const _String2 = String;
obj.userId = String(found.value);
const items10 = [obj];
return items10;
}
}
}
const items11 = [{ type: "text", text: "" }];
return items11;
} else {
const items12 = [{ type: "text", text: "" }];
return items12;
}
}
}
}
if (null != found) {
if (null == option.choices) {
const obj7 = { type: "text", text: null };
const _String7 = String;
obj7.text = String(found.value);
const items13 = [obj7];
return items13;
} else {
const choices = option.choices;
if (choices.some((value) => value.value === found.value)) {
const obj8 = { type: "text", text: null };
const choices1 = option.choices;
obj8.text = choices1.find((value) => value.value === found.value).displayName;
const items14 = [obj8];
return items14;
}
}
}
const items15 = [{ type: "text", text: "" }];
return items15;
}
};
export const getAppLauncherIconSource = function getAppLauncherIconSource(application) {
if (null == application) {
let applicationIconSource = _modDef1884;
} else {
const obj2 = AvatarUtilsDefault;
if (isRealApplicationResult) {
({ id: obj3.id, icon: obj3.icon, bot: obj3.bot } = application);
applicationIconSource = obj2.getApplicationIconSource({ id: null, icon: null, bot: null, botIconFirst: false });
const obj4 = { id: null, icon: null, bot: null, botIconFirst: false };
} else {
applicationIconSource = obj2.makeSource(React5);
}
isRealApplicationResult = AppLauncherUtils.isRealApplication(application);
}
return applicationIconSource;
};
export const useLogAppLauncherEmptyStateView = function useLogAppLauncherEmptyStateView(COMMAND_NOT_FOUND, query) {
_require = COMMAND_NOT_FOUND;
const entrypoint = require("AppLauncherContext").useAppLauncherContext().entrypoint;
const items = [COMMAND_NOT_FOUND, query, entrypoint];
const effect = noop.useEffect(() => {
if (null != closure_0) {
const obj2 = { type: tmp, source: entrypoint };
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.APP_LAUNCHER_EMPTY_STATE_ENCOUNTERED, obj2);
}
}, items);
};
export const useHandleActivityItemSelected = function useHandleActivityItemSelected(fetchesApplication) {
({ applicationId, context, sectionName } = fetchesApplication);
({ onActivityItemSelected: importDefault, location: importAll, entrypoint } = fetchesApplication);
let flag = fetchesApplication.fetchesApplication;
if (flag === undefined) {
flag = true;
}
closure_5 = undefined;
const analyticsContext = sectionName(entrypoint[16]).useAnalyticsContext();
let obj = sectionName(entrypoint[16]);
const action = sectionName(entrypoint[17]).useActivityAction({ context, applicationId, fetchesApplication: flag });
const obj2 = sectionName(entrypoint[17]);
const getOrFetchApplication = sectionName(entrypoint[18]).useGetOrFetchApplication(applicationId, flag);
const obj3 = sectionName(entrypoint[18]);
const entrypointParams = sectionName(entrypoint[15]).useAppLauncherContext().entrypointParams;
const obj4 = sectionName(entrypoint[15]);
const obj6 = {
application: getOrFetchApplication,
context,
embeddedActivitiesManager: require("EmbeddedActivitiesNativeManager"),
locationObject: analyticsContext.location,
onActivityItemSelectedProp(applicationId) {
applicationId = applicationId.applicationId;
if (importDefault != null) {
const obj = { applicationId };
tmp(obj);
}
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.APP_LAUNCHER_ACTIVITY_ITEM_SELECTED, { location: _location, application_id: applicationId, section_name: sectionName, action, source: entrypoint });
},
launchingComponentId: fetchesApplication.launchingComponentId,
commandOrigin: sectionName(entrypoint[7]).CommandOrigin.APPLICATION_LAUNCHER,
sectionName,
source: entrypoint,
fetchesApplication: flag,
customId: null,
referrerId: null
};
let customId;
if (entrypointParams != null) {
customId = entrypointParams.customId;
}
obj6.customId = customId;
let referrerId;
if (entrypointParams != null) {
referrerId = entrypointParams.referrerId;
}
obj6.referrerId = referrerId;
closure_5 = sectionName(entrypoint[17]).useOnActivityItemSelected(obj6);
return {
handleActivityItemSelected() {
const result = HapticUtils.triggerHapticFeedback(HapticUtils.HapticFeedbackTypes.IMPACT_MEDIUM);
closure_5();
}
};
};