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,125 @@
// Metro module 11462 (f11463).
import { GUILD_SELECTABLE_CHANNELS_KEY, GUILD_VOCAL_CHANNELS_KEY } from "../../../../stores/GuildChannelStore";
import ReadStateStore from "../../../../stores/ReadStateStore";
import { AutocompleterResultTypes } from "../../../autocompleter/AutocompleterConstants";
import AutocompleteUtils, { getBoosterMap } from "../../../../utils/AutocompleteUtils";
import { chain } from "../../../../_bundle/Module12";
import SnowflakeUtils from "../../../../utils/SnowflakeUtils";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
let c7803_10;
let c7803_7 = [];
let c7803_8 = [];
class GuildChannelSearchManager {
constructor() {
const r3 = {
__proto__: new.target.prototype,
count: null,
textChannels: [],
voiceChannels: null
};
r3.voiceChannels = [];
return r3;
}
search(a0, a1) {
const boosterMap2 = getBoosterMap(AutocompleterResultTypes.TEXT_CHANNEL);
const boosterMap = getBoosterMap(AutocompleterResultTypes.VOICE_CHANNEL);
const r13 = {
query: a0,
guildId: a1,
limit: 1000,
allowEmptyQueries: true,
allowSnowflake: true,
fuzzy: false,
filter: () => true
};
const r31 = AutocompleteUtils.queryChannels({
...r13,
type: GUILD_SELECTABLE_CHANNELS_KEY,
boosters: boosterMap2
});
this.voiceChannels = AutocompleteUtils.queryChannels({
...r13,
type: GUILD_VOCAL_CHANNELS_KEY,
boosters: boosterMap
}).map((item) => ({
channel: item.record
}));
this.textChannels = chain(r31).map((item) => {
let lastMessageId = ReadStateStore.lastMessageId(item.record.id);
if (lastMessageId == null) {
lastMessageId = item.record.lastMessageId;
}
return {
channel: item.record,
lastMessageId
};
}).sort((a, b) => SnowflakeUtils.compare(b.lastMessageId, a.lastMessageId)).value();
if (a0.length > 0) {
this.count = this.textChannels.length + this.voiceChannels.length;
} else {
this.count = null;
}
}
getTextChannels() {
return this.textChannels;
}
getVoiceChannels() {
return this.voiceChannels;
}
getCount() {
return this.count;
}
}
c7803_10 = new Map();
class SearchGuildChannelTabStore extends Module589.Store {
static displayName = "SearchGuildChannelTabStore";
initialize() {
this.waitFor(ReadStateStore);
}
getTextChannels(a0) {
const r6 = c7803_10.get(a0);
let r7 = r6 == null ? void 0 : r6.getTextChannels();
if (r7 == null) {
r7 = c7803_7;
}
return r7;
}
getVoiceChannels(a0) {
const r6 = c7803_10.get(a0);
let r7 = r6 == null ? void 0 : r6.getVoiceChannels();
if (r7 == null) {
r7 = c7803_8;
}
return r7;
}
getCount(a0) {
const r6 = c7803_10.get(a0);
let r7 = r6 == null ? void 0 : r6.getCount();
if (r7 == null) {
r7 = null;
}
return r7;
}
}
const searchGuildChannelTabStore = new SearchGuildChannelTabStore(Dispatcher, {
SEARCH_GUILD_CHANNEL_TAB_SEARCH: function handleSearchGuildChannelTabSearch({ id, guildId, searchQueryString }) {
let r11 = c7803_10.get(id);
if (r11 == null) {
const r16 = {
__proto__: GuildChannelSearchManager.prototype,
count: null,
textChannels: [],
voiceChannels: null
};
r16.voiceChannels = [];
r11 = r16;
}
c7803_10.set(id, r11);
r11.search(searchQueryString, guildId);
},
SEARCH_GUILD_CHANNEL_TAB_CLEANUP: function handleSearchGuildChannelTabCleanup(a0) {
return c7803_10.delete(a0.id);
}
});
export default searchGuildChannelTabStore;
@@ -0,0 +1,104 @@
// Metro module 15479 (f15480).
import * as _SearchConstants from "../../SearchConstants";
import { SearchHistoryItemTypes } from "../../SearchConstants";
import { hasOwnProperty } from "../../../../_bundle/Module1385";
import { isEqual, mapValues } from "../../../../_bundle/Module12";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
let c11013_4;
const { NATIVE_SEARCH_HISTORY_STORAGE_KEY, NATIVE_SEARCH_HISTORY_STORE_DISPLAY_NAME } = _SearchConstants;
class SearchHistory {
constructor() {
return {
__proto__: new.target.prototype,
items: []
};
}
deserialize(a0) {
this.items = a0.slice(0, 3);
this.items = this.items.filter((item) => item.type !== SearchHistoryItemTypes.TEXT || item.tags == null || item.tags.every((tag) => hasOwnProperty(tag, "type")));
}
serialize() {
return this.items;
}
add(a0) {
if (!(a0.type === SearchHistoryItemTypes.TEXT && a0.text.trim() === "" && (a0.tags == null || a0.tags.length === 0))) {
this.remove(a0);
this.items.unshift(a0);
this.items = this.items.slice(0, 3);
}
}
remove(c22055_0) {
this.items = this.items.filter((item) => !isEqual(item, c22055_0));
}
}
c11013_4 = {};
class SearchHistoryStore extends Module589.PersistedStore {
static displayName = NATIVE_SEARCH_HISTORY_STORE_DISPLAY_NAME;
static persistKey = NATIVE_SEARCH_HISTORY_STORAGE_KEY;
getState() {
const searchHistories = {};
let c22056_0 = searchHistories;
Object.entries(c11013_4).forEach((item) => {
const [r21, r22] = item;
if (r22 != null) {
c22056_0[r21] = r22.serialize();
}
});
return {
searchHistories
};
}
initialize(a0) {
const searchHistories = a0?.searchHistories;
if (searchHistories != null) {
c11013_4 = mapValues(searchHistories, (a0) => {
const r8 = {
__proto__: SearchHistory.prototype,
items: []
};
r8.deserialize(a0);
return r8;
});
}
}
getSearchHistory(a0) {
let r7 = c11013_4[a0];
if (r7 == null) {
r7 = {
__proto__: SearchHistory.prototype,
items: []
};
}
c11013_4[a0] = r7;
return r7.serialize();
}
}
const searchHistoryStore = new SearchHistoryStore(Dispatcher, {
SEARCH_HISTORY_NATIVE_CLEAR_ITEMS: function handleSearchHistoryClearItems(a0) {
delete c11013_4[a0.id];
},
SEARCH_HISTORY_NATIVE_REMOVE_ITEM: function handleSearchHistoryRemoveItem({ id, item }) {
let r9 = c11013_4[id];
if (r9 == null) {
r9 = {
__proto__: SearchHistory.prototype,
items: []
};
}
c11013_4[id] = r9;
r9.remove(item);
},
SEARCH_HISTORY_NATIVE_ADD_ITEM: function handleSearchHistoryAddItem({ id, item }) {
let r9 = c11013_4[id];
if (r9 == null) {
r9 = {
__proto__: SearchHistory.prototype,
items: []
};
}
c11013_4[id] = r9;
r9.add(item);
}
});
export default searchHistoryStore;
@@ -0,0 +1,175 @@
// Metro module 11463 (f11464).
import ChannelStore from "../../../../stores/ChannelStore";
import "../../../../Constants";
import Module6163, { AutocompleterResultTypes } from "../../../autocompleter/index";
import GuildUtils from "../../../../utils/GuildUtils";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
function $mk87272($env) {
return (a0, a1) => {
const r4 = $env[0];
if (a1 === r4.searchQueryString) {
const r11 = $env.$parent;
let env27069 = {
$parent: r11
};
r4.isFetching = false;
const results = [];
env27069[0] = results;
env27069[1] = r11[4].getChannel(r4.targetChannelId);
a0.forEach((item) => {
const type = item.type;
const r8 = env27069.$parent;
const r6 = r8[0];
const r3 = r8[3];
if (type === r6(r3[2]).AutocompleterResultTypes.USER) {
const context = env27069[1];
if (context != null && !(0, r8[2])(r3[3]).can({
permission: r8[5].VIEW_CHANNEL,
user: item.record,
context
})) {
return void 0;
}
env27069[0].push(item);
}
});
r4.results = results;
if (r4.searchQueryString.length > 0) {
r4.count = results.length;
} else {
r4.count = null;
}
r11[9].emitChange();
}
};
}
let c7804_8, c7804_10, c7804_9;
let env7804 = {};
const c7804_6 = [];
class GuildMemberSearchManager {
constructor() {
let env18863;
const r4 = env18863 = {
$parent: env7804
};
env18863[0] = this;
this.count = null;
this.isFetching = false;
this.searchQueryString = "";
this.targetChannelId = null;
this.results = [];
this.onAutocompleterResultsChange = $mk87272(r4);
this.autocompleter = new Module6163(this.onAutocompleterResultsChange, [AutocompleterResultTypes.USER], 50);
this.autocompleter.createSearchContext();
}
setAutocompleteOptions(a0) {
this.autocompleter.setOptions(a0);
}
teardown() {
this.autocompleter.clean();
}
search(a0, a1, a2) {
this.targetChannelId = a1;
this.isFetching = true;
const searchQueryString = a2.toLowerCase().trim();
this.searchQueryString = searchQueryString;
GuildUtils.requestMembers(a0, searchQueryString, 50);
this.autocompleter.search(searchQueryString);
}
getResults() {
return this.results;
}
getCount() {
return this.count;
}
getIsFetching() {
return this.isFetching;
}
}
c7804_8 = new Map();
class SearchGuildMemberTabStoreImpl extends Module589.Store {
static displayName = "SearchGuildMemberTabStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(ChannelStore);
}
getResults(a0) {
const r6 = c7804_8.get(a0);
let r7 = r6 == null ? void 0 : r6.getResults();
if (r7 == null) {
r7 = c7804_6;
}
return r7;
}
getCount(a0) {
const r6 = c7804_8.get(a0);
let r7 = r6 == null ? void 0 : r6.getCount();
if (r7 == null) {
r7 = null;
}
return r7;
}
getIsFetching(a0) {
const r6 = c7804_8.get(a0);
let r7 = r6 == null ? void 0 : r6.getIsFetching();
if (r7 == null) {
r7 = false;
}
return r7;
}
}
c7804_10 = SearchGuildMemberTabStoreImpl;
c7804_9 = new SearchGuildMemberTabStoreImpl(Dispatcher, {
SEARCH_GUILD_MEMBER_TAB_SEARCH: function handleSearchGuildMemberTabSearch(a0) {
const { id, guildId, channelId } = a0;
let threadId = a0.threadId;
const searchQueryString = a0.searchQueryString;
let r20 = c7804_8.get(id);
if (r20 == null) {
let env18864;
const r23 = {
__proto__: GuildMemberSearchManager.prototype
};
const r24 = env18864 = {
$parent: env7804
};
env18864[0] = r23;
r23.count = null;
r23.isFetching = false;
r23.searchQueryString = "";
r23.targetChannelId = null;
r23.results = [];
r23.onAutocompleterResultsChange = $mk87272(r24);
r23.autocompleter = new Module6163(r23.onAutocompleterResultsChange, [AutocompleterResultTypes.USER], 50);
r23.autocompleter.createSearchContext();
r20 = r23;
}
c7804_8.set(id, r20);
const setAutocompleteOptions2 = r20.setAutocompleteOptions;
const r49 = r20;
if (threadId == null) {
threadId = void 0;
}
setAutocompleteOptions2.call(r49, {
frecencyBoosters: true,
allowSnowflake: true,
userFilters: {
guild: guildId,
strict: true,
thread: threadId
}
});
r49.search(guildId, channelId, searchQueryString);
},
SEARCH_GUILD_MEMBER_TAB_CLEANUP: function handleSearchGuildMemberTabCleanup({ id }) {
const r4 = c7804_8.get(id);
if (r4 != null) {
r4.teardown();
}
c7804_8.delete(id);
}
});
export default c7804_9;
@@ -0,0 +1,153 @@
// Metro module 11464 (f11465).
import ChannelStore from "../../../../stores/ChannelStore";
import FrecencyStore from "../../../../stores/FrecencyStore";
import Module12 from "../../../../_bundle/Module12";
import { filterGroupDMs, matchGroupDM } from "../../../main_tabs_v2/native/shared_components/user_list/NewMessageUserList";
import { UserSearch, parseUserSearchResults } from "../../../main_tabs_v2/native/shared_components/user_list/useUserListData";
import { intl, t } from "../../../../intl/index.native";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
function $mk87273($env) {
return () => $env[0].processResults();
}
function $mk87274($env) {
return () => $env[0].processResults();
}
let c7805_7, c7805_8;
let c7805_5 = [];
class PeopleSearchManager {
constructor() {
let env18865;
const r2 = env18865 = {};
env18865[0] = this;
this.count = null;
this.searchQueryString = "";
this.groupDMs = [];
this.userIndexes = {};
this.results = [];
this.userSearch = new UserSearch($mk87273(r2));
this.userSearch.subscribe($mk87274(r2), true);
}
teardown() {
this.userSearch.unsubscribe();
}
search(a0) {
const searchQueryString = a0.toLowerCase().trim();
this.searchQueryString = searchQueryString;
if (searchQueryString !== "") {
this.userIndexes = this.userSearch.filter(searchQueryString);
this.userSearch.fetch(searchQueryString, true);
const r24 = searchQueryString.toLocaleLowerCase().trim();
let c18866_0 = r24;
this.groupDMs = r24.length === 0 ? [] : Module12.chain(ChannelStore.getMutablePrivateChannels()).values().filter(filterGroupDMs).map((item) => [item, matchGroupDM(item, c18866_0), FrecencyStore.getScoreWithoutFetchingLatest(item.id)]).filter((item) => {
const [, r14] = item;
return r14 > 0;
}).sort((a, b) => {
let r5 = b[1] - a[1];
if (r5 === 0) {
r5 = b[2] - a[2];
}
return r5;
}).map((item) => {
const [r8] = item;
return r8;
}).value();
}
this.processResults();
}
processResults() {
this.userIndexes = this.userSearch.filter(this.searchQueryString);
const r22 = parseUserSearchResults({
data: this.userIndexes,
withGuildMembers: true,
withAffinitySuggestions: true,
withFriends: true,
withFriendSuggestions: false,
withFriendRequests: false,
withFriendRequestsIncoming: false,
withFriendRequestsOutgoing: false,
excludeCurrentUser: true
});
const length = this.groupDMs.length;
let results = r22;
if (length > 0) {
const searchQueryString = this.searchQueryString;
results = r22;
if (searchQueryString !== "") {
const r36 = {
title: intl.string(t.qGlQrW),
items: this.groupDMs
};
const r40 = r22.findIndex((item) => item.title === intl.string(t.y29JXs));
results = r40 === -1 ? [...r22, r36] : [...r22.slice(0, r40), r36, ...r22.slice(r40)];
}
}
if (this.searchQueryString.length > 0) {
this.count = results.reduce((acc, result) => acc + result.items.length, 0);
} else {
this.count = null;
}
this.results = results;
c7805_8.emitChange();
}
getResults() {
return this.results;
}
getCount() {
return this.count;
}
}
c7805_7 = new Map();
class SearchPeopleTabStoreImpl extends Module589.Store {
static displayName = "SearchPeopleTabStore";
initialize() {
this.waitFor(ChannelStore, FrecencyStore);
}
getResults(a0) {
const r6 = c7805_7.get(a0);
let r7 = r6 == null ? void 0 : r6.getResults();
if (r7 == null) {
r7 = c7805_5;
}
return r7;
}
getCount(a0) {
const r6 = c7805_7.get(a0);
let r7 = r6 == null ? void 0 : r6.getCount();
if (r7 == null) {
r7 = null;
}
return r7;
}
}
c7805_8 = new SearchPeopleTabStoreImpl(Dispatcher, {
SEARCH_PEOPLE_TAB_SEARCH: function handleSearchPeopleTabSearch({ id, searchQueryString }) {
let r2 = c7805_7.get(id);
if (r2 == null) {
let env18867;
const r16 = env18867 = {};
const r18 = {
__proto__: PeopleSearchManager.prototype
};
env18867[0] = r18;
r18.count = null;
r18.searchQueryString = "";
r18.groupDMs = [];
r18.userIndexes = {};
r18.results = [];
r18.userSearch = new UserSearch($mk87273(r16));
r18.userSearch.subscribe($mk87274(r16), true);
r2 = r18;
}
c7805_7.set(id, r2);
r2.search(searchQueryString);
},
SEARCH_PEOPLE_TAB_CLEANUP: function handleSearchPeopleTabCleanup({ id }) {
const r4 = c7805_7.get(id);
if (r4 != null) {
r4.teardown();
}
c7805_7.delete(id);
}
});
export default c7805_8;
@@ -0,0 +1,247 @@
// Metro module 10102 (f10103).
import ChannelStore from "../../../../stores/ChannelStore";
import RelationshipStore from "../../../../stores/RelationshipStore";
import UserStore from "../../../../stores/UserStore";
import { EMPTY_SEARCH_QUERY_STRING, SearchQueryTagTypes } from "../../SearchConstants";
import { SearchFilterAddLocations } from "../tracking/TrackingConstants";
import { SearchTokenTypes, SearchTypes } from "../../../../Constants";
import { computeChannelName } from "../../../channel/useChannelName";
import { intl, t } from "../../../../intl/index.native";
import { quoteChannelName, getSearchContextId } from "../../SearchUtils";
import SearchQueryTagManager from "./SearchQueryTagManager";
import { cachedFunction } from "../../../../utils/FunctionUtils";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
let c6722_12, c6722_13;
class SearchQueryStateManager {
constructor(a0) {
let initialTagsSnapshot;
const _this = this;
this.isExplicitSearchSubmitted = false;
this.getQueryString = function getQueryString(r5 = false) {
const queryString = _this.tagsManager.getQueryString(r5);
return queryString.length !== 0 ? `${queryString} ${_this.textInputValue}` : _this.textInputValue;
};
this.isQueryStringEmpty = () => _this.getQueryString().trim().length === 0;
this.getTextInputValue = () => _this.textInputValue;
this.setTextInputValue = function setTextInputValue(a0, textInputChangedFromInput = false) {
_this.textInputValue = a0;
_this.textInputChangedFromInput = textInputChangedFromInput;
_this.resetExplicitSearchSubmitted();
};
this.isInitialSearchQuery = () => {
const isExplicitSearchSubmitted = _this.isExplicitSearchSubmitted;
return isExplicitSearchSubmitted ? !isExplicitSearchSubmitted : _this.textInputValue.trim().length === 0 && !_this.tagsManager.hasUserAddedTags();
};
this.markExplicitSearchSubmitted = () => {
_this.isExplicitSearchSubmitted = true;
};
this.resetExplicitSearchSubmitted = () => {
_this.isExplicitSearchSubmitted = false;
};
this.getSearchResultsQuery = () => _this.searchResultsQuery;
this.setSearchResultsQuery = (a0) => {
_this.searchResultsQuery = a0;
};
this.isTextInputValueEmpty = () => _this.textInputValue.trim().length === 0;
this.getTextValueChangedFromInput = () => _this.textInputChangedFromInput;
this.hasUserAddedTags = () => _this.tagsManager.hasUserAddedTags();
this.getTags = () => _this.tagsManager.get();
this.getPrefixTag = () => _this.tagsManager.getPrefixTag();
this.isAutocompleteVisible = () => _this.getPrefixTag() != null;
this.setTags = (a0) => {
_this.tagsManager.set(a0);
_this.resetExplicitSearchSubmitted();
};
this.addTag = (a0) => {
_this.tagsManager.add(a0);
_this.resetExplicitSearchSubmitted();
};
this.removeTag = (a0) => {
_this.tagsManager.removeAtIndex(a0);
_this.resetExplicitSearchSubmitted();
};
this.removePrefixTags = () => {
_this.tagsManager.removeAnyPrefixTags();
_this.resetExplicitSearchSubmitted();
};
this.getChannelIds = () => _this.tagsManager.getChannelIds();
this.getUserIds = (a0) => _this.tagsManager.getUserIds(a0);
this.isTagsEmpty = () => _this.tagsManager.isEmpty();
this.saveDraftTextInputValue = () => {
if (!(_this.draftTextInputValue != null || _this.isTextInputValueEmpty())) {
_this.draftTextInputValue = _this.textInputValue;
}
};
this.restoreDraftTextInputValue = () => {
if (_this.draftTextInputValue != null) {
_this.textInputValue = _this.draftTextInputValue;
_this.textInputChangedFromInput = false;
_this.draftTextInputValue = null;
}
};
this.reset = () => {
_this.textInputValue = EMPTY_SEARCH_QUERY_STRING;
_this.textInputChangedFromInput = false;
_this.searchResultsQuery = EMPTY_SEARCH_QUERY_STRING;
_this.draftTextInputValue = null;
_this.isExplicitSearchSubmitted = false;
_this.tagsManager.set(_this.initialTagsSnapshot);
};
this.textInputValue = EMPTY_SEARCH_QUERY_STRING;
this.textInputChangedFromInput = false;
this.searchResultsQuery = EMPTY_SEARCH_QUERY_STRING;
const type = a0.type;
if (SearchTypes.THREAD !== type && SearchTypes.GUILD_CHANNEL !== type) {
initialTagsSnapshot = [];
} else {
const channel = ChannelStore.getChannel(a0.channelId);
if (channel == null ? void 0 : channel.isObfuscated()) {
initialTagsSnapshot = [];
} else {
const r10 = channel != null ? computeChannelName(channel, UserStore, RelationshipStore) : void 0;
initialTagsSnapshot = r10 == null ? [] : [{
type: SearchQueryTagTypes.COMPLETE,
searchTokenType: SearchTokenTypes.FILTER_IN,
text: `${intl.string(t.WNpFHa)}: ${quoteChannelName(r10)}`,
channelId: a0.channelId,
location: SearchFilterAddLocations.CLIENT_AUTO_ADD
}];
}
}
this.initialTagsSnapshot = initialTagsSnapshot;
this.tagsManager = new SearchQueryTagManager();
this.tagsManager.set(this.initialTagsSnapshot);
this.draftTextInputValue = null;
}
}
c6722_12 = new Map();
c6722_13 = cachedFunction((a0) => new SearchQueryStateManager(a0));
class NativeSearchQueryStore extends Module589.Store {
static displayName = "NativeSearchQueryStore";
initialize() {
this.waitFor(ChannelStore, UserStore, RelationshipStore);
}
getManager(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12;
}
getQueryString(a0, r4 = false) {
let r13 = c6722_12.get(getSearchContextId(a0));
if (r13 == null) {
r13 = c6722_13(a0);
}
return r13.getQueryString(r4);
}
isQueryStringEmpty(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.isQueryStringEmpty();
}
getTextInputValue(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getTextInputValue();
}
isInitialSearchQuery(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.isInitialSearchQuery();
}
getSearchResultsQuery(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getSearchResultsQuery();
}
isTextInputValueEmpty(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.isTextInputValueEmpty();
}
getTextValueChangedFromInput(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getTextValueChangedFromInput();
}
hasUserAddedTags(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.hasUserAddedTags();
}
getTags(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getTags();
}
getPrefixTag(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getPrefixTag();
}
isAutocompleteVisible(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.isAutocompleteVisible();
}
getChannelIds(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getChannelIds();
}
getUserIds(a0, a1) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.getUserIds(a1);
}
isTagsEmpty(a0) {
let r12 = c6722_12.get(getSearchContextId(a0));
if (r12 == null) {
r12 = c6722_13(a0);
}
return r12.isTagsEmpty();
}
}
const nativeSearchQueryStore = new NativeSearchQueryStore(Dispatcher, {
SEARCH_QUERY_NATIVE_UPDATE: function handleSearchQueryNativeUpdate({ searchContext, updater }) {
const searchContextId = getSearchContextId(searchContext);
let r18 = c6722_12.get(searchContextId);
if (r18 == null) {
const searchQueryStateManager = new SearchQueryStateManager(searchContext);
c6722_12.set(searchContextId, searchQueryStateManager);
r18 = searchQueryStateManager;
}
updater(r18);
},
SEARCH_QUERY_NATIVE_DELETE: function handleSearchQueryNativeDelete(a0) {
c6722_12.delete(a0.id);
}
});
export default nativeSearchQueryStore;
export { SearchQueryStateManager };
@@ -0,0 +1,121 @@
// Metro module 10115 (f10116).
import { SearchQueryTagTypes } from "../../SearchConstants";
import { SearchFilterAddLocations } from "../tracking/TrackingConstants";
const isComplete = function isComplete(a0) {
return a0.type === SearchQueryTagTypes.COMPLETE;
};
class SearchQueryTagManager {
constructor() {
const r6 = {
__proto__: new.target.prototype,
tags: [],
ids: null,
channelIds: null,
version: 0
};
r6.ids = new Set();
r6.channelIds = new Set();
return r6;
}
markChanged() {
const set2 = new Set();
let c17708_0 = set2;
const set3 = new Set();
let c17708_1 = set3;
this.tags.forEach((tag) => {
c17708_0.add(tag.text);
if (tag.type === SearchQueryTagTypes.COMPLETE && tag.channelId != null) {
c17708_1.add(tag.channelId);
}
});
this.ids = set2;
this.channelIds = set3;
this.version = this.version + 1;
}
mergeTag(a0, a1) {
const r4 = {
type: SearchQueryTagTypes.COMPLETE,
text: `${a0.text} ${a1.text}`,
location: a0.location,
searchTokenType: a0.searchTokenType,
channelId: a1.channelId,
userId: a1.userId
};
this.tags = [...this.tags.filter((tag) => tag !== a0 && tag !== a1), r4];
}
replaceTag(c17710_0, c17710_1) {
this.tags = this.tags.map((tag) => tag === c17710_0 ? c17710_1 : tag);
}
exists(a0) {
return this.ids.has(a0.text);
}
getChannelIds() {
return this.channelIds;
}
getUserIds(c17711_0) {
const set2 = new Set();
let c17711_1 = set2;
this.tags.forEach((tag) => {
if (tag.type === SearchQueryTagTypes.COMPLETE) {
const userId = tag.userId;
if (tag.searchTokenType === c17711_0 && userId != null) {
c17711_1.add(userId);
}
}
});
return set2;
}
isChannelTagsOnly() {
return this.tags.filter(isComplete).every((item) => item.channelId != null);
}
hasUserAddedTags() {
return this.tags.filter(isComplete).some((item) => item.location !== SearchFilterAddLocations.CLIENT_AUTO_ADD);
}
isEmpty() {
return this.tags.length === 0;
}
getPrefixTag() {
const r9 = this.tags[this.tags.length - 1];
if (r9 != null) {
return r9.type === SearchQueryTagTypes.PREFIX ? r9 : void 0;
}
}
get() {
return this.tags;
}
set(a0) {
this.tags = a0;
this.markChanged();
}
getQueryString(r5 = false) {
let c17712_0 = r5;
const r7 = this.tags.filter((tag) => {
const r0 = tag.type === SearchQueryTagTypes.PREFIX;
return r0 ? c17712_0 : !r0;
});
return r7.length !== 0 ? `${r7.map((item) => item.text).join(" ")}` : "";
}
add(a0) {
if (!this.exists(a0)) {
const r16 = this.tags[this.tags.length - 1];
if (a0.type === SearchQueryTagTypes.PREFIX && (r16 != null && r16.type === SearchQueryTagTypes.PREFIX)) {
this.replaceTag(r16, a0);
} else if (a0.type === SearchQueryTagTypes.ANSWER && (r16 != null && r16.type === SearchQueryTagTypes.PREFIX)) {
this.mergeTag(r16, a0);
} else if (a0.type === SearchQueryTagTypes.PREFIX || a0.type === SearchQueryTagTypes.COMPLETE) {
this.tags = [...this.tags, a0];
}
this.markChanged();
}
}
removeAnyPrefixTags() {
this.tags = this.tags.filter((tag) => !(tag.type === SearchQueryTagTypes.PREFIX));
this.markChanged();
}
removeAtIndex(a0) {
let c17713_0 = this.tags[a0];
this.tags = this.tags.filter((tag) => tag !== c17713_0);
this.markChanged();
}
}
export default SearchQueryTagManager;
@@ -0,0 +1,192 @@
// Metro module 11461 (f11462).
import ChannelStore from "../../../../stores/ChannelStore";
import SearchMessageStore from "../../SearchMessageStore";
import SearchGuildChannelTabStore from "./SearchGuildChannelTabStore";
import SearchMemberTabStore from "./SearchMemberTabStore";
import SearchPeopleTabStore from "./SearchPeopleTabStore";
import SearchQueryStore from "./SearchQueryStore";
import { SEARCH_TYPE_TO_SEARCH_INITIAL_TABS, SEARCH_TYPE_TO_SEARCH_RESULT_TABS, SearchTabs } from "../../SearchConstants";
import shallowEqual, { areArraysShallowEqual } from "../../../../_bundle/shallowEqual";
import { getSearchContextId, getChannelIdFromSearchContext, getSearchTabFetchId } from "../../SearchUtils";
import Module589 from "../../../../_bundle/Module589";
import Dispatcher from "../../../../Dispatcher";
let candidateTabs, c7802_13, computeLayoutForState, computeLayoutForAll;
const handleSearchQuery = function handleSearchQuery({ searchContext: searchContext2 }) {
const searchContextId2 = getSearchContextId(searchContext2);
let r13 = c7802_13.get(searchContextId2);
if (r13 == null) {
r13 = {
searchContext: searchContext2,
wasInitialSearchQuery: true,
candidateTabs,
visibleTabs: candidateTabs,
visibleTabCounts: null
};
}
c7802_13.set(searchContextId2, r13);
return computeLayoutForState(r13);
};
computeLayoutForState = function computeLayoutForState(a0) {
let searchContextId, c18862_9;
const searchContext = a0.searchContext;
if (SearchQueryStore.isAutocompleteVisible(searchContext)) {
return false;
}
const isInitialSearchQuery = SearchQueryStore.isInitialSearchQuery(searchContext);
const isTextInputValueEmpty = SearchQueryStore.isTextInputValueEmpty(searchContext);
const hasUserAddedTags = SearchQueryStore.hasUserAddedTags(searchContext);
const isTagsEmpty = SearchQueryStore.isTagsEmpty(searchContext);
const searchResultsQuery = SearchQueryStore.getSearchResultsQuery(searchContext);
const queryString = SearchQueryStore.getQueryString(searchContext);
const r11 = isInitialSearchQuery ? SEARCH_TYPE_TO_SEARCH_INITIAL_TABS[searchContext.type] : SEARCH_TYPE_TO_SEARCH_RESULT_TABS[searchContext.type];
const channel = ChannelStore.getChannel(getChannelIdFromSearchContext(searchContext));
let r38 = channel == null ? void 0 : channel.isArchivedThread();
if (r38 == null) {
r38 = false;
}
let c18862_7 = r38;
const candidateTabs2 = r11.filter((item) => {
if (SearchTabs.MEMBERS === item) {
let r12 = !c18862_7;
if (!c18862_7) {
let r13 = isInitialSearchQuery;
if (!isInitialSearchQuery) {
r13 = hasUserAddedTags ? !hasUserAddedTags : !isTextInputValueEmpty;
}
r12 = r13;
}
return r12;
}
if (SearchTabs.RECENT !== item && SearchTabs.GUILD_CHANNELS !== item && SearchTabs.PEOPLE !== item) {
return true;
}
return isTagsEmpty;
});
searchContextId = getSearchContextId(searchContext);
const r50 = candidateTabs2.reduce((acc, item) => {
L12: {
if (SearchTabs.MEMBERS === item) {
acc[item] = SearchMemberTabStore.getCount(searchContextId);
} else if (SearchTabs.GUILD_CHANNELS === item) {
acc[item] = SearchGuildChannelTabStore.getCount(searchContextId);
} else if (SearchTabs.PEOPLE === item) {
acc[item] = SearchPeopleTabStore.getCount(searchContextId);
} else {
if (SearchTabs.MESSAGES !== item && SearchTabs.PINS !== item && SearchTabs.MEDIA !== item && SearchTabs.LINKS !== item && SearchTabs.FILES !== item) {
break L12;
}
acc[item] = SearchMessageStore.getTotalCount(getSearchTabFetchId(searchContext, item, searchResultsQuery));
}
}
return acc;
}, {});
c18862_9 = r50;
const wasInitialSearchQuery = a0.wasInitialSearchQuery;
let wasInitialSearchQuery2 = true;
let visibleTabCounts2 = null;
let visibleTabs = candidateTabs2;
if (!isInitialSearchQuery) {
if (searchResultsQuery !== queryString) {
visibleTabs = candidateTabs2.filter((item) => a0.wasInitialSearchQuery || a0.visibleTabs.includes(item));
wasInitialSearchQuery2 = false;
visibleTabCounts2 = null;
} else if (candidateTabs2.every((item) => c18862_9[item] != null)) {
visibleTabs = candidateTabs2.filter((item) => c18862_9[item] !== 0);
wasInitialSearchQuery2 = false;
visibleTabCounts2 = r50;
} else {
visibleTabs = a0.visibleTabs;
visibleTabCounts2 = a0.visibleTabCounts;
wasInitialSearchQuery2 = wasInitialSearchQuery;
}
}
const r65 = areArraysShallowEqual(a0.candidateTabs, candidateTabs2);
let r66 = !r65;
const r71 = areArraysShallowEqual(a0.visibleTabs, visibleTabs);
const r3 = !r71;
const visibleTabCounts = a0.visibleTabCounts;
const r73 = visibleTabCounts === visibleTabCounts2 || visibleTabCounts != null && visibleTabCounts2 != null && shallowEqual(visibleTabCounts, visibleTabCounts2);
const r78 = !r73;
if (!r65) {
a0.candidateTabs = candidateTabs2;
}
if (!r71) {
a0.visibleTabs = visibleTabs;
}
if (!r73) {
a0.visibleTabCounts = visibleTabCounts2;
}
a0.wasInitialSearchQuery = wasInitialSearchQuery2;
if (r65) {
r66 = r3;
}
if (!r66) {
r66 = r78;
}
return r66;
};
computeLayoutForAll = function computeLayoutForAll() {
let r0 = false;
for (const item of c7802_13.values()) {
if (computeLayoutForState(item)) {
r0 = true;
}
}
return r0;
};
candidateTabs = [];
c7802_13 = new Map();
class SearchTabsLayoutStore extends Module589.Store {
static displayName = "SearchTabsLayoutStore";
initialize() {
this.waitFor(SearchQueryStore, SearchMessageStore, SearchMemberTabStore, SearchGuildChannelTabStore, SearchPeopleTabStore, ChannelStore);
this.syncWith([SearchMessageStore, SearchMemberTabStore, SearchGuildChannelTabStore, SearchPeopleTabStore], computeLayoutForAll);
}
getCandidateTabs(a0) {
let r11 = c7802_13.get(getSearchContextId(a0));
if (r11 == null) {
r11 = {
searchContext: a0,
wasInitialSearchQuery: true,
candidateTabs,
visibleTabs: candidateTabs,
visibleTabCounts: null
};
}
return r11.candidateTabs;
}
getVisibleTabs(a0) {
let r11 = c7802_13.get(getSearchContextId(a0));
if (r11 == null) {
r11 = {
searchContext: a0,
wasInitialSearchQuery: true,
candidateTabs,
visibleTabs: candidateTabs,
visibleTabCounts: null
};
}
return r11.visibleTabs;
}
getVisibleTabCounts(a0) {
let r11 = c7802_13.get(getSearchContextId(a0));
if (r11 == null) {
r11 = {
searchContext: a0,
wasInitialSearchQuery: true,
candidateTabs,
visibleTabs: candidateTabs,
visibleTabCounts: null
};
}
return r11.visibleTabCounts;
}
}
const searchTabsLayoutStore = new SearchTabsLayoutStore(Dispatcher, {
SEARCH_QUERY_NATIVE_INITIALIZE: handleSearchQuery,
SEARCH_QUERY_NATIVE_UPDATE: handleSearchQuery,
SEARCH_QUERY_NATIVE_DELETE: function handleSearchQueryNativeDelete(a0) {
return c7802_13.delete(a0.id);
}
});
export default searchTabsLayoutStore;