This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,25 @@
// Metro module 6162 (f6163).
import ApexExperiment from "../experiments/apex/ApexExperiment";
const r18 = ApexExperiment({
kind: "user",
name: "2026-06-game-profile-in-quickswitcher",
defaultConfig: {
enabled: false,
alternatePosition: false
},
variations: {
0: {
enabled: false,
alternatePosition: false
},
1: {
enabled: true,
alternatePosition: false
},
2: {
enabled: true,
alternatePosition: true
}
}
});
export { r18 as GameProfileInQuickswitcherExperiment };
@@ -0,0 +1,343 @@
// Metro module 9907 (f9908).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { InAppNavigationType } from "../autocompleter/record/InAppNavigationRecord";
import { ChannelRecordBase } from "../../records/ChannelRecord";
import ChannelStore from "../../stores/ChannelStore";
import LibraryApplicationStore from "../../stores/LibraryApplicationStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import QuickSwitcherStore from "./QuickSwitcherStore";
import { AnalyticEvents, AnalyticsLocations, AnalyticsPages, AppContext, ME, Layers } from "../../Constants";
import { isStaticChannelRoute } from "../channel/ChannelConstants";
import { CollectibleShopTab } from "../collectibles/CollectiblesShopConstants";
import { findNextSelectedResult, FindResultDirections, AutocompleterResultTypes, AutocompleterQuerySymbols } from "../autocompleter/index";
import { GameProfileInQuickswitcherExperiment } from "./GameProfileInQuickswitcherExperiment";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import ValidationUtils from "../../utils/ValidationUtils";
import Dispatcher from "../../Dispatcher";
import { transitionToGuild } from "../routing/transitionToGuild.native";
import { transitionToChannel } from "../routing/transitionToChannel";
import ChannelRTCActionCreators from "../../actions/ChannelRTCActionCreators";
import SelectedChannelActionCreators from "../../actions/SelectedChannelActionCreators";
import ChannelActionCreators from "../../actions/ChannelActionCreators";
import DimensionActionCreators from "../../actions/DimensionActionCreators";
import GameProfileActionCreators_native from "../game_profile/GameProfileActionCreators.native";
import { GameProfileSources } from "../game_profile/GameProfileAnalyticUtils";
import safeTransitionTo_native from "../links/safeTransitionTo.native";
import { getHasPlaygroundAccess } from "../design/PlaygroundAccessExperiment";
import { openCollectiblesShop } from "../collectibles/CollectiblesActionCreators";
import AnalyticsLocation from "../app_analytics/AnalyticsLocation";
import InstantInviteActionCreators from "../../actions/InstantInviteActionCreators";
import { HermesBuiltin } from "../../_hermes/prelude";
let c6576_19, c6576_20, c6576_21, c6576_22, show, _openInviteFromQuickSwitcher;
const trackClose = function trackClose(a0, a1) {
const props = QuickSwitcherStore.getProps();
const results = props.results;
let queryMode = props.queryMode;
const { query, maxQueryLength } = props;
const guildId = SelectedGuildStore.getGuildId();
const channelId = SelectedChannelStore.getChannelId(guildId);
const r9 = results[findNextSelectedResult(FindResultDirections.DOWN, -1, results)];
const isEmail = ValidationUtils.isEmail(query);
const isPhoneNumber = ValidationUtils.isPhoneNumber(query);
const isUserTagLike = ValidationUtils.isUserTagLike(query);
const r21 = channelId != null && isStaticChannelRoute(channelId);
const current_channel_id = r21 ? void 0 : channelId;
const current_channel_static_route = r21 ? channelId : void 0;
if (queryMode == null) {
queryMode = "GENERAL";
}
const r45 = {
current_channel_id,
current_channel_static_route,
current_guild_id: guildId,
query_mode: queryMode,
query_length: query.length,
max_query_length: maxQueryLength,
is_email_like: isEmail,
is_phone_like: isPhoneNumber,
is_username_like: isUserTagLike,
query: isEmail ? null : isPhoneNumber ? null : isUserTagLike ? null : query,
top_result_type: r9 == null ? null : r9.type === AutocompleterResultTypes.IN_APP_NAVIGATION ? r9.type + "_" + r9.record.type : r9.type,
top_result_score: r9 != null ? r9.score : null,
num_results_total: QuickSwitcherStore.getResultTotals(),
num_results_users: QuickSwitcherStore.getResultTotals(AutocompleterResultTypes.USER),
num_results_text_channels: QuickSwitcherStore.getResultTotals(AutocompleterResultTypes.TEXT_CHANNEL),
num_results_voice_channels: QuickSwitcherStore.getResultTotals(AutocompleterResultTypes.VOICE_CHANNEL),
num_results_guilds: QuickSwitcherStore.getResultTotals(AutocompleterResultTypes.GUILD),
num_results_group_dms: QuickSwitcherStore.getResultTotals(AutocompleterResultTypes.GROUP_DM)
};
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
r45.current_channel_type = channel != null ? channel.type : null;
}
L42: {
if (a1 != null) {
const { type, score, record } = a1;
r45.selected_type = a1 == null ? null : a1.type === AutocompleterResultTypes.IN_APP_NAVIGATION ? a1.type + "_" + a1.record.type : a1.type;
r45.selected_score = score;
r45.selected_index = results.indexOf(a1);
if (AutocompleterResultTypes.GUILD === type) {
r45.selected_guild_id = record.id;
} else {
if (AutocompleterResultTypes.TEXT_CHANNEL !== type && AutocompleterResultTypes.VOICE_CHANNEL !== type) {
if (AutocompleterResultTypes.GROUP_DM === type) {
r45.selected_channel_id = record.id;
break L42;
}
if (AutocompleterResultTypes.USER !== type) {
break L42;
}
r45.selected_user_id = record.id;
break L42;
}
if (record instanceof ChannelRecordBase) {
r45.selected_guild_id = record.guild_id != null ? record.guild_id : null;
}
r45.selected_channel_id = record.id;
}
}
}
AnalyticsUtils.track(a0, r45);
};
show = function show(source = "KEYBIND", r11 = "") {
if (!QuickSwitcherStore.isOpen()) {
const guildId = SelectedGuildStore.getGuildId();
const channelId = SelectedChannelStore.getChannelId(guildId);
const r2 = channelId != null;
let current_channel_type = void 0;
if (r2) {
const channel = ChannelStore.getChannel(channelId);
current_channel_type = channel != null ? channel.type : null;
}
AnalyticsUtils.track(AnalyticEvents.QUICKSWITCHER_OPENED, {
source,
current_guild_id: guildId,
current_channel_id: channelId,
current_channel_type
});
}
const enabled = GameProfileInQuickswitcherExperiment.getConfig({
location: "QuickSwitcherActionCreators.getQueryMode"
}).enabled;
const r46 = enabled ? c6576_22 : c6576_21;
let r50 = (enabled ? c6576_20 : c6576_19)[r11.charAt(0)];
if (r50 == null) {
r50 = null;
}
const r52 = {
type: "QUICKSWITCHER_SHOW"
};
const r59 = _slicedToArray([r11.replace(r46, ""), r50], 2);
HermesBuiltin.copyDataProperties(r52, {
query: r59[0],
queryMode: r59[1]
});
Dispatcher.dispatch(r52);
};
_openInviteFromQuickSwitcher = function _openInviteFromQuickSwitcher() {
const r8 = async (c26561_0) => {
let c26561_2;
c26561_2 = void 0;
let c30157_0 = c26561_0;
let c30157_1 = (await InstantInviteActionCreators.resolveInvite(c26561_0, "Quick Switcher")).invite;
if (c30157_1 != null) {
Dispatcher.dispatch({
type: "INVITE_MODAL_OPEN",
invite: c30157_1,
code: c30157_0,
context: AppContext.APP
});
}
};
_openInviteFromQuickSwitcher = r8;
return r8.apply(this, arguments);
};
Layers;
const r63 = Object;
const r65 = {};
r65[AutocompleterQuerySymbols.USER] = AutocompleterResultTypes.USER;
r65[AutocompleterQuerySymbols.TEXT_CHANNEL] = AutocompleterResultTypes.TEXT_CHANNEL;
r65[AutocompleterQuerySymbols.VOICE_CHANNEL] = AutocompleterResultTypes.VOICE_CHANNEL;
r65[AutocompleterQuerySymbols.GUILD] = AutocompleterResultTypes.GUILD;
c6576_19 = r63.freeze(r65);
const r99 = Object;
const r101 = {
...c6576_19
};
r101[AutocompleterQuerySymbols.GAME_PROFILE] = AutocompleterResultTypes.GAME_PROFILE;
c6576_20 = r99.freeze(r101);
c6576_21 = new RegExp(`^${AutocompleterQuerySymbols.USER}|${AutocompleterQuerySymbols.TEXT_CHANNEL}|${AutocompleterQuerySymbols.VOICE_CHANNEL}|\\${AutocompleterQuerySymbols.GUILD}`);
c6576_22 = new RegExp(`^${AutocompleterQuerySymbols.USER}|${AutocompleterQuerySymbols.TEXT_CHANNEL}|${AutocompleterQuerySymbols.VOICE_CHANNEL}|\\${AutocompleterQuerySymbols.GUILD}|\\${AutocompleterQuerySymbols.GAME_PROFILE}`);
export function getQuickSwitcherOptions(a0) {
const enabled = GameProfileInQuickswitcherExperiment.getConfig({
location: "QuickSwitcherActionCreators.getQueryMode"
}).enabled;
const r8 = enabled ? c6576_22 : c6576_21;
let r18 = (enabled ? c6576_20 : c6576_19)[a0.charAt(0)];
if (r18 == null) {
r18 = null;
}
const r25 = _slicedToArray([a0.replace(r8, ""), r18], 2);
return {
query: r25[0],
queryMode: r25[1]
};
}
export function trackOpen(a0) {
if (!QuickSwitcherStore.isOpen()) {
const guildId = SelectedGuildStore.getGuildId();
const channelId = SelectedChannelStore.getChannelId(guildId);
const r1 = channelId != null;
let current_channel_type = void 0;
if (r1) {
const channel = ChannelStore.getChannel(channelId);
current_channel_type = channel != null ? channel.type : null;
}
AnalyticsUtils.track(AnalyticEvents.QUICKSWITCHER_OPENED, {
source: a0,
current_guild_id: guildId,
current_channel_id: channelId,
current_channel_type
});
}
}
export { trackClose };
export { show };
export function hide() {
trackClose(AnalyticEvents.QUICKSWITCHER_CLOSED);
Dispatcher.dispatch({
type: "QUICKSWITCHER_HIDE"
});
}
export function toggle(r4 = "KEYBIND") {
if (QuickSwitcherStore.isOpen()) {
trackClose(AnalyticEvents.QUICKSWITCHER_CLOSED);
Dispatcher.dispatch({
type: "QUICKSWITCHER_HIDE"
});
} else {
show(r4);
}
}
export function search(a0) {
const enabled = GameProfileInQuickswitcherExperiment.getConfig({
location: "QuickSwitcherActionCreators.getQueryMode"
}).enabled;
const r11 = enabled ? c6576_22 : c6576_21;
let r25 = (enabled ? c6576_20 : c6576_19)[a0.charAt(0)];
if (r25 == null) {
r25 = null;
}
const r26 = {
type: "QUICKSWITCHER_SEARCH"
};
const r32 = _slicedToArray([a0.replace(r11, ""), r25], 2);
HermesBuiltin.copyDataProperties(r26, {
query: r32[0],
queryMode: r32[1]
});
Dispatcher.dispatch(r26);
}
export function selectResult(a0) {
Dispatcher.dispatch({
type: "QUICKSWITCHER_SELECT",
selectedIndex: a0
});
}
export function switchToResult(a0, r9 = false) {
Dispatcher.dispatch({
type: "QUICKSWITCHER_HIDE"
});
trackClose(AnalyticEvents.QUICKSWITCHER_RESULT_SELECTED, a0);
const { type, record } = a0;
const analyticsSource = {
page: AnalyticsPages.QUICK_SWITCHER
};
if (AutocompleterResultTypes.GUILD === type) {
transitionToGuild(record.id, {
navigationReplace: true
});
} else if (AutocompleterResultTypes.TEXT_CHANNEL === type) {
const channel2 = ChannelStore.getChannel(record.id);
if (channel2 != null) {
transitionToChannel(channel2.id, {
state: {
analyticsSource
},
navigationReplace: true
});
}
} else if (AutocompleterResultTypes.VOICE_CHANNEL === type) {
const channel = ChannelStore.getChannel(record.id);
if (channel != null) {
if (r9) {
ChannelRTCActionCreators.updateChatOpen(record.id, true);
} else {
SelectedChannelActionCreators.selectVoiceChannel(record.id);
}
transitionToChannel(channel.id, {
state: {
analyticsSource
},
navigationReplace: true
});
}
} else if (AutocompleterResultTypes.USER === type) {
ChannelActionCreators.openPrivateChannel({
recipientIds: [record.id],
location: "Quickswitcher"
});
DimensionActionCreators.channelListScrollTo(ME, ChannelStore.getDMFromUserId(record.id));
} else if (AutocompleterResultTypes.GROUP_DM === type) {
transitionToChannel(record.id, {
navigationReplace: true
});
DimensionActionCreators.channelListScrollTo(ME, record.id);
} else if (AutocompleterResultTypes.APPLICATION === type) {
LibraryApplicationStore.getActiveLibraryApplication(record.id);
record.id;
AnalyticsLocations.QUICK_SWITCHER;
AnalyticsLocations.QUICK_SWITCHER;
Promise.resolve();
} else if (AutocompleterResultTypes.GAME_PROFILE === type) {
GameProfileActionCreators_native.openGameProfileModal({
gameId: record.id,
gameProfileModalChecks: {
shouldOpenGameProfile: true,
gameId: record.id
},
source: GameProfileSources.QuickSwitcher
});
} else if (AutocompleterResultTypes.LINK === type) {
if (record.inviteCode != null) {
(function openInviteFromQuickSwitcher() {
return _openInviteFromQuickSwitcher.apply(this, arguments);
})(record.inviteCode);
} else {
safeTransitionTo_native(record.path, {
navigationReplace: true
});
}
} else if (AutocompleterResultTypes.IN_APP_NAVIGATION === type && a0.record.type !== InAppNavigationType.SETTINGS) {
if (a0.record.type === InAppNavigationType.PLAYGROUND) {
if (!getHasPlaygroundAccess("quickswitcher_action")) {
return void 0;
}
} else if (a0.record.type === InAppNavigationType.SHOP_ORBS_TAB) {
openCollectiblesShop({
tab: CollectibleShopTab.ORBS,
analyticsLocations: [AnalyticsLocation.QUICK_SWITCHER],
analyticsSource: AnalyticsLocation.QUICK_SWITCHER
});
} else {
safeTransitionTo_native(record.path, {
navigationReplace: true
});
}
}
Dispatcher.dispatch({
type: "QUICKSWITCHER_SWITCH_TO",
result: a0
});
}
@@ -0,0 +1,529 @@
// Metro module 6159 (f6160).
import GameAutocompleteStore from "../games/autocomplete/GameAutocompleteStore";
import ActiveJoinedThreadsStore from "../threads/ActiveJoinedThreadsStore";
import ThemeStore from "../user_settings/ThemeStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import ChannelStore from "../../stores/ChannelStore";
import DraftStore, { DraftType } from "../../stores/DraftStore";
import GuildChannelStore, { GUILD_VOCAL_CHANNELS_KEY } from "../../stores/GuildChannelStore";
import GuildMemberStore from "../../stores/GuildMemberStore";
import GuildStore from "../../stores/GuildStore";
import PermissionStore from "../../stores/PermissionStore";
import ReadStateStore from "../../stores/ReadStateStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import UserGuildSettingsStore from "../../stores/UserGuildSettingsStore";
import { CHANNEL_NOTICE_SHOW_DELAY, Permissions } from "../../Constants";
import { GameProfileInQuickswitcherExperiment } from "./GameProfileInQuickswitcherExperiment";
import Module6163, { AutocompleterResultTypes, createHeaderResult, findNextSelectedResult, FindResultDirections } from "../autocompleter/index";
import Module12 from "../../_bundle/Module12";
import createAutocompleterResultForChannelId from "../autocompleter/createAutocompleterResultForChannelId";
import AutocompleteUtils from "../../utils/AutocompleteUtils";
import { intl, t } from "../../intl/index.native";
import { getHasImportantUnread } from "../read_states/ReadStateUtils";
import { isNotNullish } from "../../utils/GlobalUtils";
import { Storage } from "../../_bundle/Module595";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c3901_3, c3901_22, selectedIndex, seenTutorial, c3901_26, queryMode, results, c3901_29, length, c3901_31, channelHistory, c3901_33, generateResultFromId, generateInitialResults, handleUserSearchUpdate, c3901_37;
const getGeneralQueryResultTypes = function getGeneralQueryResultTypes() {
return [AutocompleterResultTypes.USER, AutocompleterResultTypes.GROUP_DM, AutocompleterResultTypes.TEXT_CHANNEL, AutocompleterResultTypes.GUILD, AutocompleterResultTypes.APPLICATION, ...GameProfileInQuickswitcherExperiment.getConfig({
location: "QuickSwitcherStore.handleQuickSwitcherShow"
}).enabled ? [AutocompleterResultTypes.GAME_PROFILE] : [], AutocompleterResultTypes.LINK, AutocompleterResultTypes.IN_APP_NAVIGATION];
};
const handleConnectionOpen = function handleConnectionOpen() {
c3901_26 = GuildStore.getGuildCount() >= 3 || Module12.size(ChannelStore.getMutablePrivateChannels()) >= 20;
c3901_31 = [];
};
generateResultFromId = function generateResultFromId(channelId3) {
let r11;
L4: {
const autocompleterResultForChannelId = createAutocompleterResultForChannelId(channelId3);
const r1 = autocompleterResultForChannelId == null;
r11 = null;
if (!r1) {
if (queryMode != null) {
const type = autocompleterResultForChannelId.type;
r11 = null;
if (queryMode !== type) {
break L4;
}
}
r11 = autocompleterResultForChannelId;
}
}
return r11;
};
generateInitialResults = function generateInitialResults() {
let r18 = SelectedGuildStore.getGuildId();
if (r18 == null) {
r18 = void 0;
}
let r4 = SelectedChannelStore.getChannelId();
if (r4 == null) {
r4 = void 0;
}
let id, c15537_2, c15537_3;
let c15537_0 = r4;
if (AutocompleterResultTypes.USER === queryMode) {
id = AuthenticationStore.getId();
return AutocompleteUtils.getRecentlyTalked(r4, 100).filter((item) => item.record.id !== id);
}
if (AutocompleterResultTypes.APPLICATION === queryMode) {
return AutocompleteUtils.queryApplications({
query: "",
limit: 100,
fuzzy: true
});
}
if (AutocompleterResultTypes.GAME_PROFILE === queryMode) {
return [];
}
if (AutocompleterResultTypes.GUILD === queryMode) {
return AutocompleteUtils.queryGuilds({
query: "",
limit: 100,
fuzzy: true
});
}
if (AutocompleterResultTypes.TEXT_CHANNEL === queryMode) {
return AutocompleteUtils.queryChannels({
query: "",
guildId: SelectedGuildStore.getGuildId(),
limit: 100,
fuzzy: true,
allowEmptyQueries: true
});
}
if (AutocompleterResultTypes.VOICE_CHANNEL === queryMode) {
return AutocompleteUtils.queryChannels({
query: "",
guildId: SelectedGuildStore.getGuildId(),
limit: 100,
fuzzy: true,
filter: () => true,
type: GUILD_VOCAL_CHANNELS_KEY,
allowEmptyQueries: true
});
}
const set = new Set();
c15537_2 = set;
const r11 = [];
const r69 = 1 < channelHistory.length;
let r10 = 1;
if (r69) {
do {
const r13 = generateResultFromId(channelHistory[r10]);
const r73 = r10;
if (r13 != null && (r13.type !== AutocompleterResultTypes.TEXT_CHANNEL && r13.type !== AutocompleterResultTypes.VOICE_CHANNEL || PermissionStore.can(Permissions.VIEW_CHANNEL, r13.record))) {
r11.push(r13);
if (set.size < 3) {
set.add(channelHistory[r73]);
}
}
r10 = r73 + 1;
} while (r10 < channelHistory.length);
}
const r97 = [];
const r101 = (function getDrafts(c25728_0) {
const r5 = [];
let c25728_1 = r5;
DraftStore.getRecentlyEditedDrafts(DraftType.ChannelMessage).forEach(({ channelId: channelId2 }) => {
let record;
if (!c25728_0(channelId2)) {
L5: {
const autocompleterResultForChannelId = createAutocompleterResultForChannelId(channelId2);
const r2 = autocompleterResultForChannelId == null;
record = null;
if (!r2) {
if (queryMode != null) {
const type = autocompleterResultForChannelId.type;
record = null;
if (queryMode !== type) {
break L5;
}
}
record = autocompleterResultForChannelId;
}
}
if (record != null) {
if (!(record.type !== AutocompleterResultTypes.TEXT_CHANNEL && record.type !== AutocompleterResultTypes.VOICE_CHANNEL) && !PermissionStore.can(Permissions.SEND_MESSAGES, record.record)) {
return void 0;
}
c25728_1.push({
record,
channelId: channelId2
});
}
}
});
return r5;
})((a0) => a0 === c15537_0 || c15537_2.has(a0));
if (r101.length > 0) {
r97.push(createHeaderResult(intl.string(t["4B63jZ"])));
for (const item of r101) {
set.add(item.channelId);
r97.push(item.record);
}
}
const r136 = ReadStateStore.getMentionChannelIds().filter((item) => item !== c15537_0 && !c15537_2.has(item));
const r137 = [];
let r139 = r136.length - 1;
while (0 <= r139) {
const channelId3 = r136[r139];
const r141 = r139;
if (channelId3 != null) {
const result2 = generateResultFromId(channelId3);
if (result2 != null) {
r137.push({
channelId: channelId3,
result: result2
});
}
}
r139 = r141 - 1;
}
if (r137.length > 0) {
r97.push(createHeaderResult(intl.string(t["61Df13"])));
for (const item2 of r137) {
const { channelId: channelId2, result } = item2;
set.add(result.record.id);
set.add(channelId2);
r97.push(result);
}
}
let r182 = r97;
if (r18 != null) {
const r198 = GuildChannelStore.getSelectableChannelIds(r18).filter((item) => {
const channel = ChannelStore.getChannel(item);
const r11 = channel == null || item === c15537_0 || c15537_2.has(item) || UserGuildSettingsStore.isChannelMuted(channel.guild_id, item) || channel.parent_id != null && UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.parent_id);
return r11 ? !r11 : getHasImportantUnread(channel);
}).map((item) => {
let r11;
L4: {
const autocompleterResultForChannelId = createAutocompleterResultForChannelId(item);
const r1 = autocompleterResultForChannelId == null;
r11 = null;
if (!r1) {
if (queryMode != null) {
const type = autocompleterResultForChannelId.type;
r11 = null;
if (queryMode !== type) {
break L4;
}
}
r11 = autocompleterResultForChannelId;
}
}
return r11;
}).filter(isNotNullish);
c15537_3 = r198;
Object.values(ActiveJoinedThreadsStore.getActiveJoinedUnreadThreadsForGuild(r18)).forEach((item) => {
let r18;
for (const key in item) {
L6: {
const autocompleterResultForChannelId = createAutocompleterResultForChannelId(key);
const r4 = autocompleterResultForChannelId == null;
r18 = null;
if (!r4) {
if (queryMode != null) {
const type = autocompleterResultForChannelId.type;
r18 = null;
if (queryMode !== type) {
break L6;
}
}
r18 = autocompleterResultForChannelId;
}
}
if (!(r18 == null || c15537_2.has(r18.record.id))) {
c15537_3.push(r18);
}
}
});
const length2 = r198.length;
r182 = r97;
if (length2 > 0) {
r97.push(createHeaderResult(intl.string(t.ieCAhD)));
r182 = r97.concat(r198);
}
}
const r227 = r182.length > 0 ? 3 : 7;
if (r11.length > r227) {
r11.splice(r227);
}
return r11.length > 0 ? [...[createHeaderResult(intl.string(t["80lOZ1"])), ...r11], ...r182] : r182;
};
const handleQuickSwitcherShow = function handleQuickSwitcherShow({ query, queryMode: queryMode2 }) {
const r20 = query.trim();
let r12 = SelectedGuildStore.getGuildId();
if (r12 == null) {
r12 = void 0;
}
const set = new Set([`user:${AuthenticationStore.getId()}`]);
if (r12 != null) {
set.add(`guild:${r12}`);
}
c3901_33 = Date.now();
let r41 = c3901_3;
if (r41 == null) {
r41 = new Module6163(handleUserSearchUpdate, getGeneralQueryResultTypes(), queryMode2 != null ? 100 : 5, {
frecencyBoosters: true,
blacklist: set,
allowSnowflake: true
}, 100);
}
c3901_3 = r41;
c3901_29 = null;
length = r20.length;
queryMode = queryMode2;
c3901_3.search(r20);
};
handleUserSearchUpdate = function handleUserSearchUpdate(r11, a1) {
let r41, r77;
const r10 = a1.trim();
if (r10.trim() === "") {
r11 = generateInitialResults();
}
const r29 = c3901_31;
const length2 = r11.length;
const length3 = r29.length;
let r3 = false;
if (length2 === length3) {
const length4 = r11.length;
let r0 = 0;
const r4 = 0 < length4;
r3 = true;
if (r4) {
do {
const r33 = r11[r0];
const r34 = r29[r0];
const id2 = r33.record.id;
const id3 = r34.record.id;
const r1 = r0;
r3 = false;
if (id2 !== id3) {
break;
}
const type = r33.type;
const type2 = r34.type;
r3 = false;
if (type !== type2) {
break;
}
const r39 = r1 + 1;
r41 = r39 < r11.length;
r0 = r39;
r3 = true;
} while (r41);
}
}
if (!r3) {
c3901_31 = r11;
if (AutocompleterResultTypes.USER === queryMode) {
const guild = GuildStore.getGuild(SelectedGuildStore.getGuildId());
r11.unshift.call(r11, createHeaderResult(guild != null ? intl.formatToPlainString(t.FREzQs, {
name: guild.name
}) : intl.string(t.XFYW1o)));
results = r11;
r77 = r11;
} else if (AutocompleterResultTypes.TEXT_CHANNEL === queryMode) {
r11.unshift(createHeaderResult(intl.string(t.W26k4V)));
results = r11;
r77 = r11;
} else if (AutocompleterResultTypes.VOICE_CHANNEL === queryMode) {
r11.unshift(createHeaderResult(intl.string(t.zUoI5C)));
results = r11;
r77 = r11;
} else if (AutocompleterResultTypes.GUILD === queryMode) {
r11.unshift(createHeaderResult(intl.string(t.olADPs)));
results = r11;
r77 = r11;
} else if (AutocompleterResultTypes.APPLICATION === queryMode) {
r11.unshift(createHeaderResult(intl.string(t.VwK1ld)));
results = r11;
r77 = r11;
} else if (AutocompleterResultTypes.GAME_PROFILE === queryMode) {
r11.unshift(createHeaderResult(intl.string(t.gEp2SG)));
results = r11;
r77 = r11;
} else if (GameProfileInQuickswitcherExperiment.getConfig({
location: "QuickSwitcherStore.updateResults"
}).enabled) {
const r84 = r11.filter((item) => item.type === AutocompleterResultTypes.GAME_PROFILE).slice(0, 3);
results = [...r11.filter((item) => item.type !== AutocompleterResultTypes.GAME_PROFILE), ...r84];
r77 = results;
} else {
results = r11;
r77 = r11;
}
if (r10 !== c3901_29) {
c3901_29 = r10;
length = Math.max(r10.length, length);
selectedIndex = findNextSelectedResult(FindResultDirections.DOWN, -1, results);
} else {
const r194 = r77[selectedIndex];
if (r194 != null && r194.type === AutocompleterResultTypes.HEADER) {
selectedIndex = findNextSelectedResult(FindResultDirections.DOWN, selectedIndex, results);
}
}
c3901_37.emitChange();
}
};
const handleQuickSwitcherHide = function handleQuickSwitcherHide() {
c3901_29 = null;
length = 0;
c3901_31 = [];
if (c3901_3 != null) {
c3901_3.destroy();
c3901_3 = null;
}
};
const handleGameAutocompleteSettled = function handleGameAutocompleteSettled() {
if (c3901_3 == null) {
return false;
}
c3901_3.refreshGameProfiles();
};
c3901_22 = "seenQSTutorial";
selectedIndex = 0;
seenTutorial = false;
c3901_26 = false;
queryMode = null;
results = [];
c3901_29 = null;
length = 0;
c3901_31 = [];
channelHistory = [];
c3901_33 = null;
class QuickSwitcherStoreClass extends Module589.PersistedStore {
static displayName = "QuickSwitcherStore";
static persistKey = "QuickSwitcherStore";
initialize(a0) {
this.waitFor(ActiveJoinedThreadsStore, AuthenticationStore, ChannelStore, DraftStore, GameAutocompleteStore, GuildChannelStore, GuildMemberStore, GuildStore, PermissionStore, ReadStateStore, SelectedChannelStore, SelectedGuildStore, ThemeStore, UserGuildSettingsStore);
this.syncWith([ThemeStore], () => true);
seenTutorial = Storage.get(c3901_22) || false;
let r47 = a0?.channelHistory;
if (r47 == null) {
r47 = [];
}
channelHistory = r47;
}
getState() {
return {
channelHistory
};
}
isOpen() {
return c3901_3 != null;
}
getResultTotals(a0) {
return c3901_3 == null ? 0 : a0 == null ? c3901_3.results.reduce((acc, result) => result.type !== AutocompleterResultTypes.HEADER ? acc + 1 : acc, 0) : c3901_3.results.reduce((acc, result) => result.type === a0 ? acc + 1 : acc, 0);
}
channelNoticePredicate(a0, a1) {
const r1 = Date.now() - a1 >= CHANNEL_NOTICE_SHOW_DELAY;
return c3901_26 && r1;
}
getFrequentGuilds() {
return c3901_3 != null ? c3901_3.queryGuilds("", 100) : null;
}
getFrequentGuildsLength() {
return c3901_3 != null ? c3901_3.queryGuilds("", 100).length : 0;
}
getChannelHistory() {
return channelHistory;
}
getLastShowTimestamp() {
return c3901_33;
}
getProps() {
return {
theme: ThemeStore.theme,
query: c3901_3 != null ? c3901_3.query : "",
queryMode,
results,
selectedIndex,
seenTutorial,
maxQueryLength: length
};
}
}
c3901_37 = new QuickSwitcherStoreClass(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
CONNECTION_OPEN_SUPPLEMENTAL: handleConnectionOpen,
QUICKSWITCHER_SHOW: handleQuickSwitcherShow,
SHOW_ACTION_SHEET_QUICK_SWITCHER: handleQuickSwitcherShow,
QUICKSWITCHER_HIDE: handleQuickSwitcherHide,
OVERLAY_SET_INPUT_LOCKED: handleQuickSwitcherHide,
HIDE_ACTION_SHEET_QUICK_SWITCHER: handleQuickSwitcherHide,
QUICKSWITCHER_SEARCH: function handleQuickSwitcherSearch({ query, queryMode: queryMode2 }) {
const r13 = query.trim();
if (c3901_3 == null) {
return false;
}
L15: {
if (queryMode !== queryMode2) {
c3901_3.setResultTypes(queryMode2 != null ? [queryMode2] : getGeneralQueryResultTypes());
c3901_3.setLimit(queryMode2 != null ? 100 : 5);
let guild = SelectedGuildStore.getGuildId();
if (guild == null) {
guild = void 0;
}
if (queryMode2 === AutocompleterResultTypes.USER && guild != null) {
c3901_3.setOptions({
userFilters: {
guild,
friends: true
}
}, true);
break L15;
}
if (queryMode2 === AutocompleterResultTypes.VOICE_CHANNEL) {
c3901_3.setOptions({
voiceChannelGuildFilter: null
}, true);
} else {
c3901_3.setOptions({
userFilters: null,
voiceChannelGuildFilter: void 0
}, true);
}
}
}
queryMode = queryMode2;
if (queryMode2 === AutocompleterResultTypes.USER) {
let r64 = SelectedGuildStore.getGuildId();
if (r64 == null) {
r64 = null;
}
c3901_3.search(r13, r64);
} else {
c3901_3.search(r13, void 0);
}
},
QUICKSWITCHER_SELECT: function handleQuickSwitcherSelect(a0) {
selectedIndex = a0.selectedIndex;
},
QUICKSWITCHER_SWITCH_TO: function handleQuickSwitcherSwitchTo() {
if (seenTutorial) {
return false;
}
seenTutorial = true;
Storage.set(c3901_22, true);
},
CHANNEL_SELECT: function handleChannelSelect({ channelId }) {
if (channelId == null) {
return false;
}
const r9 = channelHistory.filter((item) => item !== channelId);
channelHistory = r9;
r9.unshift(channelId);
if (channelHistory.length > 8) {
channelHistory.length = 8;
}
},
GAME_AUTOCOMPLETE_FETCH_SUCCESS: handleGameAutocompleteSettled,
GAME_AUTOCOMPLETE_FETCH_FAILURE: handleGameAutocompleteSettled
});
export default c3901_37;
export { generateResultFromId };