decord/beta/source/modules/native_intents/NativeIntentsManager.tsx

474 lines
18 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 16:32:48 +00:00
// Module ID: 18679
// Function ID: 18680
// Name: NativeIntentsManager
2026-10-12 16:32:48 +00:00
// Dependencies: [32, 2065, 2087, 4750, 4760, 2116, 1390, 1085, 18680, 18681, 5421, 13155, 1415, 1388, 4962, 6808, 2]
2026-10-12 16:32:48 +00:00
// Module 18679 (NativeIntentsManager)
import AvatarUtilsDefault from "AvatarUtils" /* 1415 */;
import UserUtilsDefault from "UserUtils" /* 4962 */;
import useChannelName from "useChannelName" /* 5421 */;
import getChannelIcon from "getChannelIcon" /* 13155 */;
import NativeIntentsExperimentDefault from "NativeIntentsExperiment" /* 18680 */;
import IntentsBindingsDefault from "IntentsBindings" /* 18681 */;
2026-10-01 14:13:23 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
2026-10-12 16:32:48 +00:00
import ChannelStore from "ChannelStore" /* 2065 */;
import GuildStore from "GuildStore" /* 2087 */;
import PermissionStore from "PermissionStore" /* 4750 */;
import RelationshipStore from "RelationshipStore" /* 4760 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2116 */;
import UserStore from "UserStore" /* 1390 */;
2026-10-07 22:43:51 +00:00
import Constants from "Constants" /* 1085 */;
2026-10-12 16:32:48 +00:00
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6808 */;
2026-10-01 14:13:23 +00:00
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
let id;
let c10;
let closure_12;
let closure_14;
let map1;
let unpackModuleId;
function indexingEnabled() {
2026-10-01 14:13:23 +00:00
let obj2;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
return getCurrentConfig({ location: "NativeIntentsManager" }, obj).searchEnabled;
}
function makeSearchItem(channel, guild, flag) {
2026-10-01 14:13:23 +00:00
let OTHER_CHANNEL;
let sum1;
if (flag === undefined) {
flag = false;
}
2026-10-01 14:13:23 +00:00
const obj = useChannelName;
const channelName = obj.computeChannelName(channel, UserStore, RelationshipStore, true);
const obj2 = useChannelName;
const channelName1 = obj2.computeChannelName(channel, UserStore, RelationshipStore, false);
const items = [channelName, channelName1];
if (channel.isGuildVocal()) {
const _HermesInternal = HermesInternal;
items.push("!" + channelName1);
}
const items1 = [];
const items2 = [];
channel = ChannelStore.getChannel(channel.parent_id);
if (null != channel) {
2026-10-01 14:13:23 +00:00
const tmpResult = useChannelName;
const channelName2 = tmpResult.computeChannelName(channel, tmp3, tmp4, true);
2026-10-01 14:13:23 +00:00
const tmpResult3 = useChannelName;
const channelName3 = tmpResult3.computeChannelName(channel, tmp3, tmp4, false);
items2.push(channelName2);
items2.push(channelName3);
items1.push(channelName2);
}
if (null != guild) {
items2.push(guild.name);
items1.push(guild.name);
}
let str2 = "";
if (items1.length > 0) {
const _HermesInternal2 = HermesInternal;
str2 = " (" + items1.join(", ") + ")";
}
const sum = channelName + str2;
id = undefined;
2026-10-12 16:32:48 +00:00
const CHANNEL = syncedClientThemes.CHANNEL;
if (guild != null) {
id = guild.id;
}
if (id == null) {
2026-10-01 14:13:23 +00:00
id = c10;
}
2026-10-01 14:13:23 +00:00
const CHANNELResult = CHANNEL(id, channel.id);
const obj3 = { id: CHANNELResult, relatedUniqueIdentifier: CHANNELResult, type: "url", title: sum, displayName: sum, thumbnailURL: sum1, rankingHint: OTHER_CHANNEL, keywords: items2, alternateNames: items, isUpdate: flag };
const tmpResult4 = getChannelIcon;
const channelIconURL = tmpResult4.getChannelIconURL(channel, 128, false);
let startsWithResult;
if (channelIconURL != null) {
const startsWith = channelIconURL.startsWith;
if (startsWith != null) {
startsWithResult = startsWith("/");
}
}
if (startsWithResult) {
const _location = location;
2026-10-01 14:13:23 +00:00
sum1 = location.origin + channelIconURL;
} else {
sum1 = channelIconURL;
}
2026-10-01 14:13:23 +00:00
if (channel.type === unpackModuleId.DM) {
OTHER_CHANNEL = constants4.DM;
} else {
OTHER_CHANNEL = constants4.OTHER_CHANNEL;
}
return obj3;
}
function getGuildThumbnail(guild1) {
2026-10-01 14:13:23 +00:00
let tmp;
if (null != guild1) {
2026-10-01 14:13:23 +00:00
let sum;
const obj3 = { id: null, icon: null, size: 128 };
({ id: obj2.id, icon: obj2.icon } = guild1);
2026-10-01 14:13:23 +00:00
const obj = AvatarUtilsDefault;
const guildIconURL = obj.getGuildIconURL(obj3);
let startsWithResult;
if (guildIconURL != null) {
const startsWith = guildIconURL.startsWith;
if (startsWith != null) {
startsWithResult = startsWith("/");
}
}
if (startsWithResult) {
const _location = location;
2026-10-01 14:13:23 +00:00
sum = location.origin + guildIconURL;
} else {
sum = guildIconURL;
}
2026-10-01 14:13:23 +00:00
tmp = sum;
}
2026-10-01 14:13:23 +00:00
return tmp;
}
function makeGuildDomain(guild1, flag) {
2026-10-01 14:13:23 +00:00
let items;
if (flag === undefined) {
flag = false;
}
2026-10-01 14:13:23 +00:00
const tmp = getGuildThumbnail(guild1);
2026-10-12 16:32:48 +00:00
const CHANNELResult = syncedClientThemes.CHANNEL(guild1.id);
2026-10-01 14:13:23 +00:00
const obj = { id: CHANNELResult, relatedUniqueIdentifier: CHANNELResult, type: "url", title: guild1.name, displayName: guild1.name, alternateNames: items, rankingHint: constants4.GUILD };
items = ["*" + guild1.name];
const items1 = [obj];
const mutableGuildChannelsForGuild = ChannelStore.getMutableGuildChannelsForGuild(guild1.id);
for (const key10030 in mutableGuildChannelsForGuild) {
let tmp14 = mutableGuildChannelsForGuild[key10030];
2026-10-01 14:13:23 +00:00
if (!PermissionStore.can(map1.VIEW_CHANNEL, tmp14)) {
continue;
} else {
2026-10-01 14:13:23 +00:00
let arr = items1.push(makeSearchItem(tmp14, guild1, flag));
continue;
}
continue;
}
const allThreadsForGuild = ChannelStore.getAllThreadsForGuild(guild1.id);
for (const item10042 of allThreadsForGuild) {
let tmp7 = item10042;
2026-10-01 14:13:23 +00:00
if (PermissionStore.can(map1.VIEW_CHANNEL, item10042)) {
let arr2 = items1.push(makeSearchItem(tmp7, guild1, flag));
}
continue;
}
2026-10-01 14:13:23 +00:00
return { id: guild1.id, items: items1, defaultThumbnailURL: tmp, isUpdate: flag };
}
function setChannelActivity(channelId) {
2026-10-01 14:13:23 +00:00
let obj2;
const obj = { autoTrackExposure: true, disable: !obj2.hasUserActivity() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).activityEnabled) {
let channel;
if (null != channelId) {
channel = ChannelStore.getChannel(channelId);
}
if (null != channel) {
const guild = GuildStore.getGuild(channel.guild_id);
2026-10-01 14:13:23 +00:00
const obj4 = useChannelName;
const channelName = obj4.computeChannelName(channel, UserStore, RelationshipStore, true);
let str2 = "";
2026-10-01 14:13:23 +00:00
const obj5 = RelationshipStore;
const tmp11 = require;
const tmp12 = UserStore;
if (null != guild) {
const _HermesInternal = HermesInternal;
str2 = " (" + guild.name + ")";
}
const sum = channelName + str2;
const items = [channelName];
const items1 = [];
2026-10-01 14:13:23 +00:00
const _Set = Set;
if ("" !== channel.name) {
items1.push(channel.name);
}
if (null != channel.nicks) {
const push = items1.push;
const _Object = Object;
const items2 = [];
2026-10-01 14:13:23 +00:00
HermesBuiltin.arraySpread(items2, Object.values(channel.nicks), 0);
HermesBuiltin.apply(push, items2, items1);
}
2026-10-01 14:13:23 +00:00
if (channel.type === unpackModuleId.DM) {
const recipients = channel.recipients;
2026-10-01 14:13:23 +00:00
const mapped = recipients.map(tmp12.getUser);
2026-10-12 16:32:48 +00:00
const first = _slicedToArray(mapped.filter(tmp11(1388).isNotNullish), 1)[0];
if (null != first) {
2026-10-01 14:13:23 +00:00
const tmpResult = UserUtilsDefault;
const globalName = tmpResult.getGlobalName(first);
if (null != globalName) {
items1.push(globalName);
}
items1.push(first.username);
2026-10-01 14:13:23 +00:00
items1.push(`@${tmp49.username}`);
const nickname = obj5.getNickname(first.id);
if (null != nickname) {
items1.push(nickname);
}
2026-10-01 14:13:23 +00:00
const tmpResult4 = UserUtilsDefault;
const name = tmpResult4.getName(first);
if (null != name) {
items1.push(name);
}
}
}
2026-10-01 14:13:23 +00:00
HermesBuiltin.arraySpread(items, items1, 1);
const self = this;
const self2 = this;
const _Set1 = new _Set(items);
const items3 = [];
2026-10-01 14:13:23 +00:00
HermesBuiltin.arraySpread(items3, _Set1, 0);
2026-10-12 16:32:48 +00:00
const CHANNELResult = syncedClientThemes.CHANNEL(channel.guild_id, channel.id);
const _HermesInternal2 = HermesInternal;
2026-10-01 14:13:23 +00:00
const obj3 = { webpageURL: "" + constants2.BASE_URL + CHANNELResult, relatedUniqueIdentifier: CHANNELResult, eligibleForHandoff: true, eligibleForSearch: true, title: sum, keywords: items3, displayName: sum, type: "com.discord.view-channel" };
const tmpResult5 = IntentsBindingsDefault;
tmpResult5.setActivity(obj3);
} else {
2026-10-01 14:13:23 +00:00
const tmpResult6 = IntentsBindingsDefault;
tmpResult6.resignActivity();
}
}
}
function indexChannelUpdates(items) {
if (indexingEnabled()) {
items = [];
const items1 = [];
const obj = {};
const iter = items[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp7 = nextResult;
2026-10-01 14:13:23 +00:00
if (PermissionStore.can(map1.VIEW_CHANNEL, nextResult)) {
let guild = GuildStore.getGuild(tmp7.guild_id);
let tmp15 = guild;
id = undefined;
if (guild != null) {
id = guild.id;
}
if (id == null) {
2026-10-01 14:13:23 +00:00
id = c10;
}
let tmp17 = id;
let tmp21 = makeSearchItem(tmp7, tmp15, true);
let tmp22 = obj[id];
let arr3 = tmp22;
if (null != tmp22) {
let arr = arr3.push(tmp21);
} else {
let items2 = [tmp21];
2026-10-01 14:13:23 +00:00
let obj2 = { id: tmp17, items: items2, defaultThumbnailURL: getGuildThumbnail(tmp15) };
let arr2 = items.push(obj2);
obj[tmp17] = items2;
}
} else {
let arr4 = items1.push(tmp7.id);
}
continue;
}
if (items.length > 0) {
2026-10-01 14:13:23 +00:00
const obj3 = IntentsBindingsDefault;
obj3.indexDomains(items);
}
if (items1.length > 0) {
2026-10-01 14:13:23 +00:00
const obj4 = IntentsBindingsDefault;
obj4.deleteSearchItems(items1);
}
}
}
2026-10-01 14:13:23 +00:00
({ ME: c10, ChannelTypes: unpackModuleId, Links: closure_12, Permissions: map1, Routes: closure_14 } = Constants);
const constants4 = { GUILD: 100, [100]: "GUILD", DM: 75, [75]: "DM", OTHER_CHANNEL: 50, [50]: "OTHER_CHANNEL" };
2026-10-01 14:13:23 +00:00
class NativeIntentsManager extends AutomaticLifecycleManager {
constructor() {
2026-10-01 14:13:23 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
applyArgumentsResult.actions = { POST_CONNECTION_OPEN: applyArgumentsResult.handleInit, LOGOUT: applyArgumentsResult.handleLogout, CHANNEL_SELECT: applyArgumentsResult.handleChannelSelect, CHANNEL_CREATE: applyArgumentsResult.handleChannelCreate, CHANNEL_DELETE: applyArgumentsResult.handleChannelDelete, CHANNEL_UPDATES: applyArgumentsResult.handleChannelUpdates, GUILD_CREATE: applyArgumentsResult.handleGuildCreateOrUpdate, GUILD_UPDATE: applyArgumentsResult.handleGuildCreateOrUpdate, GUILD_DELETE: applyArgumentsResult.handleGuildDelete, RELATIONSHIP_ADD: applyArgumentsResult.handleRelationshipChange, RELATIONSHIP_REMOVE: applyArgumentsResult.handleRelationshipChange, RELATIONSHIP_UPDATE: applyArgumentsResult.handleRelationshipChange, THREAD_CREATE: applyArgumentsResult.handleChannelCreate, THREAD_DELETE: applyArgumentsResult.handleChannelDelete, THREAD_UPDATE: applyArgumentsResult.handleThreadUpdate, USER_UPDATE: applyArgumentsResult.handleUserUpdate };
return applyArgumentsResult;
}
2026-10-01 14:13:23 +00:00
handleInit() {
let obj2;
let tmp2Result6;
let tmp2Result8;
setChannelActivity(SelectedChannelStore.getCurrentlySelectedChannelId());
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).clearEnabled) {
const tmp2Result = IntentsBindingsDefault;
tmp2Result.clearSearchIndex();
}
const obj3 = { autoTrackExposure: true, disable: !tmp2Result6.hasSearch() };
const getCurrentConfig2 = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
tmp2Result6 = IntentsBindingsDefault;
if (getCurrentConfig2({ location: "NativeIntentsManager" }, obj3).searchEnabled) {
const obj4 = { autoTrackExposure: true, disable: !tmp2Result8.hasSearch() };
const getCurrentConfig3 = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
tmp2Result8 = IntentsBindingsDefault;
if (getCurrentConfig3({ location: "NativeIntentsManager" }, obj4).searchEnabled) {
const guildsArray = GuildStore.getGuildsArray();
const mapped = guildsArray.map((item) => makeGuildDomain(item));
const items = [];
const mutablePrivateChannels = ChannelStore.getMutablePrivateChannels();
for (const key10061 in mutablePrivateChannels) {
let arr = items.push(makeSearchItem(mutablePrivateChannels[key10061]));
continue;
}
const obj5 = { id, items };
mapped.push(obj5);
const obj9 = IntentsBindingsDefault;
obj9.indexDomains(mapped);
}
}
}
2026-10-01 14:13:23 +00:00
handleLogout() {
let obj2;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).clearEnabled) {
const tmpResult = IntentsBindingsDefault;
tmpResult.clearSearchIndex();
}
}
2026-10-01 14:13:23 +00:00
handleChannelSelect(channelId) {
setChannelActivity(channelId.channelId);
}
handleChannelCreate(channel) {
let items;
let obj2;
channel = channel.channel;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).searchEnabled) {
if (PermissionStore.can(map1.VIEW_CHANNEL, channel)) {
const guild = GuildStore.getGuild(channel.guild_id);
if (null != guild) {
let tmp9;
if (null != guild) {
let sum;
const obj3 = { id: null, icon: null, size: 128 };
({ id: obj4.id, icon: obj4.icon } = guild);
const tmpResult = AvatarUtilsDefault;
const guildIconURL = tmpResult.getGuildIconURL(obj3);
let startsWithResult;
if (guildIconURL != null) {
const startsWith = guildIconURL.startsWith;
if (startsWith != null) {
startsWithResult = startsWith("/");
}
}
if (startsWithResult) {
const _location = location;
sum = location.origin + guildIconURL;
} else {
sum = guildIconURL;
}
tmp9 = sum;
}
id = undefined;
2026-10-01 14:13:23 +00:00
const indexDomains = IntentsBindingsDefault.indexDomains;
IntentsBindingsDefault;
if (guild != null) {
id = guild.id;
}
if (id == null) {
2026-10-01 14:13:23 +00:00
id = c10;
}
2026-10-01 14:13:23 +00:00
const obj5 = { id, items, defaultThumbnailURL: tmp9 };
items = [makeSearchItem(channel, guild)];
const items1 = [obj5];
indexDomains(items1);
}
}
}
}
2026-10-01 14:13:23 +00:00
handleChannelDelete(channel) {
let obj2;
channel = channel.channel;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).searchEnabled) {
const items = [channel.id];
const tmpResult = IntentsBindingsDefault;
tmpResult.deleteSearchItems(items);
}
}
2026-10-01 14:13:23 +00:00
handleChannelUpdates(channels) {
indexChannelUpdates(channels.channels);
}
handleGuildCreateOrUpdate(guild) {
let obj2;
guild = guild.guild;
const type = guild.type;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).searchEnabled) {
const guild1 = GuildStore.getGuild(guild.id);
if (null != guild1) {
const indexDomains = IntentsBindingsDefault.indexDomains;
const items = [];
IntentsBindingsDefault;
items[0] = makeGuildDomain(guild1, "GUILD_UPDATE" === type);
indexDomains(items);
} else {
const items1 = [guild.id];
const tmpResult2 = IntentsBindingsDefault;
tmpResult2.deleteSearchDomains(items1);
}
}
}
2026-10-01 14:13:23 +00:00
handleGuildDelete(guild) {
let obj2;
guild = guild.guild;
const obj = { autoTrackExposure: true, disable: !obj2.hasSearch() };
const getCurrentConfig = NativeIntentsExperimentDefault.getCurrentConfig;
NativeIntentsExperimentDefault;
obj2 = IntentsBindingsDefault;
if (getCurrentConfig({ location: "NativeIntentsManager" }, obj).searchEnabled) {
const items = [guild.id];
const tmpResult = IntentsBindingsDefault;
tmpResult.deleteSearchDomains(items);
}
}
2026-10-01 14:13:23 +00:00
handleThreadUpdate(channel) {
const items = [channel.channel];
indexChannelUpdates(items);
}
2026-10-01 14:13:23 +00:00
handleUserUpdate(user) {
const dMChannelFromUserId = ChannelStore.getDMChannelFromUserId(user.user.id);
if (null != dMChannelFromUserId) {
const items = [dMChannelFromUserId];
indexChannelUpdates(items);
}
}
2026-10-01 14:13:23 +00:00
handleRelationshipChange(relationship) {
const dMChannelFromUserId = ChannelStore.getDMChannelFromUserId(relationship.relationship.id);
if (null != dMChannelFromUserId) {
const items = [dMChannelFromUserId];
indexChannelUpdates(items);
}
}
}
const prototype = NativeIntentsManager.prototype;
const nativeIntentsManager = new NativeIntentsManager();
const result = size.fileFinishedImporting("modules/native_intents/NativeIntentsManager.tsx");
export default nativeIntentsManager;