Files
discord-decomp/sources/modules/interaction_components/SearchableSelectActionComponentUtils.tsx
2026-07-28 01:06:53 +03:00

205 lines
12 KiB
TypeScript

/* Metro module 8362; source: modules/interaction_components/SearchableSelectActionComponentUtils.tsx; dependencies: [1379, 1945, 1938, 1867, 3793, 1878, 8358, 1909, 6526, 4617, 4633, 4805, 8363, 1360, 2] */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import GuildRoleStore from '../../stores/GuildRoleStore.tsx'; /* Metro dependency 1938 */
import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */
import RelationshipStore from '../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */
import NicknameUtils from '../../utils/NicknameUtils.tsx'; /* Metro dependency 4617 */
import LocalInteractionComponentStateStore from './LocalInteractionComponentStateStore.tsx'; /* Metro dependency 8358 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ServerModule from '../../flow/Server.tsx'; /* Metro dependency 1909 */
import * as InteractionComponentTypesModule from './InteractionComponentTypes.tsx'; /* Metro dependency 4633 */
import * as SnowflakeSelectDefaultValueTypesModule from '../../external/discord_common/js/shared/shared-constants/SnowflakeSelectDefaultValueTypes.tsx'; /* Metro dependency 8363 */
function _fun66591(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66591, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:6, offset: 0x01c01b89, size: 269 bytes, params: 8, frame: 20
const env0_0 = require;
const getSnowflakeSelectDefaultValues2 = getSnowflakeSelectDefaultValues;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/interaction_components/SearchableSelectActionComponentUtils.tsx');
exports.MIN_REREQUEST_TIME = 1000;
exports.queryMentionables = queryMentionables;
exports.queryChannels = queryChannels_66597;
exports.getInitialSnowflakeSelectOptions = getInitialSnowflakeSelectOptions;
exports.getSnowflakeSelectDefaultValues = getSnowflakeSelectDefaultValues2;
function getSnowflakeSelectDefaultValues(a0, a1) { // fn#66592, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:166, offset: 0x01c01c96, size: 114 bytes, params: 3, frame: 15
var value2;
const value = a2;
const env0_0 = value !== undefined ? value : [];
var env0_1;
if (a0 != null) {
env0_1 = GuildStore.getGuild(a1);
value2 = a0.map(_fun66593);
return value2.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish);
}
function _fun66593(a0) { // fn#66593, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:263, offset: 0x01c01d08, size: 585 bytes, params: 2, frame: 21
var r2;
var value4;
var channelStoreBinding;
var id;
var value5;
var binding;
var object;
const SelectOptionType = (InteractionComponentTypesModule).SelectOptionType;
var moduleValue;
var userStoreBinding;
var value7;
var guildRoleStoreBinding;
var value8;
var getUser;
var value9;
const type = a0.type;
const value2 = undefined;
const SnowflakeSelectDefaultValueTypes = (SnowflakeSelectDefaultValueTypesModule).SnowflakeSelectDefaultValueTypes;
const USER = SnowflakeSelectDefaultValueTypes.USER;
if (USER === type) {
userStoreBinding = UserStore;
getUser = userStoreBinding.getUser;
id = a0.id;
value9 = Reflect.apply(getUser, userStoreBinding, [id]);
if (value9 == null) {
return null;
}
r2 = env0_1 != null ? GuildMemberStore.getNick(env0_1.id, value9.id) : value2;
id = value9.id;
r2 = r2 ?? value9.globalName;
r2 = r2 ?? value9.username;
return {type: SelectOptionType.USER, value: id, label: r2};
}
const ROLE = SnowflakeSelectDefaultValueTypes.ROLE;
if (ROLE === type) {
value7 = null;
if (value7 == env0_1) {
return value7;
}
guildRoleStoreBinding = GuildRoleStore;
value8 = guildRoleStoreBinding.getRole(env0_1.id, a0.id);
return value7 == value8 ? value7 : {type: SelectOptionType.ROLE, value: value8.id, label: value8.name};
}
const CHANNEL = SnowflakeSelectDefaultValueTypes.CHANNEL;
if (CHANNEL === type) {
value4 = null;
if (value4 == env0_1) {
return value4;
}
channelStoreBinding = ChannelStore;
value5 = channelStoreBinding.getChannel(a0.id);
if (value4 == value5) {
r2 = value4;
} else if (value5.guild_id !== env0_1.id) {
r2 = value4;
} else if (env0_0.length > 0) {
binding = env0_0;
if (binding.includes(value5.type)) {
object = {};
object.type = SelectOptionType.CHANNEL;
object.value = value5.id;
moduleValue = require(4805) /* metro dependency 4805: useChannelName */;
object.label = moduleValue.computeChannelName(value5, UserStore, RelationshipStore);
r2 = object;
} else {
r2 = value4;
}
} else {
object = {};
object.type = SelectOptionType.CHANNEL;
object.value = value5.id;
moduleValue = require(4805) /* metro dependency 4805: useChannelName */;
object.label = moduleValue.computeChannelName(value5, UserStore, RelationshipStore);
r2 = object;
}
return r2;
}
return value2;
}
}
function queryMentionables(a0, a1, a2) { // fn#66594, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:1168, offset: 0x01c01f51, size: 350 bytes, params: 4, frame: 20
const env0_0 = a2;
var value;
const channel = ChannelStore.getChannel(a2);
if (channel == null) {
return [];
}
const ComponentType = (ServerModule).ComponentType;
const USER_SELECT = ComponentType.USER_SELECT;
const r6 = a0 === USER_SELECT || a0 === ComponentType.MENTIONABLE_SELECT;
const ROLE_SELECT = ComponentType.ROLE_SELECT;
value = Reflect.apply((importDefault(6526) /* metro dependency 6526: AutocompleteUtils */).queryMentionResults,
value, [{query: a1, channel: channel, canMentionEveryone: false, canMentionHere: false, canMentionUsers: r6,
canMentionRoles: a0 === ROLE_SELECT || a0 === ComponentType.MENTIONABLE_SELECT, includeAllGuildUsers: true,
includeNonMentionableRoles: true, checkRecentlyTalkedOnEmptyQuery: false, limit: 15}]);
const users = value.users;
const roles = value.roles;
value = users.map(_fun66595);
items2 = [];
value = arraySpread(items2, value, 0, 7);
arraySpread(items2, roles.map(function(a0) {
var object = {};
object.type = require(dependencyMap[10]).SelectOptionType.ROLE;
object.value = a0.id;
object.label = a0.name;
return object;
}), value, 7);
return items2;
function _fun66595(a0) { // fn#66595, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:1682, offset: 0x01c020af, size: 153 bytes, params: 2, frame: 19
const defaultImport = NicknameUtils;
const getNickname = defaultImport.getNickname;
const guildId = env0_1.getGuildId();
let user = a0.user;
const value4 = Reflect.apply(getNickname, defaultImport, [guildId, importDefault, user]);
const SelectOptionType = (InteractionComponentTypesModule).SelectOptionType;
const USER = SelectOptionType.USER;
user = a0.user;
let r1 = value4 ?? a0.user.globalName;
r1 = r1 ?? a0.user.username;
return {type: USER, value: user.id, label: r1};
}
}
function queryChannels_66597(a0, a1, a2) { // fn#66597, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:1961, offset: 0x01c0218a, size: 121 bytes, params: 4, frame: 13
var r0;
var value;
const channel = ChannelStore.getChannel(a1);
if (channel == null) {
r0 = [];
} else {
value = importDefault(6526) /* metro dependency 6526: AutocompleteUtils */;
value = value.queryApplicationCommandChannelResults({query: a0, channel: channel, channelTypes: a2,
limit: 15}).channels.map(function(a0) {
var object = {};
object.type = require(dependencyMap[10]).SelectOptionType.CHANNEL;
object.value = a0.id;
object.label = require(dependencyMap[11]).computeChannelName(a0, UserStore, RelationshipStore);
return object;
});
r0 = value;
}
return r0;
}
function getInitialSnowflakeSelectOptions(a0, a1, a2) { // fn#66599, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8547:2272, offset: 0x01c02261, size: 310 bytes, params: 4, frame: 20
const interactionComponentState = LocalInteractionComponentStateStore.getInteractionComponentState(a1, a0.id);
const getSnowflakeSelectDefaultValuesBinding = getSnowflakeSelectDefaultValues;
const defaultValues = a0.defaultValues;
let type = a0.type;
const value3 = undefined;
const ComponentType = (ServerModule).ComponentType;
const CHANNEL_SELECT = ComponentType.CHANNEL_SELECT;
const snowflakeSelectDefaultValuesBinding = getSnowflakeSelectDefaultValuesBinding(defaultValues, a2,
type !== CHANNEL_SELECT ? value3 : a0.channelTypes);
type = interactionComponentState == null ? value3 : interactionComponentState.type;
const USER_SELECT = ComponentType.USER_SELECT;
let r0 = type === USER_SELECT || (interactionComponentState == null ? value3 : interactionComponentState.type) === ComponentType.ROLE_SELECT || (interactionComponentState == null ? value3 : interactionComponentState.type) === ComponentType.MENTIONABLE_SELECT ? interactionComponentState.selectedOptions : (interactionComponentState == null ? value3 : interactionComponentState.type) !== ComponentType.CHANNEL_SELECT ? snowflakeSelectDefaultValuesBinding : interactionComponentState.selectedOptions;
r0 = r0 ?? [];
return r0;
}
}
global.__d(_fun66591, 8362, [1379, 1945, 1938, 1867, 3793, 1878, 8358, 1909, 6526, 4617, 4633, 4805, 8363, 1360,
2]) /* metro module 8362, dependencies: [1379, 1945, 1938, 1867, 3793, 1878, 8358, 1909, 6526, 4617, 4633, 4805, 8363, 1360, 2] */;