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

+216
View File
@@ -0,0 +1,216 @@
// Metro module 10110 (f10111).
import { getSearchQueryFromTokens, tokenizeQuery, searchModeToSearchQueryParams, getGuildIdFromSearchContext, setIncludeNSFW, getSearchContextId } from "./SearchUtils";
import SearchTabsFetchManager from "./managers/SearchTabsFetchManager";
import Dispatcher from "../../Dispatcher";
import Module12 from "../../_bundle/Module12";
import convertServerThreadMember from "../threads/convertServerThreadMember";
import SearchFetchManager from "./managers/SearchFetchManager";
import { FrecencyUserSettingsActionCreators } from "../user_settings/UserSettingsProtoActionCreators";
const r13 = {
fetchTabMessages: function fetchTabMessages({ searchContext, searchTabs, searchQueryString, pagination, trackExactTotalHits, getId, getLimit, onFetchStart, onFetchSuccess, searchMode }) {
let guildIdFromSearchContext, ids;
guildIdFromSearchContext = void 0;
ids = void 0;
const searchQueryFromTokens = getSearchQueryFromTokens(tokenizeQuery(searchQueryString));
if (Array.isArray(searchQueryFromTokens.pinned)) {
searchQueryFromTokens.pinned = searchQueryFromTokens.pinned.some((item) => item === true);
}
const searchQuery = {
...searchQueryFromTokens,
...searchModeToSearchQueryParams(searchMode)
};
guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
if (guildIdFromSearchContext != null) {
setIncludeNSFW(searchQuery, guildIdFromSearchContext);
}
const r63 = SearchTabsFetchManager.create({
id: getSearchContextId(searchContext),
searchContext,
searchQuery,
searchTabs,
getLimit,
pagination,
trackExactTotalHits
});
if (onFetchStart != null) {
onFetchStart({
searchContext,
searchQueryString,
searchQuery
});
}
ids = searchTabs.map((searchTab) => getId(searchTab));
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_START",
ids
});
r63.fetch(({ body }) => {
const tabEntries = Object.entries(body.tabs);
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_SUCCESS",
guildId: guildIdFromSearchContext,
data: tabEntries.map((tabEntry) => {
const [r23, r24] = tabEntry;
const id = getId(r23);
const cursor = r24.cursor;
const cursor2 = cursor != null ? Module12.isEmpty(cursor) ? null : cursor : cursor;
let channels = r24.channels;
if (channels == null) {
channels = [];
}
let threads = r24.threads;
if (threads == null) {
threads = [];
}
let members = r24.members;
if (members == null) {
members = [];
}
return {
id,
analyticsId: body.analytics_id,
totalResults: r24.total_results,
cursor: cursor2,
messages: r24.messages,
channels,
threads,
members: members.map((member) => convertServerThreadMember(member)),
doingHistoricalIndex: body.doing_deep_historical_index,
documentsIndexed: body.documents_indexed
};
})
});
if (onFetchSuccess != null) {
onFetchSuccess({
searchContext,
tabEntries
});
}
}, () => {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_INDEXING",
ids
});
}, (a0) => {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_FAILURE",
ids,
error: a0
});
});
return true;
},
fetchMessages: function fetchMessages({ searchContext: searchContext2, searchQueryString, pagination, searchMode, searchEverywhere, onFetchStart }) {
const searchQuery = {
...getSearchQueryFromTokens(tokenizeQuery(searchQueryString)),
...searchModeToSearchQueryParams(searchMode),
offset: pagination.offset
};
const guildIdFromSearchContext2 = getGuildIdFromSearchContext(searchContext2);
if (guildIdFromSearchContext2 != null) {
setIncludeNSFW(searchQuery, guildIdFromSearchContext2);
}
if (searchEverywhere) {
searchQuery.search_everywhere = true;
}
const searchContextId = getSearchContextId(searchContext2);
const r51 = SearchFetchManager.create({
id: searchContextId,
searchType: searchContext2.type,
searchQuery
});
if (onFetchStart != null) {
onFetchStart({
searchContext: searchContext2,
searchQueryString,
searchQuery
});
}
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_START",
ids: [searchContextId]
});
r51.fetch((a0) => {
let threads = a0.body.threads;
if (threads == null) {
threads = [];
}
let members = a0.body.members;
if (members == null) {
members = [];
}
const r16 = {
id: searchContextId,
analyticsId: a0.body.analytics_id,
totalResults: a0.body.total_results,
messages: a0.body.messages,
threads,
members: members.map((member) => convertServerThreadMember(member)),
doingHistoricalIndex: a0.body.doing_deep_historical_index,
documentsIndexed: a0.body.documents_indexed,
channels: null,
cursor: null
};
let channels = a0.body.channels;
if (channels == null) {
channels = [];
}
r16.channels = channels;
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_SUCCESS",
guildId: guildIdFromSearchContext2,
data: [r16]
});
}, () => {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_INDEXING",
ids: [searchContextId]
});
}, (a0) => {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_FAILURE",
ids: [searchContextId],
error: a0
});
});
},
clearSearchRecentMessages: function clearSearchRecentMessages() {
Dispatcher.dispatch({
type: "SEARCH_RECENT_MESSAGES_CLEAR"
});
},
clearAllSearchMesssages: function clearAllSearchMesssages() {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_CLEAR_ALL"
});
},
clearSearchMessages: function clearSearchMessages(a0) {
Dispatcher.dispatch({
type: "SEARCH_MESSAGES_CLEAR",
id: a0
});
},
initializeAutocomplete: function initializeAutocomplete(a0) {
Dispatcher.dispatch({
type: "SEARCH_AUTOCOMPLETE_INITIALIZE",
searchContext: a0
});
},
updateAutocompleteQuery: function updateAutocompleteQuery({ searchContext: searchContext2, tokens, queryString, cursorScope }) {
if (queryString.trim().length > 0) {
FrecencyUserSettingsActionCreators.loadIfNecessary();
}
Dispatcher.dispatch({
type: "SEARCH_AUTOCOMPLETE_QUERY_UPDATE",
searchContext: searchContext2,
tokens,
cursorScope
});
},
markSearchTokensRefreshed: function markSearchTokensRefreshed() {
Dispatcher.dispatch({
type: "SEARCH_TOKENS_REFRESHED"
});
}
};
export default r13;
+346
View File
@@ -0,0 +1,346 @@
// Metro module 10105 (f10106).
import ChannelStore from "../../stores/ChannelStore";
import GuildMemberStore from "../../stores/GuildMemberStore";
import GuildStore from "../../stores/GuildStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import StreamerModeStore from "../../stores/StreamerModeStore";
import UserStore from "../../stores/UserStore";
import { ME, SearchPopoutModes, SearchTokenTypes } from "../../Constants";
import { AutocompleterResultTypes } from "../autocompleter/AutocompleterConstants";
import { getSearchContextId, isGuildLikeSearchContext, clearTokenCache, getQueryFromTokens, getAutocompleteMode, getGuildIdFromSearchContext } from "./SearchUtils";
import UserSearchManager from "../autocompleter/UserSearchManager";
import UserUtils from "../../utils/UserUtils";
import isEqual from "../../_bundle/isEqual_4349";
import GuildUtils from "../../utils/GuildUtils";
import { getBoosterMap } from "../../utils/AutocompleteUtils";
import * as _SearchTokens from "./tokens/SearchTokens";
import SearchTokens from "./tokens/SearchTokens";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let searchContext, c6725_14, c6725_15, c6725_16, c6725_17, getAutocompleteList, rebuildAutocompleteResults, c6725_21;
const handleUserSearchResults = function handleUserSearchResults(a0, { results }) {
const searchContextId = getSearchContextId(a0);
const r13 = c6725_16.get(searchContextId);
const r29 = c6725_15.get(searchContextId);
if (r13 != null && r29 != null) {
const mode = r29.mode;
let r2 = mode.type === SearchPopoutModes.FILTER;
if (r2) {
const filter = mode.filter;
r2 = filter != null && (filter === SearchTokenTypes.FILTER_FROM || filter === SearchTokenTypes.FILTER_MENTIONS);
}
if (r2) {
r13.results = (function fixUserResults(a0, r5) {
const r0 = [];
for (const item of a0) {
if (!(r0.length >= r5)) {
const user = UserStore.getUser(item.id);
const user2 = user;
if (user == null) {
continue;
}
const userTag = UserUtils.getUserTag(user2);
const text = userTag;
if (userTag == null) {
continue;
}
r0.push({
text,
user: user2
});
continue;
}
break;
}
return r0;
})(results, r29.mode.type === SearchPopoutModes.FILTER ? 10 : 3);
const { query, mode: mode2, tokens, cursorScope } = r29;
const autocompleteList = getAutocompleteList(a0, mode2, tokens);
const searchContextId2 = getSearchContextId(a0);
let r51 = c6725_16.get(searchContextId2);
if (r51 == null) {
r51 = {
results: [],
context: UserSearchManager.getUserSearchContext(handleUserSearchResults.bind(null, a0))
};
}
c6725_16.set(searchContextId2, r51);
c6725_15.set(searchContextId, {
searchContext: a0,
query,
mode: mode2,
tokens,
cursorScope,
autocompletes: autocompleteList
});
c6725_21.emitChange();
}
}
};
getAutocompleteList = function getAutocompleteList(searchContext2, a1, a2) {
let results;
const type = a1.type;
if (SearchPopoutModes.FILTER === type) {
const { filter, token } = a1;
let maxResults = c6725_17;
if (c6725_17 === void 0) {
maxResults = 10;
}
let currentUser;
currentUser = void 0;
const r1 = filter == null;
let r29 = null;
if (!r1) {
const r30 = token == null;
let query = void 0;
if (!r30) {
const fullMatch = token.getFullMatch();
query = fullMatch == null ? void 0 : fullMatch.trim();
}
if (query == null) {
query = "";
}
const length = query.length;
if (isGuildLikeSearchContext(searchContext2) && (filter != null && (filter === SearchTokenTypes.FILTER_FROM || filter === SearchTokenTypes.FILTER_MENTIONS) && length !== 0)) {
const searchContextId = getSearchContextId(searchContext2);
let r48 = c6725_16.get(searchContextId);
if (r48 == null) {
r48 = {
results: [],
context: UserSearchManager.getUserSearchContext(handleUserSearchResults.bind(null, searchContext2))
};
}
c6725_16.set(searchContextId, r48);
results = r48.results;
} else {
const getAutocompletions = SearchTokens[filter]?.getAutocompletions;
results = getAutocompletions != null ? getAutocompletions({
query,
searchContext: searchContext2,
maxResults,
tokens: a2
}) : [];
}
let results2 = results;
if (results2 != null) {
const r68 = filter != null && (filter === SearchTokenTypes.FILTER_FROM || filter === SearchTokenTypes.FILTER_MENTIONS);
results2 = results;
if (r68) {
const isMeAutcompleteAnswer = _SearchTokens.isMeAutcompleteAnswer(query);
results2 = results;
if (isMeAutcompleteAnswer) {
currentUser = UserStore.getCurrentUser();
results2 = results;
if (currentUser != null) {
const r82 = results.filter((result) => result.user?.id !== currentUser.id);
r82.unshift({
text: ME,
user: currentUser
});
results2 = r82;
}
}
}
}
r29 = results2 == null ? null : results2.length !== 0 ? {
group: filter,
results: results2
} : null;
}
return r29 != null ? [r29] : c6725_14;
}
if (SearchPopoutModes.FILTER_ALL !== type && SearchPopoutModes.EMPTY !== type) {
return void 0;
}
return c6725_14;
};
const handleChannelCreateOrDelete = function handleChannelCreateOrDelete() {
clearTokenCache();
};
rebuildAutocompleteResults = function rebuildAutocompleteResults(a0) {
const searchContextId = getSearchContextId(a0);
const r21 = c6725_15.get(searchContextId);
if (r21 == null) {
return false;
}
const { query, mode, tokens, cursorScope } = r21;
const autocompleteList = getAutocompleteList(a0, mode, tokens);
const searchContextId2 = getSearchContextId(a0);
let r28 = c6725_16.get(searchContextId2);
if (r28 == null) {
r28 = {
results: [],
context: UserSearchManager.getUserSearchContext(handleUserSearchResults.bind(null, a0))
};
}
c6725_16.set(searchContextId2, r28);
c6725_15.set(searchContextId, {
searchContext: a0,
query,
mode,
tokens,
cursorScope,
autocompletes: autocompleteList
});
};
searchContext = null;
c6725_14 = [];
c6725_15 = new Map();
c6725_16 = new Map();
c6725_17 = 10;
new Set([SearchTokenTypes.FILTER_FROM, SearchTokenTypes.FILTER_IN, SearchTokenTypes.FILTER_MENTIONS]);
class SearchAutocompleteStoreClass extends Module589.Store {
static displayName = "SearchAutocompleteStore";
initialize() {
this.waitFor(ChannelStore, GuildMemberStore, GuildStore, SelectedChannelStore, StreamerModeStore, UserStore);
}
getState(a0) {
let r11 = c6725_15.get(getSearchContextId(a0));
if (r11 == null) {
r11 = {
searchContext: a0,
query: "",
mode: {
type: SearchPopoutModes.EMPTY,
filter: null,
token: null
},
tokens: [],
cursorScope: null,
autocompletes: []
};
}
return r11;
}
getSelectedSearchContext() {
return searchContext;
}
}
c6725_21 = new SearchAutocompleteStoreClass(Dispatcher, {
SEARCH_AUTOCOMPLETE_INITIALIZE: function handleSearchAutocompleteInitialize({ searchContext: searchContext2 }) {
if (!isEqual(searchContext, searchContext2)) {
searchContext = searchContext2;
clearTokenCache();
}
rebuildAutocompleteResults(searchContext2);
},
SEARCH_AUTOCOMPLETE_QUERY_UPDATE: function handleSearchAutocompleteQueryUpdate({ searchContext: searchContext2, tokens, cursorScope }) {
let r46, r66, autocompleteMode, autocompletes, queryFromTokens, searchContextId;
if (!isEqual(searchContext, searchContext2)) {
searchContext = searchContext2;
clearTokenCache();
}
L34: {
L6: {
queryFromTokens = getQueryFromTokens(tokens);
autocompleteMode = getAutocompleteMode(cursorScope, tokens);
searchContextId = getSearchContextId(searchContext2);
r46 = c6725_15.get(searchContextId);
if (r46 != null && queryFromTokens === r46.query) {
if (r46.mode != null && r46.mode.filter !== autocompleteMode.filter) {
break L6;
}
autocompletes = r46.autocompletes;
r66 = false;
break L34;
}
}
let r1 = autocompleteMode.type === SearchPopoutModes.FILTER;
if (r1) {
const filter = autocompleteMode.filter;
r1 = filter != null && (filter === SearchTokenTypes.FILTER_FROM || filter === SearchTokenTypes.FILTER_MENTIONS);
}
if (r1) {
const searchContextId2 = getSearchContextId(searchContext2);
let r71 = c6725_16.get(searchContextId2);
if (r71 == null) {
r71 = {
results: [],
context: UserSearchManager.getUserSearchContext(handleUserSearchResults.bind(null, searchContext2))
};
}
c6725_16.set(searchContextId2, r71);
const token = autocompleteMode.token;
const r80 = token == null;
let query = void 0;
if (!r80) {
const fullMatch = token.getFullMatch();
query = fullMatch == null ? void 0 : fullMatch.trim();
}
if (query != null && query.length > 0) {
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext2);
if (guildIdFromSearchContext != null) {
GuildUtils.requestMembers(guildIdFromSearchContext, query, c6725_17);
}
const context = r71.context;
let guild = guildIdFromSearchContext;
if (guild == null) {
guild = void 0;
}
context.setQuery({
query,
filters: {
guild
},
boosters: getBoosterMap(AutocompleterResultTypes.USER)
});
let r115 = r46?.autocompletes;
if (r115 == null) {
r115 = [];
}
r66 = false;
autocompletes = r115;
break L34;
}
r71.context.clearQuery();
autocompletes = getAutocompleteList(searchContext2, autocompleteMode, tokens);
r66 = true;
} else {
const r59 = c6725_16.get(searchContextId);
if (r59 != null) {
r59.context.clearQuery();
r59.results = [];
}
autocompletes = getAutocompleteList(searchContext2, autocompleteMode, tokens);
r66 = true;
}
}
const searchContextId3 = getSearchContextId(searchContext2);
let r122 = c6725_16.get(searchContextId3);
if (r122 == null) {
r122 = {
results: [],
context: UserSearchManager.getUserSearchContext(handleUserSearchResults.bind(null, searchContext2))
};
}
c6725_16.set(searchContextId3, r122);
c6725_15.set(searchContextId, {
searchContext: searchContext2,
query: queryFromTokens,
mode: autocompleteMode,
tokens,
cursorScope,
autocompletes
});
return r66;
},
SEARCH_QUERY_TEXT_CLEAR: function handleSearchQueryTextClear({ id }) {
const r5 = c6725_16.get(id);
if (r5 != null) {
r5.context.destroy();
r5.results = [];
c6725_16.delete(id);
}
c6725_15.delete(id);
searchContext = null;
},
CHANNEL_CREATE: handleChannelCreateOrDelete,
CHANNEL_DELETE: handleChannelCreateOrDelete,
STREAMER_MODE_UPDATE: function handleStreamerModeUpdate() {
return searchContext != null && rebuildAutocompleteResults(searchContext);
},
CHANNEL_SELECT: function handleChannelSelect() {
return searchContext != null && rebuildAutocompleteResults(searchContext);
}
});
export default c6725_21;
+190
View File
@@ -0,0 +1,190 @@
// Metro module 9101 (f9102).
import { SearchTypes } from "../../Constants";
import { ChannelListLayoutTypes } from "../main_tabs_v2/ChannelListLayoutTypes";
const r27 = {
KEY_PRESS: "key_press",
CLICK: "click"
};
const r26 = {
Messages: 0,
0: "Messages",
Media: 1,
1: "Media",
Link: 2,
2: "Link",
File: 3,
3: "File",
Pins: 4,
4: "Pins"
};
const r25 = {};
r25[r26.Media] = {
has: ["image", "video"]
};
r25[r26.File] = {
has: ["file"]
};
r25[r26.Messages] = {};
r25[r26.Link] = {
has: ["link"]
};
r25[r26.Pins] = {
pinned: true
};
const r24 = {
RECENT: "recent",
MEMBERS: "members",
PEOPLE: "people",
MEDIA: "media",
PINS: "pins",
MESSAGES: "messages",
LINKS: "links",
FILES: "files",
GUILD_CHANNELS: "guild_channels",
THREADS: "threads"
};
const r23 = {};
r23[r24.MEDIA] = 15;
r23[r24.MESSAGES] = 15;
r23[r24.PINS] = 15;
r23[r24.LINKS] = 10;
r23[r24.FILES] = 10;
const r22 = [r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const set = new Set(r22);
const r19 = [r24.MEDIA, r24.LINKS, r24.FILES];
const r18 = [r24.MEDIA, r24.LINKS, r24.PINS, r24.FILES];
const r17 = {};
r17[r24.RECENT] = r26.Media;
r17[r24.MEDIA] = r26.Media;
r17[r24.PINS] = r26.Pins;
r17[r24.MESSAGES] = r26.Messages;
r17[r24.LINKS] = r26.Link;
r17[r24.FILES] = r26.File;
const r14 = [r24.RECENT, r24.PEOPLE, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r111 = [r24.PEOPLE, r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r15 = [r24.RECENT, r24.MEMBERS, r24.GUILD_CHANNELS, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r125 = [r24.MEMBERS, r24.GUILD_CHANNELS, r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r31 = [r24.MEMBERS, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r12 = [r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r30 = [r24.MEMBERS, r24.GUILD_CHANNELS, r24.MEDIA, r24.PINS, r24.THREADS, r24.LINKS, r24.FILES];
const r11 = [r24.MEMBERS, r24.GUILD_CHANNELS, r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r32 = [r24.MEMBERS, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r13 = [r24.MEMBERS, r24.MESSAGES, r24.MEDIA, r24.PINS, r24.LINKS, r24.FILES];
const r16 = {};
r16[SearchTypes.THREAD] = r32;
r16[SearchTypes.CHANNEL] = r31;
r16[SearchTypes.GUILD_CHANNEL] = r30;
r16[SearchTypes.GUILD] = r15;
r16[SearchTypes.DMS] = r14;
const r172 = {};
r172[SearchTypes.THREAD] = r13;
r172[SearchTypes.CHANNEL] = r12;
r172[SearchTypes.GUILD_CHANNEL] = r11;
r172[SearchTypes.GUILD] = r125;
r172[SearchTypes.DMS] = r111;
const r178 = {
GUILD_TEXT_CHANNEL: "guild_text_channel",
GUILD_VOICE_CHANNEL: "guild_voice_channel",
GROUP_DM: "group_dm",
DM: "dm",
TEXT: "text"
};
const r184 = {
DM: "dm",
GENERIC: "generic",
GROUP_DM: "group_dm",
GUILD_TEXT_CHANNEL: "guild_text_channel",
GUILD_VOICE_CHANNEL: "guild_voice_channel",
SEARCH_HISTORY_ITEM: "search_history_item",
MEDIA: "media",
MEDIA_PLACEHOLDER: "media_placeholder",
MEDIA_GRID: "media_grid",
MESSAGE: "message",
MESSAGE_PLACEHOLDER: "message_placeholder",
FILE: "file",
LINK: "link",
FILE_OR_LINK_PLACEHOLDER: "file_or_link_placeholder",
SECTION: "section",
GUILD_CHANNEL_MEMBER_PLACEHOLDER: "guild_channel_member_placeholder",
GUILD_CHANNEL_MEMBER: "guild_channel_member"
};
const COZY = ChannelListLayoutTypes.COZY;
const FILES = r24.FILES;
const r202 = {
AUDIO: "audio",
EMBED: "embed",
ATTACHMENT: "attachment",
COMPONENT: "component"
};
const r207 = {
TEXT: "text",
EMBED: "embed"
};
const r208 = {
AUDIO: "audio",
MEDIA_ATTACHMENT: "media_attachment",
ATTACHMENT: "attachment"
};
const r210 = {
COMPLETE: "complete",
PREFIX: "prefix",
ANSWER: "answer"
};
const r214 = {
SEARCH_TEXT_INPUT: "search_text_input",
SEARCH_POPOUT: "search_popout",
SEARCH_FILTERS_MODAL: "search_filters_modal",
SEARCH_XDM_SETTINGS: "search_xdm_settings"
};
export { r27 as SearchAutocompleteSelectAnalyticsActions };
export const WEB_SEARCH_HISTORY_STORAGE_KEY = "SearchStore";
export const NATIVE_SEARCH_HISTORY_STORAGE_KEY = "SearchHistoryStore";
export const WEB_SEARCH_HISTORY_STORE_DISPLAY_NAME = "SearchHistoryStore_Web";
export const NATIVE_SEARCH_HISTORY_STORE_DISPLAY_NAME = "SearchHistoryStore";
export { r26 as SearchFilter };
export const SEARCH_QUERY_DEFAULT_FILTERS = {
sort_by: "timestamp",
sort_order: "desc"
};
export { r25 as SEARCH_QUERY_BY_SEARCH_FILTER };
export const SEARCH_PINNED_MESSAGES_LINE_CLAMP = 10;
export const SEARCH_MESSAGES_DEFAULT_LINE_CLAMP = 4;
export { r24 as SearchTabs };
export { r23 as SEARCH_TABS_TO_SEARCH_QUERY_LIMITS };
export { r22 as MESSAGE_SEARCH_RESULT_TABS };
export { set as MESSAGE_SEARCH_RESULT_TABS_SET };
export { r19 as CHANNEL_SEARCH_INITIAL_MESSAGE_TABS };
export { r18 as SEARCH_INITIAL_MESSAGE_TABS };
export { r17 as SEARCH_FILTERS_BY_TAB };
export { r16 as SEARCH_TYPE_TO_SEARCH_INITIAL_TABS };
export { r172 as SEARCH_TYPE_TO_SEARCH_RESULT_TABS };
export { r178 as SearchHistoryItemTypes };
export { r184 as SearchListItemTypes };
export const SEARCH_LIST_SECTION_TOP_PADDING = 16;
export const SEARCH_LIST_HORIZONTAL_PADDING = 16;
export const FILES_OR_LINKS_GAP_WIDTH = 8;
export const MEDIA_ITEM_GAP_WIDTH = 4;
export const SEARCH_ROW_TAP_STATE_PADDING = 8;
export const FILE_OR_LINK_IMAGE_RATIO = 0.72;
export const FILE_OR_LINK_IMAGE_BUFFER = 50;
export const FILES_OR_LINKS_NUM_COLUMNS = 2;
export const MEDIA_NUM_COLUMNS = 3;
export const CHANNELS_ESTIMATED_ITEM_SIZE = 64;
export const USER_ESTIMATED_ITEM_SIZE = 56;
export const MESSAGE_ESTIMATED_ITEM_SIZE = 110;
export const CARD_ESTIMATED_ITEM_SIZE = 150;
export const RECENTS_ESTIMATED_ITEM_SIZE = 64;
export const MESSAGE_PLACEHOLDER_ITEM_SIZE = 64;
export { COZY as CHANNEL_LIST_SEARCH_LAYOUT };
export const EMPTY_VOICE_STATES = [];
export const EMPTY_SEARCH_TAB_COUNTS = {};
export const FADE_LAYOUT_ANIMATION_DURATION = 350;
export const EMPTY_SEARCH_QUERY_STRING = "";
export { FILES as SEARCH_MESSAGE_TAB_SENTINEL };
export const MAX_SEARCH_RESULTS_LIMIT = 25;
export { r202 as SearchMediaTypes };
export { r207 as SearchLinkTypes };
export { r208 as SearchFileTypes };
export const SEARCH_BAR_HEIGHT = 40;
export { r210 as SearchQueryTagTypes };
export { r214 as SearchQuerySource };
+187
View File
@@ -0,0 +1,187 @@
// Metro module 10113 (f10114).
import ChannelStore from "../../stores/ChannelStore";
import { Endpoints, SearchTypes } from "../../Constants";
import Durations from "../../utils/Durations";
import Logger from "../debug/Logger";
import { HTTP } from "../../_bundle/sendRequest";
import Module1464 from "../../_bundle/Module1464";
export class SearchFetcher {
constructor(a0, a1, a2) {
const r3 = {
__proto__: new.target.prototype,
isCanceled: false
};
r3.searchId = a0;
r3.searchType = a1;
r3.query = a2;
return r3;
}
async fetch(c17707_0, c17707_1, c17707_2) {
const _this = this;
let attempts, c26625_3;
let c26625_4 = 0;
let c30195_0, c30195_1, c30195_2;
L31: {
L28: {
L30: {
L29: {
L26: {
try {
c30195_0 = void 0;
c30195_1 = void 0;
if (_this.isCanceled) {
break L31;
}
c26625_4 = 1;
c30195_0 = await _this.makeRequest({
rejectWithError: false
});
if (c30195_0 == null) {
c26625_4 = 0;
break L30;
}
if (_this.isCanceled) {
c26625_4 = 0;
break L29;
}
if (c30195_0.status === 200) {
(0, c17707_0)(c30195_0);
} else if (c30195_0.status === 202) {
const query = _this.query;
const attempts2 = _this.query.attempts;
attempts = attempts2;
if (attempts2 == null) {
attempts = 0;
}
query.attempts = attempts + 1;
if (_this.query.attempts > 5) {
c26625_4 = 0;
break L26;
}
c30195_1 = parseInt(c30195_0.headers["retry-after"]);
_this.retryDelay = isNaN(c30195_1) ? 5000 : c30195_1 !== 0 ? c30195_1 * Durations.Millis.SECOND : 5000;
_this.retryLater(c17707_0, c17707_1, c17707_2);
c17707_1(c30195_0);
}
c26625_4 = 0;
break L28;
} catch ($e) {
const r35 = $e;
let r8 = r35;
c26625_3 = r35;
if (c26625_4 !== 0) {
while (true) {
try {
const r134 = c26625_3;
c26625_4 = 0;
c30195_2 = r134;
new Logger("SearchFetcher").error(c30195_2);
(0, c17707_2)(c30195_2);
break L28;
} catch (r130) {
r8 = r130;
c26625_3 = r130;
if (c26625_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
}
cancel() {
this.isCanceled = true;
if (this.indexingPollId != null) {
clearTimeout(this.indexingPollId);
}
}
retryLater(a0, a1, a2) {
if (this.indexingPollId != null) {
clearTimeout(this.indexingPollId);
}
this.indexingPollId = setTimeout(this.fetch.bind(this, a0, a1, a2), this.retryDelay);
}
}
class SearchFetcherImpl extends SearchFetcher {
getEndpoint() {
const searchType = this.searchType;
if (SearchTypes.GUILD === searchType) {
if (this.searchId != null && this.searchId !== "") {
return Endpoints.SEARCH_GUILD(this.searchId);
}
return void 0;
}
if (SearchTypes.GUILD_CHANNEL === searchType) {
if (this.searchId != null && this.searchId !== "") {
const channel = ChannelStore.getChannel(this.searchId);
const r37 = channel == null ? void 0 : channel.getGuildId();
if (r37 == null) {
return void 0;
}
return Endpoints.SEARCH_GUILD(r37);
}
return void 0;
}
if (SearchTypes.CHANNEL === searchType) {
if (this.searchId != null && this.searchId !== "") {
return Endpoints.SEARCH_CHANNEL(this.searchId);
}
return void 0;
}
throw new Error(`[SearchFetcher] Unhandled search type: ${this.searchType}`);
}
makeRequest({ rejectWithError }) {
const endpoint = this.getEndpoint();
return endpoint != null ? HTTP.get({
url: endpoint,
query: Module1464.stringify(this.query),
oldFormErrors: true,
rejectWithError
}) : null;
}
}
export { SearchFetcherImpl };
class SearchTabFetcherImpl extends SearchFetcher {
constructor(a0, a1, a2, a3) {
super(a0, a1, a2);
this.payload = a3;
}
getEndpoint() {
const searchType = this.searchType;
if (SearchTypes.DMS === searchType) {
return Endpoints.SEARCH_TABS_DMS;
}
if (SearchTypes.GUILD_CHANNEL !== searchType && SearchTypes.GUILD !== searchType && SearchTypes.THREAD !== searchType) {
if (SearchTypes.CHANNEL === searchType) {
if (this.searchId != null && this.searchId !== "") {
return Endpoints.SEARCH_TABS_CHANNEL(this.searchId);
}
return void 0;
}
throw new Error(`[SearchFetcher] Unhandled search type: ${this.searchType}`);
}
if (this.searchId != null && this.searchId !== "") {
return Endpoints.SEARCH_TABS_GUILD(this.searchId);
}
}
makeRequest({ rejectWithError }) {
const endpoint = this.getEndpoint();
return endpoint != null ? HTTP.post({
url: endpoint,
body: this.payload,
oldFormErrors: true,
rejectWithError
}) : null;
}
}
export { SearchTabFetcherImpl };
+488
View File
@@ -0,0 +1,488 @@
// Metro module 5875 (f5876).
import AuthenticationStore from "../../stores/AuthenticationStore";
import RelationshipStore from "../../stores/RelationshipStore";
import { APIError } from "../../errors/index";
import { createMessageRecord, updateMessageRecord } from "../messages/MessageRecordUtils";
import { shouldApplyReaction } from "../reactions/ReactionUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c3677_5, c3677_6, c3677_7;
const handleReaction = function handleReaction(a0) {
const { type, messageId, userId, emoji } = a0;
if (shouldApplyReaction(a0)) {
const id = AuthenticationStore.getId();
const r25 = c3677_6.get(messageId);
const r1 = r25 == null;
let r27 = false;
if (!r1) {
const r28 = id === userId;
const reactionType = a0.reactionType;
c3677_6.set(messageId, type === "MESSAGE_REACTION_ADD" ? r25.addReaction(emoji, r28, a0.colors, reactionType) : r25.removeReaction(emoji, r28, reactionType));
r27 = true;
}
return r27;
}
return false;
};
class SearchState {
constructor() {
return {
__proto__: new.target.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
handleSearchStart() {
this.isFetching = true;
this.isIndexing = false;
this.analyticsId = null;
this.error = null;
}
handleSearchIndexing() {
this.isInitialFetchComplete = true;
this.isIndexing = true;
this.isHistoricalIndexing = true;
this.isFetching = false;
this.error = null;
}
handleSearchFailure(a0) {
this.isFetching = false;
this.isIndexing = false;
this.isInitialFetchComplete = true;
this.isHistoricalIndexing = false;
this.error = new APIError(a0);
this.analyticsId = null;
this.documentsIndexed = 0;
}
handleSearchSuccess({ analyticsId, cursor, totalResults, doingHistoricalIndex, documentsIndexed }, a1) {
this.analyticsId = analyticsId;
this.isFetching = false;
this.isIndexing = false;
this.isInitialFetchComplete = true;
this.isHistoricalIndexing = doingHistoricalIndex;
this.error = null;
this.documentsIndexed = documentsIndexed;
this.cursor = cursor;
let messages = this.messages;
if (messages == null) {
messages = [];
}
const messages2 = [...messages];
let c15229_1 = messages2;
const r19 = [];
let c15229_0 = r19;
a1.forEach((item) => {
if (!(this.messageIds.has(item.id) || RelationshipStore.isBlockedOrIgnoredForMessage(item))) {
this.messageIds.add(item.id);
c15229_1.push(item);
c15229_0.push(item);
}
});
this.messages = messages2;
this.totalResults = totalResults;
return r19;
}
}
c3677_5 = new Map();
c3677_6 = new Map();
c3677_7 = new Map();
class SearchMessageStore extends Module589.Store {
static displayName = "SearchMessageStore";
initialize() {
this.waitFor(AuthenticationStore, RelationshipStore);
}
getMessage(a0) {
return c3677_6.get(a0);
}
getTotalCount(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.totalResults;
}
getIsInitialFetchComplete(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.isInitialFetchComplete;
}
getIsIndexing(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.isIndexing;
}
getIsHistoricalIndexing(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.isHistoricalIndexing;
}
getDocumentsIndexed(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.documentsIndexed;
}
getIsFetching(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.isFetching;
}
getError(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.error;
}
getMessages(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.messages;
}
getCursor(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.cursor;
}
getAnalyticsId(a0) {
let r7 = c3677_5.get(a0);
if (r7 == null) {
r7 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
return r7.analyticsId;
}
hasSearchState(a0) {
return c3677_5.has(a0);
}
}
const searchMessageStore = new SearchMessageStore(Dispatcher, {
SEARCH_MESSAGES_START: function handleSearchMessagesStart(a0) {
a0.ids.forEach((id) => {
let r10 = c3677_5.get(id);
if (r10 == null) {
r10 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
c3677_5.set(id, r10);
r10.handleSearchStart();
});
},
SEARCH_MESSAGES_SUCCESS: function handleSearchMessagesSuccess(a0) {
a0.data.forEach((a0) => {
const id = a0.id;
let r4 = c3677_5.get(id);
if (r4 == null) {
r4 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
c3677_5.set(id, r4);
r4.handleSearchSuccess(a0, a0.messages.map((message) => {
const [r18] = message;
return createMessageRecord(r18);
})).forEach((item) => {
c3677_6.set(item.id, item);
let r11 = c3677_7.get(item.id);
if (r11 == null) {
r11 = 0;
}
c3677_7.set(item.id, r11 + 1);
});
});
},
SEARCH_MESSAGES_INDEXING: function handleSearchMessagesIndexing(a0) {
a0.ids.forEach((id) => {
let r10 = c3677_5.get(id);
if (r10 == null) {
r10 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
c3677_5.set(id, r10);
r10.handleSearchIndexing();
});
},
SEARCH_MESSAGES_FAILURE: function handleSearchMessagesFailure(a0) {
a0.ids.forEach((id) => {
let r10 = c3677_5.get(id);
if (r10 == null) {
r10 = {
__proto__: SearchState.prototype,
isIndexing: false,
isHistoricalIndexing: false,
isFetching: false,
analyticsId: null,
error: null,
messages: null,
documentsIndexed: 0,
totalResults: null,
messageIds: new Set(),
isInitialFetchComplete: false,
cursor: null
};
}
c3677_5.set(id, r10);
r10.handleSearchFailure(a0.error);
});
},
SEARCH_MESSAGES_CLEAR: function handleSearchMessagesClear(a0) {
const r6 = c3677_5.get(a0.id);
if (r6 == null) {
return false;
}
r6.messageIds.forEach((messageId) => {
let r6 = c3677_7.get(messageId);
if (r6 == null) {
r6 = 0;
}
if (r6 <= 1) {
c3677_6.delete(messageId);
c3677_7.delete(messageId);
} else {
c3677_7.set(messageId, r6 - 1);
}
});
c3677_5.delete(a0.id);
},
SEARCH_MESSAGES_CLEAR_ALL: function handleSearchMessagesClearAll() {
c3677_5 = new Map();
c3677_6 = new Map();
c3677_7 = new Map();
},
MESSAGE_UPDATE: function handleMessageUpdate(a0) {
const id = a0.message.id;
if (id == null) {
return false;
}
const r6 = c3677_6.get(id);
if (r6 == null) {
return false;
}
c3677_6.set(id, updateMessageRecord(r6, a0.message));
},
MESSAGE_REACTION_ADD: handleReaction,
MESSAGE_REACTION_ADD_MANY: function handleReactionBatch({ messageId, reactions }) {
const id = AuthenticationStore.getId();
const r11 = c3677_6.get(messageId);
const r1 = r11 == null;
let r12 = false;
if (!r1) {
c3677_6.set(messageId, r11.addReactionBatch(reactions, id));
r12 = true;
}
return r12;
},
MESSAGE_REACTION_REMOVE: handleReaction,
MESSAGE_REACTION_REMOVE_ALL: function handleRemoveAllReactions({ messageId }) {
const r7 = c3677_6.get(messageId);
const r1 = r7 == null;
let r9 = false;
if (!r1) {
c3677_6.set(messageId, r7.set("reactions", []));
r9 = true;
}
return r9;
},
MESSAGE_REACTION_REMOVE_EMOJI: function handleRemoveEmojiReactions({ messageId, emoji }) {
const r8 = c3677_6.get(messageId);
const r1 = r8 == null;
let r9 = false;
if (!r1) {
c3677_6.set(messageId, r8.removeReactionsForEmoji(emoji));
r9 = true;
}
return r9;
},
CONNECTION_OPEN: function handleConnectionOpen() {
c3677_5 = new Map();
c3677_6 = new Map();
c3677_7 = new Map();
}
});
export default searchMessageStore;
@@ -0,0 +1,54 @@
// Metro module 10106 (f10107).
import { createMessageRecord } from "../messages/MessageRecordUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c6726_2, c6726_3;
const handleReset = function handleReset() {
c6726_2 = new Map();
};
c6726_2 = new Map();
c6726_3 = [];
class SearchRecentMessageStore extends Module589.Store {
static displayName = "SearchRecentMessageStore";
getRecentMessageAuthorIds(a0) {
let r5 = c6726_2.get(a0);
if (r5 == null) {
r5 = c6726_3;
}
return r5;
}
}
const searchRecentMessageStore = new SearchRecentMessageStore(Dispatcher, {
SEARCH_MESSAGES_SUCCESS: function handleSearchMessagesSuccess({ guildId, data }) {
if (guildId == null) {
return false;
}
let c17701_0 = false;
let r16 = c6726_2.get(guildId);
if (r16 == null) {
r16 = [];
}
const r17 = [...r16];
let c17701_1 = r17;
let c17701_2 = new Set(r17);
data.forEach((item) => {
item.messages.forEach((message) => {
const [r7] = message;
const messageRecord = createMessageRecord(r7);
const r33 = c17701_2.has(messageRecord.author.id);
if (r33 ? !r33 : c17701_2.size < 15) {
c17701_2.add(messageRecord.author.id);
c17701_1.push(messageRecord.author.id);
c17701_0 = true;
}
});
});
if (c17701_0) {
c6726_2.set(guildId, r17);
}
return c17701_0;
},
SEARCH_RECENT_MESSAGES_CLEAR: handleReset,
CONNECTION_OPEN: handleReset
});
export default searchRecentMessageStore;
+576
View File
@@ -0,0 +1,576 @@
// Metro module 10103 (f10104).
import ChannelStore from "../../stores/ChannelStore";
import GuildChannelStore from "../../stores/GuildChannelStore";
import GuildNSFWAgreeStore from "../../stores/GuildNSFWAgreeStore";
import RelationshipStore from "../../stores/RelationshipStore";
import "../../stores/SelectedChannelStore";
import UserStore from "../../stores/UserStore";
import { SearchTabs } from "./SearchConstants";
import { IS_SEARCH_ANSWER_TOKEN, IS_SEARCH_FILTER_TOKEN, SearchModes, SearchPopoutModes, SearchTokenTypes, SearchTypes, ME } from "../../Constants";
import Module3771 from "../../_bundle/Module3771";
import { intl, t } from "../../intl/index.native";
import SearchTokens, { isSearchFilterTokenType, rebuildSearchTokenConfigs, buildCrossDMSearchTokensConfig } from "./tokens/SearchTokens";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import QueryTokenizer from "../../lib/QueryTokenizer";
import Module12 from "../../_bundle/Module12";
import SearchActionCreators from "./SearchActionCreators";
import { computeChannelName } from "../channel/useChannelName";
import UserUtils from "../../utils/UserUtils";
function $mk83946() {
return (a0, a1) => `\\${a1}`;
}
ME;
let c6723_16 = 2592000;
let c6723_17 = 31536000;
const r45 = {};
r45[SearchTokenTypes.FILTER_BEFORE] = true;
r45[SearchTokenTypes.FILTER_AFTER] = true;
r45[SearchTokenTypes.FILTER_ON] = true;
let c6723_18 = r45;
let c6723_19 = new QueryTokenizer();
let c6723_20 = new QueryTokenizer();
export function getSearchContextId(a0) {
const type = a0.type;
if (SearchTypes.GUILD === type) {
return a0.guildId;
}
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type && SearchTypes.THREAD !== type) {
if (SearchTypes.DMS === type) {
return a0.type;
}
return void 0;
}
return a0.channelId;
}
export function getSearchHistoryStateId(a0) {
let guildId;
L8: {
const type = a0.type;
if (SearchTypes.GUILD === type) {
guildId = a0.guildId;
} else {
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type && SearchTypes.THREAD !== type) {
const DMS = SearchTypes.DMS;
guildId = void 0;
if (DMS !== type) {
break L8;
}
guildId = a0.type;
break L8;
}
guildId = a0.channelId;
}
}
return guildId;
}
export function getSearchTabFetchId(a0, a1, a2) {
let guildId;
L8: {
const type = a0.type;
if (SearchTypes.GUILD === type) {
guildId = a0.guildId;
} else {
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type && SearchTypes.THREAD !== type) {
const DMS = SearchTypes.DMS;
guildId = void 0;
if (DMS !== type) {
break L8;
}
guildId = a0.type;
break L8;
}
guildId = a0.channelId;
}
}
return `${guildId}-${a1}-${a2}`;
}
export function getChannelActiveAgoTimestamp(a0) {
const r19 = Module3771().diff(Module3771(a0), "s");
if (r19 > c6723_17) {
return intl.formatToPlainString(t["7th+Mf"], {
count: Math.round(r19 / c6723_17)
});
}
if (r19 > c6723_16) {
return intl.formatToPlainString(t.g2uHTD, {
count: Math.round(r19 / c6723_16)
});
}
if (r19 > 172800) {
return intl.formatToPlainString(t.HNgi95, {
count: Math.round(r19 / 86400)
});
}
if (r19 > 86400) {
return intl.string(t.uNkIhT);
}
if (r19 > 3600) {
return intl.formatToPlainString(t.WJBWP1, {
count: Math.round(r19 / 3600)
});
}
if (r19 > 60) {
return intl.formatToPlainString(t.CbRfwg, {
count: Math.round(r19 / 60)
});
}
return intl.string(t["5Ldpkc"]);
}
export function getIndexingErrorText({ type }) {
if (SearchTypes.CHANNEL === type) {
return intl.string(t.Q0JJjv);
}
if (SearchTypes.DMS === type) {
return intl.string(t.Br0xJA);
}
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.GUILD !== type && SearchTypes.THREAD !== type) {
return void 0;
}
return intl.string(t.AXPbZr);
}
export function getGuildIdFromSearchContext(a0) {
const type = a0.type;
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.GUILD !== type && SearchTypes.THREAD !== type) {
if (SearchTypes.CHANNEL === type) {
let r15 = ChannelStore.getChannel(a0.channelId)?.guild_id;
if (r15 == null) {
r15 = null;
}
return r15;
}
return null;
}
return a0.guildId;
}
export function isGuildLikeSearchContext(a0) {
return a0.type === SearchTypes.GUILD || a0.type === SearchTypes.GUILD_CHANNEL || a0.type === SearchTypes.THREAD;
}
export function getChannelIdFromSearchContext(a0) {
const type = a0.type;
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type && SearchTypes.THREAD !== type) {
return null;
}
return a0.channelId;
}
export function getTabTitle(a0) {
if (SearchTabs.RECENT === a0) {
return intl.string(t.tWnHcL);
}
if (SearchTabs.MESSAGES === a0) {
return intl.string(t.dvZAkp);
}
if (SearchTabs.PEOPLE === a0) {
return intl.string(t["GFd/I5"]);
}
if (SearchTabs.MEDIA === a0) {
return intl.string(t["Aw9+/M"]);
}
if (SearchTabs.PINS === a0) {
return intl.string(t["/MoGoB"]);
}
if (SearchTabs.LINKS === a0) {
return intl.string(t.DFSvTt);
}
if (SearchTabs.FILES === a0) {
return intl.string(t["WgVYR/"]);
}
if (SearchTabs.GUILD_CHANNELS === a0) {
return intl.string(t.OGiMXJ);
}
if (SearchTabs.MEMBERS === a0) {
return intl.string(t["9Oq93m"]);
}
if (SearchTabs.THREADS === a0) {
return intl.string(t.B2panI);
}
}
export function searchModeToSearchQueryParams(a0) {
if (SearchModes.MOST_RELEVANT === a0) {
return {
sort_by: "relevance",
sort_order: "desc"
};
}
if (SearchModes.OLDEST === a0) {
return {
sort_by: "timestamp",
sort_order: "asc"
};
}
SearchModes.NEWEST;
return {
sort_by: "timestamp",
sort_order: "desc"
};
}
export function searchQueryParamsToSearchMode(a0) {
let MOST_RELEVANT;
L10: {
if (a0.sort_by != null && a0.sort_order != null) {
if (a0.sort_by === "relevance") {
MOST_RELEVANT = SearchModes.MOST_RELEVANT;
break L10;
}
if (a0.sort_order === "asc") {
MOST_RELEVANT = SearchModes.OLDEST;
break L10;
}
MOST_RELEVANT = SearchModes.NEWEST;
} else {
MOST_RELEVANT = SearchModes.NEWEST;
}
}
return MOST_RELEVANT;
}
export function getSearchOptionAnswer(a0) {
if (SearchTokenTypes.FILTER_FROM === a0) {
return intl.string(t.E466pL);
}
if (SearchTokenTypes.FILTER_MENTIONS === a0) {
return intl.string(t.BYvFWl);
}
if (SearchTokenTypes.FILTER_HAS === a0) {
return intl.string(t.bhSYbc);
}
if (SearchTokenTypes.FILTER_BEFORE !== a0 && SearchTokenTypes.FILTER_ON !== a0 && SearchTokenTypes.FILTER_AFTER !== a0) {
if (SearchTokenTypes.FILTER_IN === a0) {
return intl.string(t["GpM+/7"]);
}
if (SearchTokenTypes.FILTER_LINK_FROM === a0) {
return intl.string(t.FdDTni);
}
if (SearchTokenTypes.FILTER_FILE_TYPE === a0) {
return intl.string(t.FXcAFe);
}
if (SearchTokenTypes.FILTER_FILE_NAME === a0) {
return intl.string(t.uAbFDM);
}
if (SearchTokenTypes.FILTER_PINNED === a0) {
return intl.string(t.UJxL3V);
}
if (SearchTokenTypes.FILTER_AUTHOR_TYPE === a0) {
return intl.string(t.qCQzBl);
}
return void 0;
}
return intl.string(t.Zbbc1E);
}
export { c6723_18 as ShowDatePicker };
export function setIncludeNSFW(a0, a1) {
if (GuildNSFWAgreeStore.didAgree(a1)) {
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
return void 0;
}
a0.include_nsfw = currentUser.nsfwAllowed == null || currentUser.nsfwAllowed;
}
}
export function getSearchQueryFromTokens(a0) {
const r0 = {};
let c17687_0 = r0;
a0.forEach((a0) => {
L32: {
const type = a0.type;
if (!IS_SEARCH_FILTER_TOKEN.test(type)) {
if (SearchTokenTypes.ANSWER_BEFORE !== type && SearchTokenTypes.ANSWER_ON !== type && SearchTokenTypes.ANSWER_AFTER !== type) {
const r7 = (function getQueryKey(a0) {
const r8 = SearchTokens[a0];
let r10 = r8 != null ? r8.queryKey : null;
if (r10 == null) {
r10 = "content";
}
return r10;
})(type);
if (c17687_0[r7] == null) {
c17687_0[r7] = new Set();
}
const r33 = c17687_0[r7];
if (SearchTokenTypes.ANSWER_USERNAME_FROM !== type && SearchTokenTypes.ANSWER_USERNAME_MENTIONS !== type) {
if (SearchTokenTypes.ANSWER_LINK_FROM !== type && SearchTokenTypes.ANSWER_FILE_TYPE !== type && SearchTokenTypes.ANSWER_FILE_NAME !== type) {
if (SearchTokenTypes.ANSWER_IN !== type) {
if (SearchTokenTypes.ANSWER_HAS === type) {
r33.add(a0.getData("has"));
break L32;
}
if (SearchTokenTypes.ANSWER_PINNED === type) {
r33.add(a0.getData("pinned"));
break L32;
}
if (SearchTokenTypes.ANSWER_AUTHOR_TYPE === type) {
r33.add(a0.getData("author_type"));
break L32;
}
r33.add(a0.getFullMatch().trim());
break L32;
}
let r66 = a0.getData("channelIds");
if (r66 == null) {
r66 = [];
}
for (const item of r66) {
r33.add(item);
}
break L32;
}
r33.add(a0.getMatch(1));
break L32;
}
r33.add(a0.getData("userId"));
break L32;
}
const data = a0.getData("start");
const data2 = a0.getData("end");
if (data) {
c17687_0.min_id = SnowflakeUtils.fromTimestamp(data);
}
if (data2) {
c17687_0.max_id = SnowflakeUtils.fromTimestamp(data2);
}
return void 0;
}
}
});
for (const item of Object.entries(r0)) {
const [r37, r38] = item;
if (r38 instanceof Set) {
r0[r37] = Array.from(r38);
}
}
if (r0.content) {
delete r0["contents"];
r0.content = r0.content.join(" ").trim();
if (!r0.content) {
delete r0["content"];
}
}
return r0;
}
export function getQueryContentString(a0) {
let r12;
if (a0?.contents != null && a0.contents.length > 0) {
const r13 = a0 == null;
let r5 = void 0;
if (!r13) {
const contents = a0.contents;
r5 = contents == null ? void 0 : contents.map((content) => content.split("|").slice(1).join("|")).join(" ");
}
r12 = r5;
} else {
r12 = a0?.content;
}
return r12;
}
export function getNonTokenQuery(a0) {
return a0.map((item) => item.type === QueryTokenizer.NON_TOKEN_TYPE ? item.getFullMatch() : "").join(" ").trim();
}
export function getSelectionScope(a0, a1, a2) {
let previousToken, nextToken;
const currentToken = a0.find((item, index) => {
let r1;
L7: {
if (a1 >= item.start && a1 <= item.end) {
if (a2 >= item.start && a2 <= item.end) {
const r3 = a0[index + 1] != null;
r1 = true;
if (!r3) {
break L7;
}
nextToken = a0[index + 1];
r1 = true;
} else {
previousToken = item;
r1 = false;
}
} else {
previousToken = item;
r1 = false;
}
}
return r1;
});
return currentToken != null ? {
previousToken,
currentToken,
nextToken,
focusOffset: a1,
anchorOffset: a2
} : null;
}
export function getAutocompleteMode(a0, a1) {
const r7 = a0 == null ? {} : a0;
const { currentToken, nextToken: nextToken2, previousToken: previousToken2 } = r7;
if (a1.length === 0) {
return {
type: SearchPopoutModes.EMPTY,
filter: null,
token: null
};
}
if (currentToken == null) {
return {
type: SearchPopoutModes.FILTER_ALL,
filter: null,
token: null
};
}
L10: {
if (isSearchFilterTokenType(currentToken.type)) {
if (nextToken2 != null && nextToken2.type !== QueryTokenizer.NON_TOKEN_TYPE) {
if (nextToken2 == null) {
break L10;
}
if (IS_SEARCH_ANSWER_TOKEN.test(nextToken2.type)) {
break L10;
}
return {
type: SearchPopoutModes.FILTER,
filter: currentToken.type,
token: null
};
}
return {
type: SearchPopoutModes.FILTER,
filter: currentToken.type,
token: nextToken2
};
}
}
return currentToken.type === QueryTokenizer.NON_TOKEN_TYPE && (previousToken2 != null && isSearchFilterTokenType(previousToken2.type)) ? {
type: SearchPopoutModes.FILTER,
filter: previousToken2.type,
token: currentToken
} : {
type: SearchPopoutModes.FILTER_ALL,
filter: null,
token: currentToken.type === QueryTokenizer.NON_TOKEN_TYPE ? currentToken : void 0
};
}
export function quoteChannelName(a0) {
return a0.match(/([\\" ])/g) != null ? `"${a0.replaceAll.call(a0, /([\\"])/g, $mk83946())}"` : a0;
}
export function getFlattenedAutocompleteResults(a0, c17689_0) {
let c17689_1 = [];
Module12(a0).forEach((item) => {
let group;
if (item != null && item.results.length !== 0) {
group = item.group;
c17689_1 = c17689_1.concat(item.results.map((a0) => {
const text = a0.text;
const r10 = a0.channel != null ? text.match(/([\\" ])/g) != null ? `"${text.replaceAll(/([\\"])/g, $mk83946())}"` : text : text;
const type = c17689_0.type;
const FILTER_ALL = SearchPopoutModes.FILTER_ALL;
let resultText = r10;
if (type === FILTER_ALL) {
let group2 = a0.group;
if (group2 == null) {
group2 = group;
}
group = group2;
const r34 = SearchTokens[group];
resultText = r34?.key != null && r34?.key !== "" ? `${r34.key} ${r10}` : r10;
}
return {
result: a0,
group: item.group,
resultText
};
}));
}
});
return c17689_1.filter((item) => item.resultText !== "");
}
export function getQueryFromTokens(a0) {
return a0 == null ? "" : a0.map((item) => item.getFullMatch()).join("");
}
export function queryHasFilter(a0, c17690_0) {
return c6723_19.tokenize(a0).some((item) => item.type === c17690_0);
}
export function tokenizeQuery(a0) {
return c6723_19.tokenize(a0);
}
export function clearTokenCache() {
c6723_19.clearCache();
c6723_20.clearCache();
}
export function showDatePicker(a0) {
return a0 != null ? c6723_18[a0] : null;
}
export function filterHasAnswer(a0, a1) {
const r7 = IS_SEARCH_FILTER_TOKEN.test(a0.type);
return !(a1 == null && r7 || a1 != null && r7 && !IS_SEARCH_ANSWER_TOKEN.test(a1.type));
}
export function refreshSearchTokens() {
rebuildSearchTokenConfigs();
c6723_19.reset();
Module12(SearchTokens).forOwn((a0, a1) => c6723_19.addRule({
type: a1,
...a0
}));
c6723_20.reset();
Module12(buildCrossDMSearchTokensConfig()).forOwn((a0, a1) => c6723_20.addRule({
type: a1,
...a0
}));
SearchActionCreators.markSearchTokensRefreshed();
}
export function getChannelDisplayName(a0) {
let r0, r20;
const r12 = computeChannelName(a0, UserStore, RelationshipStore);
if (a0.isDM()) {
const userTag = UserUtils.getUserTag(UserStore.getUser(a0.getRecipientId()));
const r40 = userTag == null;
r0 = false;
r20 = userTag;
if (r40) {
return null;
}
} else {
const isGroupDM = a0.isGroupDM();
r0 = false;
r20 = r12;
if (!isGroupDM) {
const r2 = !a0.isThread();
const r28 = GuildChannelStore.getTextChannelNameDisambiguations(a0.getGuildId())[a0.id];
const name = r28?.name;
r0 = r2;
r20 = r12;
if (name != null) {
r20 = r28.name;
r0 = r2;
}
}
}
const r43 = r20.match(/([\\" ])/g);
const r45 = r20;
const r46 = r43 != null ? `"${r45.replaceAll(/([\\"])/g, $mk83946())}"` : r45;
return r0 ? `#${r46}` : r46;
}
export function getChannelPlaceholderName(a0) {
if (a0.isGroupDM()) {
return computeChannelName(a0, UserStore, RelationshipStore);
}
if (a0.isDM()) {
return UserUtils.getUserTag(UserStore.getUser(a0.getRecipientId()));
}
let r18 = GuildChannelStore.getTextChannelNameDisambiguations(a0.getGuildId())[a0.id]?.name;
if (r18 == null) {
r18 = computeChannelName(a0, UserStore, RelationshipStore);
}
return r18;
}
export function removeInvalidPrivateChannelSearchTokens(a0) {
let c17691_1;
const r4 = c6723_20.tokenize(a0);
const r6 = [];
let c17691_0 = r6;
r4.forEach((item) => {
if (!(item.type === SearchTokenTypes.FILTER_IN || item.type === SearchTokenTypes.ANSWER_IN)) {
c17691_0.push(item);
}
});
c17691_1 = "";
r6.forEach((item) => {
c17691_1 = c17691_1 + item.getFullMatch();
});
return c17691_1.trim();
}
+158
View File
@@ -0,0 +1,158 @@
// Metro module 14711 (f14712).
const calculateJaroWinklerDistance = function calculateJaroWinklerDistance(a0, a1) {
let r48, r82, r110, length2, length4, length6, length7;
const r1 = Math.floor(Math.max(a0.length, a1.length) / 2) - 1;
const r30 = [];
const r12 = 0 < a0.length;
let r2 = 0;
let r32 = 0;
let r10 = 0;
if (r12) {
do {
let r35 = Math.max(0, r2 - r1);
const r36 = Math;
const length = a1.length;
const r6 = r2 + r1;
const r39 = r36.min(length, r6);
const r40 = r2;
const r5 = r32;
let r4 = r5;
if (r35 <= r39) {
do {
const r41 = a0[r40];
const r42 = a1[r35];
const r43 = r35;
if (r41 === r42 && !r30[r43]) {
r30[r43] = true;
r4 = r5 + 1;
break;
}
r35 = r43 + 1;
r48 = Math.min(a1.length, r6);
r4 = r5;
} while (r35 <= r48);
}
r2 = r40 + 1;
length2 = a0.length;
r32 = r4;
r10 = r32;
} while (r2 < length2);
}
if (!(0 < r10)) {
return 0;
}
const r59 = Math.floor(Math.max(a0.length, a1.length) / 2) - 1;
const r60 = [];
const r62 = 0 < a0.length;
let r64 = "";
let r65 = 0;
let r66 = "";
if (r62) {
do {
let r23 = Math.max(0, r65 - r59);
const r24 = Math;
const length3 = a1.length;
const r72 = r65 + r59;
const r73 = r24.min(length3, r72);
const r74 = r64;
const r75 = r65;
let r76 = r74;
if (r23 <= r73) {
do {
const r26 = a0[r75];
const r25 = a1[r23];
const r77 = r23;
if (r26 === r25 && !r60[r77]) {
r76 = r74 + a0[r75];
r60[r77] = true;
break;
}
r23 = r77 + 1;
r82 = Math.min(a1.length, r72);
r76 = r74;
} while (r23 <= r82);
}
r65 = r75 + 1;
length4 = a0.length;
r64 = r76;
r66 = r64;
} while (r65 < length4);
}
const r84 = [];
const r86 = 0 < a1.length;
let r87 = "";
let r88 = 0;
let r89 = "";
if (r86) {
do {
let r93 = Math.max(0, r88 - r59);
const r94 = Math;
const length5 = a0.length;
const r97 = r88 + r59;
const r98 = r94.min(length5, r97);
const r99 = r87;
const r100 = r88;
let r101 = r99;
if (r93 <= r98) {
do {
const r102 = a1[r100];
const r103 = a0[r93];
const r104 = r93;
if (r102 === r103 && !r84[r104]) {
r101 = r99 + a1[r100];
r84[r104] = true;
break;
}
r93 = r104 + 1;
r110 = Math.min(a0.length, r97);
r101 = r99;
} while (r93 <= r110);
}
r88 = r100 + 1;
length6 = a1.length;
r87 = r101;
r89 = r87;
} while (r88 < length6);
}
const r113 = 0 < r66.length;
let r114 = 0;
let r115 = 0;
let r116 = 0;
if (r113) {
do {
const r117 = r66[r114];
const r118 = r89[r114];
const r119 = r114;
const r120 = r115;
const r121 = r117 !== r118 ? r120 + 1 : r120;
r114 = r119 + 1;
length7 = r66.length;
r115 = r121;
r116 = r115;
} while (r114 < length7);
}
const r136 = (r10 / a0.length + r10 / a1.length + (r10 - Math.floor(r116 / 2)) / r10) / 3;
let r139 = 0;
if (r136 < 0.7) {
return r136;
}
while (true) {
const r140 = a0[r139];
const r141 = a1[r139];
const r142 = r139;
let r143 = r142;
if (r140 === r141) {
const r144 = r142 + 1;
r139 = r144;
if (r139 < 4) {
continue;
}
r143 = r144 + 1;
}
return r136 + 0.1 * r143 * (1 - r136);
}
};
export function calculateJaroWinklerSimilarity(a0, a1, a2) {
const caseSensitive = (a2 == null ? {} : a2).caseSensitive;
return caseSensitive !== void 0 && caseSensitive ? calculateJaroWinklerDistance(a0, a1) : calculateJaroWinklerDistance(a0.toLowerCase(), a1.toLowerCase());
}
@@ -0,0 +1,24 @@
// Metro module 16170 (f16171).
import { createApexExperiment } from "../../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2025-05-search-results-feedback",
kind: "user",
defaultConfig: {
enabled: false
},
variations: {
1: {
enabled: true
}
}
});
export function useIsSearchResultsFeedbackExperimentEnabled(a0) {
return apexExperiment.useConfig({
location: a0.location
}).enabled;
}
export function getIsSearchResultsFeedbackExperimentEnabled(a0) {
return apexExperiment.getConfig({
location: a0.location
}).enabled;
}
@@ -0,0 +1,28 @@
// Metro module 10112 (f10113).
export class AbstractSearchFetchManager {
constructor() {
return {
__proto__: new.target.prototype,
searchFetchers: new Map()
};
}
cleanUp(a0) {
this.cancel(a0);
this.delete(a0);
}
cancel(a0) {
const r5 = this.searchFetchers.get(a0);
if (r5 != null) {
r5.cancel();
}
}
delete(a0) {
this.searchFetchers.delete(a0);
}
get(a0) {
return this.searchFetchers.get(a0);
}
set(a0, a1) {
this.searchFetchers.set(a0, a1);
}
}
@@ -0,0 +1,80 @@
// Metro module 10117 (f10118).
import { v4 } from "../../../_bundle/Module514";
import { getSearchContextId } from "../SearchUtils";
class AbstractSearchSessionAnalyticsManager {
constructor() {
return {
__proto__: new.target.prototype,
sessions: new Map()
};
}
getSession(a0) {
let r12 = this.sessions.get(getSearchContextId(a0));
if (r12 == null) {
r12 = null;
}
return r12;
}
setSession(a0, a1) {
const searchContextId = getSearchContextId(a0);
let r15 = this.sessions.get(searchContextId);
if (r15 == null) {
r15 = {
sessionId: v4(),
searchQueryId: null
};
}
this.sessions.set(searchContextId, {
...r15,
...a1
});
}
deleteSession(a0) {
this.sessions.delete(getSearchContextId(a0));
}
getSessionId(a0) {
let r6 = this.getSession(a0)?.sessionId;
if (r6 == null) {
r6 = null;
}
return r6;
}
getQueryId(a0) {
let r6 = this.getSession(a0)?.searchQueryId;
if (r6 == null) {
r6 = null;
}
return r6;
}
refreshQueryId(a0) {
this.setSession(a0, {
searchQueryId: v4()
});
}
initialize(a0) {
this._initialize.apply(this, [a0, ...Array.prototype.slice.call(arguments, 1)]);
this.setSession(a0, {
sessionId: v4(),
searchQueryId: null
});
}
terminate(a0) {
this._terminate(a0);
this.deleteSession(a0);
}
transferSession(a0, a1) {
this._transferSession(a0, a1);
let r14 = this.getSession(a0);
const sessions = this.sessions;
const searchContextId = getSearchContextId(a1);
if (r14 == null) {
r14 = {
sessionId: v4(),
searchQueryId: null
};
}
sessions.set(searchContextId, r14);
this.deleteSession(a0);
}
}
export default AbstractSearchSessionAnalyticsManager;
@@ -0,0 +1,13 @@
// Metro module 10114 (f10115).
import { AbstractSearchFetchManager } from "./AbstractSearchFetchManager";
import { SearchFetcherImpl } from "../SearchFetcher";
class SearchFetchManager extends AbstractSearchFetchManager {
create({ id, searchType, searchQuery }) {
this.cancel(id);
const searchFetcherImpl = new SearchFetcherImpl(id, searchType, searchQuery);
this.set(id, searchFetcherImpl);
return searchFetcherImpl;
}
}
const searchFetchManager = new SearchFetchManager();
export default searchFetchManager;
@@ -0,0 +1,68 @@
// Metro module 10111 (f10112).
import _objectWithoutProperties from "../../../_bundle/_objectWithoutProperties";
import { SEARCH_FILTERS_BY_TAB, SEARCH_QUERY_BY_SEARCH_FILTER, SEARCH_QUERY_DEFAULT_FILTERS } from "../SearchConstants";
import { SearchTypes } from "../../../Constants";
import { AbstractSearchFetchManager } from "./AbstractSearchFetchManager";
import { SearchTabFetcherImpl } from "../SearchFetcher";
const _excluded = ["include_nsfw", "channel_id"];
class SearchTabsFetchManager extends AbstractSearchFetchManager {
createRequestPayload({ searchQuery, searchTabs, getLimit, pagination, trackExactTotalHits }) {
const { include_nsfw, channel_id } = searchQuery;
let c17706_2 = _objectWithoutProperties(searchQuery, _excluded);
const r14 = {
include_nsfw,
channel_ids: channel_id,
tabs: {},
track_exact_total_hits: trackExactTotalHits
};
let c17706_3 = r14;
searchTabs.forEach((searchTab) => {
const limit = getLimit(searchTab);
const r3 = SEARCH_FILTERS_BY_TAB[searchTab];
c17706_3.tabs[searchTab] = {
...SEARCH_QUERY_DEFAULT_FILTERS,
...r3 != null ? SEARCH_QUERY_BY_SEARCH_FILTER[r3] : {},
...c17706_2,
...pagination,
limit
};
});
return r14;
}
createWithPayload(a0) {
const { searchContext, searchQuery } = a0;
const requestPayload = this.createRequestPayload({
searchQuery,
searchTabs: a0.searchTabs,
getLimit: a0.getLimit,
pagination: a0.pagination,
trackExactTotalHits: a0.trackExactTotalHits
});
const type = searchContext.type;
if (SearchTypes.GUILD !== type && SearchTypes.GUILD_CHANNEL !== type && SearchTypes.THREAD !== type) {
if (SearchTypes.CHANNEL === type) {
return new SearchTabFetcherImpl(searchContext.channelId, searchContext.type, searchQuery, requestPayload);
}
if (SearchTypes.DMS === type) {
return new SearchTabFetcherImpl(searchContext.type, searchContext.type, searchQuery, requestPayload);
}
throw new Error(`[SearchFetchManager] Unsupported search context type: ${searchContext.type}`);
}
return new SearchTabFetcherImpl(searchContext.guildId, searchContext.type, searchQuery, requestPayload);
}
create({ id, searchContext, searchQuery, searchTabs, getLimit: getLimit2, pagination: pagination2, trackExactTotalHits }) {
this.cancel(id);
const withPayload = this.createWithPayload({
searchContext,
searchQuery,
searchTabs,
getLimit: getLimit2,
pagination: pagination2,
trackExactTotalHits
});
this.set(id, withPayload);
return withPayload;
}
}
const searchTabsFetchManager = new SearchTabsFetchManager();
export default searchTabsFetchManager;
@@ -0,0 +1,21 @@
// Metro module 16313 (f16314).
import { subscribeToIntlLoadingSuccess } from "../../../intl/IntlLoaderStore";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
import { refreshSearchTokens } from "../SearchUtils";
class SearchTokensManager extends AutomaticLifecycleManager {
actions = {
USER_SETTINGS_PROTO_UPDATE: refreshSearchTokens,
POST_CONNECTION_OPEN: refreshSearchTokens
};
_initialize() {
this._unsubscribeIntlLoadingStore = subscribeToIntlLoadingSuccess(refreshSearchTokens);
}
_terminate() {
const _unsubscribeIntlLoadingStore = this._unsubscribeIntlLoadingStore;
if (_unsubscribeIntlLoadingStore != null) {
_unsubscribeIntlLoadingStore.call(this);
}
}
}
const searchTokensManager = new SearchTokensManager();
export default searchTokensManager;
@@ -0,0 +1,28 @@
// Metro module 10116 (f10117).
import { SEARCH_TAB_TO_ANALYTICS_SEARCH_TAB } from "../../native/tracking/TrackingConstants";
import AbstractSearchSessionAnalyticsManager from "../AbstractSearchSessionAnalyticsManager";
import { getSearchContextId } from "../../SearchUtils";
class SearchSessionAnalyticsManager extends AbstractSearchSessionAnalyticsManager {
locations = new Map();
selectedTabs = new Map();
_initialize(a0, a1) {
this.locations.set(getSearchContextId(a0), a1);
}
_terminate(a0) {
const searchContextId = getSearchContextId(a0);
this.locations.delete(searchContextId);
this.selectedTabs.delete(searchContextId);
}
_transferSession() {}
getLocation(a0) {
return this.locations.get(getSearchContextId(a0));
}
getSelectedTab(a0) {
return this.selectedTabs.get(getSearchContextId(a0));
}
setSelectedTab(a0, a1) {
this.selectedTabs.set(getSearchContextId(a0), SEARCH_TAB_TO_ANALYTICS_SEARCH_TAB[a1]);
}
}
const searchSessionAnalyticsManager = new SearchSessionAnalyticsManager();
export default searchSessionAnalyticsManager;
@@ -0,0 +1,95 @@
// Metro module 11460 (f11461).
import { SearchTypes } from "../../../Constants";
import "./stores/SearchTabsLayoutStore";
import "./stores/SearchQueryStore";
import { getSearchContextId } from "../SearchUtils";
import Dispatcher from "../../../Dispatcher";
const r20 = {
searchPeopleTab: function searchPeopleTab(a0, a1) {
Dispatcher.dispatch({
type: "SEARCH_PEOPLE_TAB_SEARCH",
id: getSearchContextId(a0),
searchQueryString: a1
});
},
cleanupPeopleTab: function cleanupPeopleTab(a0) {
Dispatcher.dispatch({
type: "SEARCH_PEOPLE_TAB_CLEANUP",
id: getSearchContextId(a0)
});
},
searchGuildMemberTab: function searchGuildMemberTab({ searchContext, searchQueryString, guildId, channelId, threadId }) {
Dispatcher.dispatch({
type: "SEARCH_GUILD_MEMBER_TAB_SEARCH",
id: getSearchContextId(searchContext),
searchQueryString,
guildId,
channelId,
threadId
});
},
cleanupGuildMemberTab: function cleanupGuildMemberTab(a0) {
Dispatcher.dispatch({
type: "SEARCH_GUILD_MEMBER_TAB_CLEANUP",
id: getSearchContextId(a0)
});
},
searchGuildChannelTab: function searchGuildChannelTab({ searchContext, searchQueryString, guildId }) {
Dispatcher.dispatch({
type: "SEARCH_GUILD_CHANNEL_TAB_SEARCH",
id: getSearchContextId(searchContext),
searchQueryString,
guildId
});
},
cleanupGuildChannelTab: function cleanupGuildChannelTab(a0) {
Dispatcher.dispatch({
type: "SEARCH_GUILD_CHANNEL_TAB_CLEANUP",
id: getSearchContextId(a0)
});
},
addSearchHistoryItem: function addSearchHistoryItem(a0, a1) {
if (!(a0.type !== SearchTypes.DMS && a0.type !== SearchTypes.GUILD)) {
Dispatcher.dispatch({
type: "SEARCH_HISTORY_NATIVE_ADD_ITEM",
id: getSearchContextId(a0),
item: a1
});
}
},
removeSearchHistoryItem: function removeSearchHistoryItem(a0, a1) {
Dispatcher.dispatch({
type: "SEARCH_HISTORY_NATIVE_REMOVE_ITEM",
id: getSearchContextId(a0),
item: a1
});
},
clearSearchHistory: function clearSearchHistory(a0) {
Dispatcher.dispatch({
type: "SEARCH_HISTORY_NATIVE_CLEAR_ITEMS",
id: getSearchContextId(a0)
});
},
updateSearchQuery: function updateSearchQuery(a0, a1) {
Dispatcher.dispatch({
type: "SEARCH_QUERY_NATIVE_UPDATE",
id: getSearchContextId(a0),
searchContext: a0,
updater: a1
});
},
deleteSearchQuery: function deleteSearchQuery(a0) {
Dispatcher.dispatch({
type: "SEARCH_QUERY_NATIVE_DELETE",
id: getSearchContextId(a0)
});
},
initializeSearchQuery: function initializeSearchQuery(a0) {
Dispatcher.dispatch({
type: "SEARCH_QUERY_NATIVE_INITIALIZE",
id: getSearchContextId(a0),
searchContext: a0
});
}
};
export default r20;
@@ -0,0 +1,26 @@
// Metro module 11453 (f11454).
import { LINKING_WHITELIST } from "../../links/native/LinkingWhitelist";
import { TiktokNeutralIcon } from "../../../design/components/Icon/native/redesign/generated/TiktokNeutralIcon";
import { TwitterNeutralIcon } from "../../../design/components/Icon/native/redesign/generated/TwitterNeutralIcon";
import { InstagramNeutralIcon } from "../../../design/components/Icon/native/redesign/generated/InstagramNeutralIcon";
import { FacebookNeutralIcon } from "../../../design/components/Icon/native/redesign/generated/FacebookNeutralIcon";
import { YoutubeNeutralIcon } from "../../../design/components/Icon/native/redesign/generated/YoutubeNeutralIcon";
const r20 = [{
REGEX: LINKING_WHITELIST.tiktok.regex,
Icon: TiktokNeutralIcon
}, {
REGEX: LINKING_WHITELIST.twitter.regex,
Icon: TwitterNeutralIcon
}, {
REGEX: LINKING_WHITELIST.instagram.regex,
Icon: InstagramNeutralIcon
}, {
REGEX: LINKING_WHITELIST.facebook.regex,
Icon: FacebookNeutralIcon
}, {
REGEX: LINKING_WHITELIST.youtube.regex,
Icon: YoutubeNeutralIcon
}];
export const SEARCH_TEXT_INPUT_DEBOUNCE_TIME = 500;
export const EMPTY_MEDIA_RESULTS = [];
export { r20 as PLATFORM_REGEX_ICON_PAIRS };
@@ -0,0 +1,518 @@
// Metro module 11452 (f11453).
import SearchMessageStore from "../SearchMessageStore";
import SearchQueryStore from "./stores/SearchQueryStore";
import { SEARCH_TABS_TO_SEARCH_QUERY_LIMITS, MAX_SEARCH_RESULTS_LIMIT, SEARCH_INITIAL_MESSAGE_TABS, CHANNEL_SEARCH_INITIAL_MESSAGE_TABS, MESSAGE_SEARCH_RESULT_TABS, SearchMediaTypes, SearchFileTypes, SearchLinkTypes } from "../SearchConstants";
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME, PLATFORM_REGEX_ICON_PAIRS } from "./SearchPlatformConstants";
import { SearchTypes, SearchModes, MessageFlags } from "../../../Constants";
import { getSearchTabFetchId, tokenizeQuery, getSelectionScope, getGuildIdFromSearchContext } from "../SearchUtils";
import { isThumbnailAttachment, isValidImageAttachment, isValidVideoAttachment, extractMediaFromAttachment, isValidImageEmbed, isValidVideoEmbed, extractMediaFromEmbed, extractMediaFromMessageComponents } from "../../media_viewer/native/MediaSourceUtil";
import * as _Module1384 from "../../../_bundle/Module1384";
import { getKeyboardIsOpen } from "../../keyboard/native/useKeyboardIsOpen";
import { isIOS } from "../../../utils/PlatformUtils";
import { dismissGlobalKeyboard } from "../../../utils/native/KeyboardManagerUtils";
import { LinkIcon } from "../../../design/components/Icon/native/redesign/generated/LinkIcon";
import URLUtils from "../../../utils/URLUtils";
import { ClydeIcon } from "../../../design/components/Icon/native/redesign/generated/ClydeIcon";
import Module712 from "../../../_bundle/Module712";
import { SearchResultExactCountEnabled } from "../../user_settings/UserSettings";
import Tracking from "./tracking/Tracking";
import SearchPlatformActionCreators from "./SearchPlatformActionCreators";
import SearchActionCreators from "../SearchActionCreators";
import Module12 from "../../../_bundle/Module12";
import { HermesBuiltin } from "../../../_hermes/prelude";
function $mk87255($env) {
return function callback() {
const r2 = $env;
const r3 = $env.$parent;
const r9 = (0, r2[1])(r3[4].getManager(r2[0]));
if (!(r2[3] != null && (0, r3[1])(r3[2][20])(r2[3], r9))) {
const r17 = r2[3];
r2[3] = r9;
(0, r2[2])(r9, r17);
}
};
}
function $mk87256($env) {
return () => $env.$parent[4].removeChangeListener($env[4]);
}
let getGridItemBorderStyles, getInitialFetchLimit, getNextFetchLimit, onInitialFetchMessagesSuccess, onFetchMessagesStart, fetchInitialMessages;
let env7797 = {};
export function performKeyboardAwareNavigation(a0) {
if (getKeyboardIsOpen() && isIOS()) {
dismissGlobalKeyboard();
setTimeout(() => a0(), 100);
} else {
a0();
}
}
export function delayUntilNavigationComplete(c18852_0) {
setTimeout(() => c18852_0(), 200);
}
export function getUrlIcon(a0) {
if (a0 == null) {
return LinkIcon;
}
if (URLUtils.safeParseWithQuery(a0) == null) {
return LinkIcon;
}
if (URLUtils.isDiscordUrl(a0)) {
return ClydeIcon;
}
const length = PLATFORM_REGEX_ICON_PAIRS.length;
let r0 = 0;
if (0 < length) {
do {
const r22 = PLATFORM_REGEX_ICON_PAIRS[r0];
const { REGEX, Icon } = r22;
const r25 = REGEX.exec(a0);
const r1 = r0;
if (r25 != null) {
return Icon;
}
r0 = r1 + 1;
} while (r0 < PLATFORM_REGEX_ICON_PAIRS.length);
}
return LinkIcon;
}
getGridItemBorderStyles = function getGridItemBorderStyles(a0) {
let r22;
L12: {
const { itemIndex, numItems, numColumns } = a0;
const r14 = Math.ceil(numItems / numColumns);
const r18 = Math.floor(itemIndex / numColumns);
const r3 = r14 - 1;
if (itemIndex === 0) {
r22 = {
borderTopLeftRadius: Module712.radii.lg
};
} else if (itemIndex === numColumns - 1) {
r22 = {
borderTopRightRadius: Module712.radii.lg
};
} else {
if (itemIndex % numColumns == 0 && r18 === r3) {
r22 = {
borderBottomLeftRadius: Module712.radii.lg
};
break L12;
}
r22 = itemIndex === r14 * numColumns - 1 ? {
borderBottomRightRadius: Module712.radii.lg
} : void 0;
}
}
return r22;
};
export function getMediaGridItemStyles({ itemIndex, numItems, numColumns, spacing }) {
const r13 = {
...getGridItemBorderStyles({
itemIndex,
numItems,
numColumns
})
};
const marginEnd = spacing * (numColumns - 1) / numColumns;
const r18 = itemIndex % numColumns;
HermesBuiltin.copyDataProperties(r13, r18 === 0 ? {
marginEnd
} : numColumns - 1 === r18 ? {
marginStart: marginEnd
} : {
marginHorizontal: marginEnd / 2
});
return r13;
}
export function getGridItemSpacingStyles({ itemIndex, spacing, numColumns }) {
const marginEnd = spacing * (numColumns - 1) / numColumns;
const r9 = itemIndex % numColumns;
if (r9 === 0) {
return {
marginEnd
};
}
if (numColumns - 1 === r9) {
return {
marginStart: marginEnd
};
}
return {
marginHorizontal: marginEnd / 2
};
}
export function toSearchBarTag(a0) {
return {
id: a0.text,
text: a0.text
};
}
getInitialFetchLimit = function getInitialFetchLimit(a0) {
return Math.min(SEARCH_TABS_TO_SEARCH_QUERY_LIMITS[a0], MAX_SEARCH_RESULTS_LIMIT);
};
getNextFetchLimit = function getNextFetchLimit(a0) {
return Math.min(2 * SEARCH_TABS_TO_SEARCH_QUERY_LIMITS[a0], MAX_SEARCH_RESULTS_LIMIT);
};
onInitialFetchMessagesSuccess = function onInitialFetchMessagesSuccess(a0) {
const searchContext = a0.searchContext;
if (a0.tabEntries.every((tabEntry) => {
const [, r14] = tabEntry;
return r14.total_results === 0 || r14.total_results == null;
})) {
Tracking.trackSearchEmptyMessageResult({
searchContext
});
}
};
onFetchMessagesStart = function onFetchMessagesStart({ searchContext, searchQueryString }) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => a0.setSearchResultsQuery(searchQueryString));
};
fetchInitialMessages = function fetchInitialMessages(a0) {
let searchTabs;
let c18854_0 = a0;
const isInitialSearchQuery = SearchQueryStore.isInitialSearchQuery(a0);
const queryString = SearchQueryStore.getQueryString(a0);
if (isInitialSearchQuery) {
const type = a0.type;
searchTabs = SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type ? SEARCH_INITIAL_MESSAGE_TABS : CHANNEL_SEARCH_INITIAL_MESSAGE_TABS;
} else {
searchTabs = MESSAGE_SEARCH_RESULT_TABS;
}
const searchTabFetchId = getSearchTabFetchId(a0, searchTabs[0], queryString);
if (!SearchMessageStore.getIsFetching(searchTabFetchId)) {
SearchActionCreators.clearAllSearchMesssages();
Tracking.trackSearchStarted({
searchContext: a0
});
let cursor = SearchMessageStore.getCursor(searchTabFetchId);
if (cursor == null) {
cursor = null;
}
SearchActionCreators.fetchTabMessages({
searchContext: a0,
searchTabs,
searchQueryString: queryString,
getId: (a0) => getSearchTabFetchId(c18854_0, a0, queryString),
getLimit: getInitialFetchLimit,
onFetchStart: onFetchMessagesStart,
onFetchSuccess: onInitialFetchMessagesSuccess,
pagination: {
cursor
},
trackExactTotalHits: SearchResultExactCountEnabled.getSetting(),
searchMode: SearchModes.NEWEST
});
}
};
const syncAutocomplete = function syncAutocomplete(a0) {
const queryString3 = SearchQueryStore.getQueryString(a0, true);
const tokens = tokenizeQuery(queryString3);
SearchActionCreators.updateAutocompleteQuery({
searchContext: a0,
tokens,
cursorScope: getSelectionScope(tokens, queryString3.length - 1, queryString3.length - 1),
queryString: queryString3
});
};
const r52 = {
performKeyboardAwareNavigation,
delayUntilNavigationComplete,
getUrlIcon,
getGridItemBorderStyles,
getMediaGridItemStyles,
getGridItemSpacingStyles,
toSearchBarTag,
fetchInitialMessages,
fetchInitialMessagesDebounced: Module12.debounce(fetchInitialMessages, SEARCH_TEXT_INPUT_DEBOUNCE_TIME),
fetchNextMessages: function fetchNextMessages(a0, a1, a2) {
let r44, cursor, messages, totalCount;
let c18856_0 = a0;
const queryString2 = SearchQueryStore.getQueryString(a0);
const searchTabFetchId2 = getSearchTabFetchId(a0, a1, queryString2);
const r28 = Math.min(SEARCH_TABS_TO_SEARCH_QUERY_LIMITS[a1], MAX_SEARCH_RESULTS_LIMIT);
const searchTabFetchId = getSearchTabFetchId(a0, a1, queryString2);
const isInitialFetchComplete = SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId);
let r1 = true;
if (isInitialFetchComplete) {
L12: {
L5: {
cursor = SearchMessageStore.getCursor(searchTabFetchId);
totalCount = SearchMessageStore.getTotalCount(searchTabFetchId);
messages = SearchMessageStore.getMessages(searchTabFetchId);
if (!SearchResultExactCountEnabled.getSetting()) {
if (totalCount != null && totalCount < r28) {
break L5;
}
r44 = cursor != null;
break L12;
}
}
r44 = cursor != null && totalCount != null && messages != null && messages.length < totalCount;
}
r1 = r44;
}
const isFetching = SearchMessageStore.getIsFetching(searchTabFetchId2);
const isInitialFetchComplete2 = SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId2);
const r50 = (r1 ? !isInitialFetchComplete2 : !r1) || isFetching;
let r51 = !r50;
if (!r50) {
let cursor2 = SearchMessageStore.getCursor(searchTabFetchId2);
if (cursor2 == null) {
cursor2 = null;
}
r51 = SearchActionCreators.fetchTabMessages({
searchContext: a0,
searchTabs: [a1],
searchQueryString: queryString2,
getLimit: getNextFetchLimit,
getId: (a0) => getSearchTabFetchId(c18856_0, a0, queryString2),
onFetchStart: onFetchMessagesStart,
onFetchSuccess: a2,
pagination: {
cursor: cursor2
},
trackExactTotalHits: SearchResultExactCountEnabled.getSetting(),
searchMode: SearchModes.NEWEST
});
}
return r51;
},
syncAutocomplete,
syncAutocompleteDebounced: Module12.debounce(syncAutocomplete, SEARCH_TEXT_INPUT_DEBOUNCE_TIME),
navigateToSearchWithPrefetch: function navigateToSearchWithPrefetch(a0, a1) {
SearchActionCreators.initializeAutocomplete(a1);
SearchPlatformActionCreators.initializeSearchQuery(a1);
fetchInitialMessages(a1);
a0.navigate("search", {
searchContext: a1
});
},
subscribeSearchQueryState: function subscribeSearchQueryState(a0, a1, a2, a3) {
let env18855;
const r2 = env18855 = {
$parent: env7797
};
env18855[0] = a0;
env18855[1] = a1;
env18855[2] = a2;
let r3 = a3;
const r5 = $mk87255(r2);
env18855[4] = r5;
const r12 = a1(SearchQueryStore.getManager(a0));
env18855[3] = r12;
if (a3) {
r3 = r12 != null;
}
if (r3) {
a2(env18855[3], void 0);
}
SearchQueryStore.addChangeListener(r5);
return $mk87256(r2);
},
subscribeTextInputValue: function subscribeTextInputValue(a0, a1, a2) {
let env18858;
let c18857_0 = a1;
let r6 = a2;
const r2 = env18858 = {
$parent: env7797
};
env18858[0] = a0;
env18858[1] = (a0) => ({
textInputValue: a0.getTextInputValue(),
textInputChangedFromInput: a0.getTextValueChangedFromInput()
});
env18858[2] = (a0, a1) => {
c18857_0(a0.textInputValue, a1?.textInputValue, a0.textInputChangedFromInput);
};
const r5 = $mk87255(r2);
env18858[4] = r5;
const manager = SearchQueryStore.getManager(a0);
const r16 = {
textInputValue: manager.getTextInputValue(),
textInputChangedFromInput: manager.getTextValueChangedFromInput()
};
env18858[3] = r16;
if (a2) {
r6 = true;
}
if (r6) {
a1(r16.textInputValue, void 0, r16.textInputChangedFromInput);
}
SearchQueryStore.addChangeListener(r5);
return $mk87256(r2);
}
};
export default r52;
export function getMedia(a0, a1) {
let r10 = getGuildIdFromSearchContext(a0);
if (r10 == null) {
r10 = void 0;
}
let c18859_0 = r10;
const r12 = [];
let c18859_1 = r12;
a1.forEach((a0) => {
let c27068_0 = a0;
let mediaIndex = 0;
const contentMessage3 = a0.getContentMessage();
const attachments = contentMessage3.attachments;
if (attachments != null) {
attachments.forEach((a0, index) => {
L5: {
if (!isThumbnailAttachment(a0)) {
if (!isValidImageAttachment(a0) && !isValidVideoAttachment(a0)) {
break L5;
}
const sources = extractMediaFromAttachment(a0, c27068_0, index, c18859_0);
if (sources != null) {
c18859_1.push({
type: SearchMediaTypes.ATTACHMENT,
attachment: a0,
messageId: c27068_0.id,
channelId: c27068_0.channel_id,
author: c27068_0.author,
mediaIndex,
sources
});
mediaIndex = mediaIndex + 1;
}
}
}
});
}
const embeds = contentMessage3.embeds;
if (embeds != null) {
embeds.forEach((a0, index) => {
if (!(!isValidImageEmbed(a0) && !isValidVideoEmbed(a0))) {
const sources = extractMediaFromEmbed(a0, c27068_0, contentMessage3, index, c18859_0);
if (sources != null) {
c18859_1.push({
type: SearchMediaTypes.EMBED,
embed: a0,
messageId: c27068_0.id,
channelId: c27068_0.channel_id,
author: c27068_0.author,
mediaIndex,
sources
});
mediaIndex = mediaIndex + 1;
}
}
});
}
for (const item of extractMediaFromMessageComponents(a0, contentMessage3, c18859_0)) {
c18859_1.push({
type: SearchMediaTypes.COMPONENT,
messageId: a0.id,
channelId: a0.channel_id,
author: a0.author,
mediaIndex,
sources: item.sources,
unfurledMediaItem: item.unfurledMediaItem
});
mediaIndex = mediaIndex + 1;
}
if (_Module1384.hasFlag(contentMessage3.flags, MessageFlags.IS_VOICE_MESSAGE)) {
c18859_1.push({
type: SearchMediaTypes.AUDIO,
messageId: a0.id,
channelId: a0.channel_id,
author: a0.author,
mediaIndex
});
mediaIndex = mediaIndex + 1;
}
});
return r12;
}
export function getFiles(a0) {
let c18860_0 = a0;
const r1 = [];
let c18860_1 = r1;
const contentMessage = a0.getContentMessage();
const attachments = contentMessage.attachments;
if (attachments != null) {
attachments.forEach((a0, index) => {
L6: {
if (!isValidImageAttachment(a0) && !isValidVideoAttachment(a0)) {
const hasFlag = _Module1384.hasFlag(contentMessage.flags, MessageFlags.IS_VOICE_MESSAGE);
const r26 = {
type: null,
messageId: null,
channelId: null,
author: null,
fileIndex: null,
attachment: null
};
if (hasFlag) {
r26.type = SearchFileTypes.AUDIO;
r26.messageId = c18860_0.id;
r26.channelId = c18860_0.channel_id;
r26.author = c18860_0.author;
r26.fileIndex = index;
r26.attachment = a0;
c18860_1.push(r26);
break L6;
}
r26.type = SearchFileTypes.ATTACHMENT;
r26.messageId = c18860_0.id;
r26.channelId = c18860_0.channel_id;
r26.author = c18860_0.author;
r26.fileIndex = index;
r26.attachment = a0;
c18860_1.push(r26);
} else {
c18860_1.push({
type: SearchFileTypes.MEDIA_ATTACHMENT,
messageId: c18860_0.id,
channelId: c18860_0.channel_id,
author: c18860_0.author,
fileIndex: index,
attachment: a0
});
}
}
});
}
return r1;
}
export function getLinks(a0, a1) {
let r12 = getGuildIdFromSearchContext(a0);
if (r12 == null) {
r12 = void 0;
}
let c18861_1 = r12;
const r13 = [];
let c18861_2 = r13;
const contentMessage2 = a1.getContentMessage();
const linkIndex = 0;
const embeds = contentMessage2.embeds;
if (embeds != null) {
embeds.forEach((a0, index) => {
if (!(!isValidImageEmbed(a0) && !isValidVideoEmbed(a0))) {
const sources = extractMediaFromEmbed(a0, a1, contentMessage2, index, c18861_1);
if (sources != null) {
c18861_2.push({
type: SearchLinkTypes.EMBED,
messageId: a1.id,
channelId: a1.channel_id,
author: a1.author,
linkIndex,
sources,
embed: a0
});
linkIndex = linkIndex + 1;
}
}
});
}
if (r13.length === 0) {
r13.push({
type: SearchLinkTypes.TEXT,
messageId: a1.id,
channelId: a1.channel_id,
author: a1.author,
linkIndex: 0
});
}
return r13;
}
export { getGridItemBorderStyles };
@@ -0,0 +1,7 @@
// Metro module 15513 (f15514).
import combineMarkupRules from "../../markup/combineMarkupRules";
import MarkupRules from "../../markup/MarkupRules";
import { createSearchResultLinkPreviewReactRules } from "../../markup/native/MarkupSearchResultLinkPreviewReactRules";
import { reactParserFor } from "../../../_bundle/Module7768";
const r26 = reactParserFor(combineMarkupRules([MarkupRules.NATIVE_SEARCH_RESULT_LINK_RULES, createSearchResultLinkPreviewReactRules()]));
export { r26 as NativeSearchResultLinkPreviewParser };
@@ -0,0 +1,17 @@
// Metro module 10290 (f10291).
import { Fonts } from "../../../../Constants";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import { hexOpacityToRgba } from "../../../../utils/ColorUtils";
import Module712 from "../../../../_bundle/Module712";
import { LegacyText } from "../../../../design/void/native";
const useStyles = createStyles({
text: {
fontFamily: Fonts.PRIMARY_BOLD,
backgroundColor: hexOpacityToRgba(Module712.unsafe_rawColors.YELLOW_300, 0.3),
color: Module712.colors.TEXT_STRONG
}
});
export default function HighlightText(props) {
const children = props.children;
return <LegacyText style={useStyles().text}>{children}</LegacyText>;
};
@@ -0,0 +1,213 @@
// Metro module 15464 (f15465).
import * as Module19 from "react";
import { forwardRef, useMemo, useRef, useImperativeHandle, useEffect, useCallback } from "react";
import { View } from "react-native";
import ChannelStore from "../../../../../stores/ChannelStore";
import GuildStore from "../../../../../stores/GuildStore";
import RelationshipStore from "../../../../../stores/RelationshipStore";
import UserStore from "../../../../../stores/UserStore";
import SearchQueryStore from "../../stores/SearchQueryStore";
import { SEARCH_BAR_HEIGHT, SearchQueryTagTypes } from "../../../SearchConstants";
import { SearchFilterAddLocations } from "../../tracking/TrackingConstants";
import { SearchTypes } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { intl, t } from "../../../../../intl/index.native";
import { computeChannelName } from "../../../../channel/useChannelName";
import { useStateFromStores } from "../../../../../_bundle/Module589";
import MobileVisualRefreshExperiment from "../../../../themes/experiments/MobileVisualRefreshExperiment";
import { useFontScale } from "../../../../screen/native/useFontScale";
import SearchPlatformUtils, { toSearchBarTag } from "../../SearchPlatformUtils";
import SearchPlatformActionCreators from "../../SearchPlatformActionCreators";
import { AccessibilityAnnouncer } from "../../../../../_bundle/Module3902";
import Tracking from "../../tracking/Tracking";
import { isValidFilterAnswerForSubmit } from "../../../tokens/SearchTokens";
import TagListInput_native from "../../../../../design/components/TagListInput/native/TagListInput.native";
import SearchBarActivityIcon from "./SearchBarActivityIcon";
const useStyles = createStyles((a0, a1) => ({
searchBar: {
...a0 ? {
minHeight: a1 + 2
} : {
borderRadius: Module712.radii.round,
minHeight: a1
}
},
icon: {
width: 32,
minHeight: a1,
justifyContent: "center",
zIndex: 10
}
}));
const r50 = Module19.memo(forwardRef(function({ searchContext, setSuggestionsDismissed }, a1) {
let ref;
let searchContext2;
ref = void 0;
const styles = useStyles(MobileVisualRefreshExperiment("SearchBar"), SEARCH_BAR_HEIGHT * Math.min(2, useFontScale()));
const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.getTags(searchContext), [searchContext]);
const memo2 = useMemo(() => stateFromStores.map(toSearchBarTag), [stateFromStores]);
const memo = useMemo(() => {
if (stateFromStores.length !== 0) {
return intl.formatToPlainString(t["0zoRaK"], {
text: stateFromStores.map((stateFromStore) => stateFromStore.text).join(", ")
});
}
}, [stateFromStores]);
ref = useRef(null);
searchContext2 = searchContext;
const stateFromStores2 = useStateFromStores([SearchQueryStore], () => {
let r89;
const channelIds = SearchQueryStore.getChannelIds(searchContext2);
const type = searchContext2.type;
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.GUILD !== type) {
if (SearchTypes.CHANNEL === type) {
const channel = ChannelStore.getChannel(searchContext2.channelId);
return channel == null ? intl.string(t["5h0QOP"]) : intl.formatToPlainString(t.LDpotA, {
guildName: computeChannelName(channel, UserStore, RelationshipStore, true)
});
}
if (SearchTypes.DMS === type) {
return intl.string(t.m7OrlR);
}
return intl.string(t["5h0QOP"]);
}
if (channelIds.size === 0) {
const name = GuildStore.getGuild(searchContext2.guildId)?.name;
r89 = name == null ? intl.string(t["5h0QOP"]) : intl.formatToPlainString(t.LDpotA, {
guildName: name
});
} else {
r89 = intl.string(t["5h0QOP"]);
}
return r89;
}, [searchContext]);
useImperativeHandle(a1, () => ({
setText: (a0) => {
const current = ref.current;
return current == null ? void 0 : current.setText(a0);
},
getText: () => {
const current = ref.current;
let r6 = current == null ? void 0 : current.getText();
if (r6 == null) {
r6 = "";
}
return r6;
},
blur: () => {
const current = ref.current;
return current == null ? void 0 : current.blur();
},
focus: () => {
const current = ref.current;
return current == null ? void 0 : current.focus();
},
isFocused: () => {
const current = ref.current;
let r6 = current == null ? void 0 : current.isFocused();
if (r6 == null) {
r6 = false;
}
return r6;
},
measure: (a0) => {
const current = ref.current;
return current == null ? void 0 : current.measure(a0);
},
measureInWindow: (a0) => {
const current = ref.current;
return current == null ? void 0 : current.measureInWindow(a0);
},
measureLayout: (a0, a1, a2) => {
const current = ref.current;
return current == null ? void 0 : current.measureLayout(a0, a1, a2);
}
}));
useEffect(() => SearchPlatformUtils.subscribeTextInputValue(searchContext, (a0, a1, a2) => {
if (!(a2 ? a2 : a0 == null)) {
const current = ref.current;
if (current != null) {
current.setText(a0);
}
}
}), [searchContext]);
const callback = useCallback((a0) => {
let c28031_0 = a0;
if (SearchQueryStore.getTextInputValue(searchContext) !== a0) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.setTextInputValue(c28031_0, true);
});
SearchPlatformUtils.syncAutocompleteDebounced(searchContext);
if (!SearchQueryStore.isAutocompleteVisible(searchContext)) {
if (SearchQueryStore.isInitialSearchQuery(searchContext)) {
SearchPlatformUtils.fetchInitialMessages(searchContext);
} else {
SearchPlatformUtils.fetchInitialMessagesDebounced(searchContext);
}
}
}
}, [searchContext]);
const callback2 = useCallback((a0) => {
let c28032_0 = a0;
const r10 = SearchQueryStore.getTags(searchContext)[a0];
let c28032_1 = r10;
if (r10 != null) {
AccessibilityAnnouncer.announce(intl.formatToPlainString(t.srlxB8, {
text: r10.text
}));
if (r10.type === SearchQueryTagTypes.COMPLETE) {
Tracking.trackSearchFilterRemove({
searchContext,
searchTokenType: r10.searchTokenType,
isDefault: r10.location === SearchFilterAddLocations.CLIENT_AUTO_ADD
});
}
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.removeTag(c28032_0);
if (c28032_1.type === SearchQueryTagTypes.PREFIX) {
a0.restoreDraftTextInputValue();
}
});
SearchPlatformUtils.syncAutocompleteDebounced(searchContext);
const queryString = SearchQueryStore.getQueryString(searchContext);
const searchResultsQuery = SearchQueryStore.getSearchResultsQuery(searchContext);
const isInitialSearchQuery = SearchQueryStore.isInitialSearchQuery(searchContext);
if (queryString !== searchResultsQuery) {
if (isInitialSearchQuery) {
SearchPlatformUtils.fetchInitialMessages(searchContext);
} else {
SearchPlatformUtils.fetchInitialMessagesDebounced(searchContext);
}
}
}
}, [searchContext]);
const memo3 = useMemo(() => () => {
setSuggestionsDismissed();
const prefixTag = SearchQueryStore.getPrefixTag(searchContext);
const text = SearchQueryStore.getTextInputValue(searchContext).trim();
if (prefixTag != null && text !== "" && isValidFilterAnswerForSubmit(prefixTag.searchTokenType, text)) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.setTextInputValue("");
a0.addTag({
type: SearchQueryTagTypes.ANSWER,
text
});
a0.restoreDraftTextInputValue();
});
Tracking.trackSearchFilterAdd({
searchContext,
searchTokenType: prefixTag.searchTokenType,
location: prefixTag.location
});
}
if (!SearchQueryStore.isQueryStringEmpty(searchContext)) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => a0.markExplicitSearchSubmitted());
SearchPlatformUtils.fetchInitialMessages(searchContext);
}
}, [searchContext, setSuggestionsDismissed]);
return <TagListInput_native ref={ref} accessibilityHint={memo} autoFocus defaultValue={SearchQueryStore.getTextInputValue(searchContext)} style={styles.searchBar} tags={memo2} icon={<View style={styles.icon}>
<SearchBarActivityIcon searchContext={searchContext} />
</View>} onChangeText={callback} onRemove={callback2} placeholder={stateFromStores2} onSubmitEditing={memo3} leadingFade horizontal autoClearInputOnTagAdd={false} />;
}));
export default r50;
@@ -0,0 +1,104 @@
// Metro module 15465 (f15466).
import { memo, useEffect } from "react";
import { ActivityIndicator } from "react-native";
import SearchMessageStore from "../../../SearchMessageStore";
import SearchQueryStore from "../../stores/SearchQueryStore";
import { SEARCH_MESSAGE_TAB_SENTINEL } from "../../../SearchConstants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../../_bundle/defaultAreStatesEqual";
import { getSearchTabFetchId } from "../../../SearchUtils";
import * as _ReanimatedRexport from "../../../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle } from "../../../../reanimated/ReanimatedRexport";
import { withTiming } from "../../../../../design/animation/reanimated/timing/timing";
import { MagnifyingGlassIcon } from "../../../../../design/components/Icon/native/redesign/generated/MagnifyingGlassIcon";
import { isAndroid } from "../../../../../utils/PlatformUtils";
const useStyles = createStyles({
spinnerColor: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
spinner: {
width: 18,
height: 18,
alignItems: "center",
justifyContent: "center",
position: "absolute"
},
icon: {
marginLeft: 12,
marginRight: 4
}
});
let c11001_12 = {
START: 0,
0: "START",
END: 1,
1: "END"
};
const ANIMATION_STATE_INPUT = [c11001_12.START, c11001_12.END];
const __initData = {
code: "function SearchBarActivityIconTsx1(){const{interpolate,fadeAnimationState,ANIMATION_STATE_INPUT}=this.__closure;return{opacity:interpolate(fadeAnimationState.get(),ANIMATION_STATE_INPUT,[0,0.5])};}"
};
const __initData2 = {
code: "function SearchBarActivityIconTsx2(){const{interpolate,fadeAnimationState,ANIMATION_STATE_INPUT}=this.__closure;return{opacity:interpolate(fadeAnimationState.get(),ANIMATION_STATE_INPUT,[1,0])};}"
};
const r54 = memo(function SearchBarActivityIcon(props) {
let sharedValue;
const searchContext = props.searchContext;
sharedValue = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([SearchQueryStore, SearchMessageStore], () => {
const isInitialFetchComplete = SearchMessageStore.getIsInitialFetchComplete(getSearchTabFetchId(searchContext, SEARCH_MESSAGE_TAB_SENTINEL, SearchQueryStore.getSearchResultsQuery(searchContext)));
let r18 = !isInitialFetchComplete;
const isInitialSearchQuery = SearchQueryStore.isInitialSearchQuery(searchContext);
const isAutocompleteVisible = SearchQueryStore.isAutocompleteVisible(searchContext);
if (!isInitialFetchComplete) {
r18 = !isInitialSearchQuery;
}
if (r18) {
r18 = !isAutocompleteVisible;
}
return r18;
}, [searchContext]);
sharedValue = useSharedValue(c11001_12.START);
useEffect(() => {
if (stateFromStores) {
sharedValue.set(withTiming(c11001_12.END));
} else {
sharedValue.set(withTiming(c11001_12.START));
}
}, [stateFromStores, sharedValue]);
const E = function E() {
return {
opacity: _ReanimatedRexport.interpolate(sharedValue.get(), ANIMATION_STATE_INPUT, [0, 0.5])
};
};
E.__closure = {
interpolate: _ReanimatedRexport.interpolate,
fadeAnimationState: sharedValue,
ANIMATION_STATE_INPUT
};
E.__workletHash = 12880513119188;
E.__initData = __initData;
const animatedStyle = useAnimatedStyle(E);
const v = function v() {
return {
opacity: _ReanimatedRexport.interpolate(sharedValue.get(), ANIMATION_STATE_INPUT, [1, 0])
};
};
v.__closure = {
interpolate: _ReanimatedRexport.interpolate,
fadeAnimationState: sharedValue,
ANIMATION_STATE_INPUT
};
v.__workletHash = 11061952032557;
v.__initData = __initData2;
return <>
{[<ReanimatedRexport.View style={animatedStyle}>
<ActivityIndicator color={styles.spinnerColor.color} style={[styles.icon, styles.spinner]} />
</ReanimatedRexport.View>, <ReanimatedRexport.View style={useAnimatedStyle(v)}>
<MagnifyingGlassIcon style={styles.icon} size={isAndroid() ? "sm" : "xs"} color="interactive-text-default" />
</ReanimatedRexport.View>]}
</>;
});
export default r54;
@@ -0,0 +1,37 @@
// Metro module 15474 (f15475).
import { memo } from "react";
import { View } from "react-native";
import SearchQueryStore from "../../stores/SearchQueryStore";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import AppFreezer from "../../../../panels/morphable/native/AppFreezer";
import { useStateFromStores } from "../../../../../_bundle/Module589";
import SearchTabsLayout from "../tabs/SearchTabsLayout";
import AutocompleteScreen from "./autocomplete/AutocompleteScreen";
let useStyles;
const SearchFreezeContainer = function SearchFreezeContainer(props) {
const { visible, children, containerStyle } = props;
const styles = useStyles();
return <AppFreezer manualFreeze={!visible} placeholder={null}>
<View style={[containerStyle, visible ? styles.visible : styles.hidden]} aria-hidden={!visible}>{children}</View>
</AppFreezer>;
};
useStyles = createStyles({
hidden: {
opacity: 0
},
visible: {
flex: 1
}
});
const r35 = memo(function({ searchContext, containerStyle, width }) {
const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isAutocompleteVisible(searchContext), [searchContext]);
return <>
<SearchFreezeContainer visible={!stateFromStores} containerStyle={containerStyle}>
<SearchTabsLayout searchContext={searchContext} width={width} />
</SearchFreezeContainer>
<SearchFreezeContainer visible={stateFromStores} containerStyle={containerStyle}>
<AutocompleteScreen searchContext={searchContext} />
</SearchFreezeContainer>
</>;
});
export default r35;
@@ -0,0 +1,54 @@
// Metro module 15463 (f15464).
import { memo, forwardRef } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import SearchBar from "./SearchBar";
import SearchFilterSuggestions from "./autocomplete/SearchFilterSuggestions";
import SearchFilterButton from "./autocomplete/SearchFilterButton";
const useStyles = createStyles({
header: {
flexDirection: "row",
alignItems: "center",
paddingLeft: 16,
zIndex: 10
},
headerWithBackButton: {
paddingLeft: 0
},
headerSearch: {
flex: 1,
flexGrow: 1
},
headerControlsRight: {
paddingRight: 16,
paddingLeft: 12
},
suggestionsAnchor: {
height: 0
},
suggestions: {
position: "absolute",
left: 0,
right: -50,
top: 8
},
suggestionsWithBackButton: {
left: -28
}
});
const r38 = memo(forwardRef(function({ searchContext, onSuggestionsLayoutMesure, suggestionsDismissed, setSuggestionsDismissed, backButton }, a1) {
const styles = useStyles();
return <View style={[styles.header, backButton != null && styles.headerWithBackButton]}>
{backButton}
<View style={styles.headerSearch}>
<SearchBar ref={a1} searchContext={searchContext} setSuggestionsDismissed={setSuggestionsDismissed} />
<View style={styles.suggestionsAnchor}>
<SearchFilterSuggestions searchContext={searchContext} onLayoutMeasure={onSuggestionsLayoutMesure} dismissed={suggestionsDismissed} containerStyle={[styles.suggestions, backButton != null && styles.suggestionsWithBackButton]} />
</View>
</View>
<View style={styles.headerControlsRight}>
<SearchFilterButton searchContext={searchContext} />
</View>
</View>;
}));
export default r38;
@@ -0,0 +1,259 @@
// Metro module 15559 (f15560).
import * as Module19 from "react";
import { useState, useCallback, useEffect, useMemo } from "react";
import ChannelStore from "../../../../../../stores/ChannelStore";
import RelationshipStore from "../../../../../../stores/RelationshipStore";
import UserStore from "../../../../../../stores/UserStore";
import SearchAutocompleteStore from "../../../../SearchAutocompleteStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { SearchListItemTypes, SearchQueryTagTypes, USER_ESTIMATED_ITEM_SIZE } from "../../../../SearchConstants";
import { SearchPopoutModes, SearchTokenTypes } from "../../../../../../Constants";
import { useStateFromStores, statesWillNeverBeEqual } from "../../../../../../_bundle/Module589";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import SearchPlatformUtils from "../../../SearchPlatformUtils";
import SearchPlatformActionCreators from "../../../SearchPlatformActionCreators";
import Tracking from "../../../tracking/Tracking";
import UserUtils from "../../../../../../utils/UserUtils";
import { computeChannelName } from "../../../../../channel/useChannelName";
import { quoteChannelName } from "../../../../SearchUtils";
import { getSearchQueryUserIds, getSearchQueryChannelIds, toSearchListUserItem, toSearchListChannelItem, getSearchFilterHasIcon, getSearchFilterAuthorTypeIcon } from "./AutocompleteScreenUtils";
import { Token } from "../../../../../../lib/QueryTokenizer";
import { isValidUserAutocomplete, isValidChannelAutocomplete } from "../../../../tokens/SearchTokens";
import { useMessageTabCountsErrorText } from "../../../hooks/useSearchScreenError";
import ErrorScreen from "../../tabs/pages/ErrorScreen";
import { intl, t } from "../../../../../../intl/index.native";
import SearchList from "../../list/SearchList";
let c11085_16 = [];
const r42 = Module19.memo(function AutocompleteScreen(props) {
let r97;
let searchContext, stateFromStores, state, setState, fullscreenPlaceholderCount, callback, callback2, callback3, callback4;
L12: {
searchContext = props.searchContext;
stateFromStores = void 0;
state = void 0;
setState = void 0;
fullscreenPlaceholderCount = void 0;
callback = void 0;
callback2 = void 0;
callback3 = void 0;
callback4 = void 0;
stateFromStores = useStateFromStores([SearchAutocompleteStore], () => SearchAutocompleteStore.getState(searchContext), [searchContext], statesWillNeverBeEqual);
[state, setState] = useState(false);
const stateFromStores2 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isTextInputValueEmpty(searchContext), [searchContext]);
fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: USER_ESTIMATED_ITEM_SIZE,
numColumns: 1
});
callback = useCallback(() => {
SearchPlatformUtils.syncAutocomplete(searchContext);
SearchPlatformUtils.fetchInitialMessages(searchContext);
}, [searchContext]);
callback2 = useCallback((text) => {
const prefixTag = SearchQueryStore.getPrefixTag(searchContext);
if (prefixTag != null) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.setTextInputValue("");
a0.addTag({
type: SearchQueryTagTypes.ANSWER,
text
});
a0.restoreDraftTextInputValue();
});
Tracking.trackSearchFilterAdd({
searchContext,
searchTokenType: prefixTag.searchTokenType,
location: prefixTag.location
});
callback();
}
}, [callback, searchContext]);
callback3 = useCallback((a0) => {
const user = UserStore.getUser(a0);
if (user != null) {
const prefixTag = SearchQueryStore.getPrefixTag(searchContext);
if (prefixTag != null) {
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.setTextInputValue("");
a0.addTag({
type: SearchQueryTagTypes.ANSWER,
text: UserUtils.getUserTag(user),
userId: user.id
});
a0.restoreDraftTextInputValue();
});
Tracking.trackSearchFilterAdd({
searchContext,
searchTokenType: prefixTag.searchTokenType,
location: prefixTag.location
});
callback();
}
}
}, [callback, searchContext]);
callback4 = useCallback((a0) => {
let userTag;
const channelId = a0;
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
const prefixTag = SearchQueryStore.getPrefixTag(searchContext);
if (prefixTag != null) {
userTag = computeChannelName(channel, UserStore, RelationshipStore);
if (channel.isDM()) {
const user2 = UserStore.getUser(channel.getRecipientId());
if (user2 == null) {
return void 0;
}
userTag = UserUtils.getUserTag(user2);
}
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
a0.setTextInputValue("");
a0.addTag({
type: SearchQueryTagTypes.ANSWER,
text: quoteChannelName(userTag),
channelId
});
a0.restoreDraftTextInputValue();
});
Tracking.trackSearchFilterAdd({
searchContext,
searchTokenType: prefixTag.searchTokenType,
location: prefixTag.location
});
callback();
}
}
}, [callback, searchContext]);
useEffect(() => SearchPlatformUtils.subscribeSearchQueryState(searchContext, (a0) => {
const r1 = {
isAutocompleteVisible: a0.isAutocompleteVisible(),
textInputValue: a0.getTextInputValue(),
prefixTag: null
};
let prefixTag = a0.getPrefixTag();
if (prefixTag == null) {
prefixTag = null;
}
r1.prefixTag = prefixTag;
return r1;
}, (a0, a1) => {
const { textInputValue, prefixTag } = a0;
if (a0.isAutocompleteVisible && !(textInputValue === a1?.textInputValue && prefixTag === a1?.prefixTag)) {
setState(true);
}
}, true), [searchContext]);
useEffect(() => {
setState(false);
}, [stateFromStores.autocompletes]);
const memo = useMemo(() => {
const r6 = [];
let c28083_0 = r6;
if (state) {
let r101 = 0;
while (r101 < fullscreenPlaceholderCount) {
r6.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r101}`
});
r101 = r101 + 1;
}
return r6;
}
const set = new Set(getSearchQueryUserIds(searchContext));
let c28083_1 = set;
let c28083_2 = new Set(getSearchQueryChannelIds(searchContext));
const { autocompletes, tokens, mode } = stateFromStores;
autocompletes.forEach((autocomplete) => {
if (mode.type === SearchPopoutModes.FILTER) {
const { results, group } = autocomplete;
if (results.length !== 0) {
results.forEach(({ user: user2, channel, text: text2 }) => {
const r20 = toSearchListUserItem(searchContext, user2, callback3);
const id = user2?.id;
if (!(r20 == null || id == null || c28083_1.has(id) || RelationshipStore.isBlockedOrIgnored(id))) {
c28083_1.add(id);
c28083_0.push(r20);
}
const r38 = toSearchListChannelItem(channel, callback4);
const id2 = channel?.id;
if (!(r38 == null || id2 == null || c28083_2.has(id2))) {
c28083_2.add(id2);
c28083_0.push(r38);
}
if (group === SearchTokenTypes.FILTER_HAS && text2 != null) {
c28083_0.push({
type: SearchListItemTypes.GENERIC,
props: {
text: text2,
icon: getSearchFilterHasIcon(text2),
onPress: callback2
}
});
}
if (group === SearchTokenTypes.FILTER_AUTHOR_TYPE && text2 != null) {
c28083_0.push({
type: SearchListItemTypes.GENERIC,
props: {
text: text2,
icon: getSearchFilterAuthorTypeIcon(text2),
onPress: callback2
}
});
}
});
}
}
});
if (r6.length === 0 && mode.type !== SearchPopoutModes.FILTER) {
const r50 = tokens[tokens.length - 1];
if (r50 != null) {
const token = new Token(r50);
if (!(token.type !== SearchTokenTypes.ANSWER_USERNAME_FROM && token.type !== SearchTokenTypes.ANSWER_USERNAME_MENTIONS) && isValidUserAutocomplete(token)) {
const data = token.getData("userId");
if (data != null) {
const user2 = UserStore.getUser(data);
const r77 = toSearchListUserItem(searchContext, user2, callback3);
const id = user2?.id;
if (!(r77 == null || id == null || set.has(id) || RelationshipStore.isBlockedOrIgnored(id))) {
set.add(id);
r6.push(r77);
}
}
}
if (token.type === SearchTokenTypes.ANSWER_IN && isValidChannelAutocomplete(token, searchContext)) {
const data2 = token.getData("channelIds");
if (data2 != null) {
data2.forEach((item) => {
const channel = ChannelStore.getChannel(item);
const r17 = toSearchListChannelItem(channel, callback4);
const id = channel?.id;
if (!(r17 == null || id == null || c28083_2.has(id))) {
c28083_2.add(id);
c28083_0.push(r17);
}
});
}
}
}
}
return r6.length > 0 ? r6 : c11085_16;
}, [state, searchContext, fullscreenPlaceholderCount, stateFromStores, callback3, callback4, callback2]);
const messageTabCountsErrorText = useMessageTabCountsErrorText({
searchContext
});
if (messageTabCountsErrorText != null) {
r97 = <ErrorScreen text={messageTabCountsErrorText} />;
} else {
if (stateFromStores2 && memo.length === 0) {
r97 = <ErrorScreen text={intl.string(t["E4HqQ+"])} />;
break L12;
}
if (!stateFromStores2 && memo.length === 0 && !state) {
r97 = <ErrorScreen text={intl.string(t.Dr1vko)} />;
break L12;
}
r97 = <SearchList data={memo} />;
}
}
return r97;
});
export default r42;
@@ -0,0 +1,146 @@
// Metro module 15560 (f15561).
import GuildMemberStore from "../../../../../../stores/GuildMemberStore";
import RelationshipStore from "../../../../../../stores/RelationshipStore";
import UserStore from "../../../../../../stores/UserStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { SearchListItemTypes } from "../../../../SearchConstants";
import { RelationshipTypes } from "../../../../../../Constants";
import { intl, t } from "../../../../../../intl/index.native";
import ForwardingIcon from "../../../../../forwarding/native/ForwardingIcon";
import { LinkIcon } from "../../../../../../design/components/Icon/native/redesign/generated/LinkIcon";
import { EmbedIcon } from "../../../../../../design/components/Icon/native/redesign/generated/EmbedIcon";
import { PollsIcon } from "../../../../../../design/components/Icon/native/redesign/generated/PollsIcon";
import { AttachmentIcon } from "../../../../../../design/components/Icon/native/redesign/generated/AttachmentIcon";
import { VideoIcon } from "../../../../../../design/components/Icon/native/redesign/generated/VideoIcon";
import { ImageIcon } from "../../../../../../design/components/Icon/native/redesign/generated/ImageIcon";
import { SoundboardIcon } from "../../../../../../design/components/Icon/native/redesign/generated/SoundboardIcon";
import { StickerIcon } from "../../../../../../design/components/Icon/native/redesign/generated/StickerIcon";
import { UserIcon } from "../../../../../../design/components/Icon/native/redesign/generated/UserIcon";
import { RobotIcon } from "../../../../../../design/components/Icon/native/redesign/generated/RobotIcon";
import { WebhookIcon } from "../../../../../../design/components/Icon/native/redesign/generated/WebhookIcon";
import { getGuildIdFromSearchContext } from "../../../../SearchUtils";
import UserUtils from "../../../../../../utils/UserUtils";
export function getSearchQueryChannelIds(a0) {
return new Set(SearchQueryStore.getChannelIds(a0));
}
export function getSearchQueryUserIds(a0) {
const prefixTag = SearchQueryStore.getPrefixTag(a0);
if (prefixTag == null) {
return new Set();
}
return new Set(SearchQueryStore.getUserIds(a0, prefixTag.searchTokenType));
}
export function getSearchFilterHasIcon(a0) {
if (intl.string(t.nrpA5E) === a0) {
return ForwardingIcon;
}
if (intl.string(t.ZNR2fi) === a0) {
return LinkIcon;
}
if (intl.string(t["20uQR3"]) === a0) {
return EmbedIcon;
}
if (intl.string(t.L4lxyE) === a0) {
return PollsIcon;
}
if (intl.string(t["AV/v6i"]) === a0) {
return AttachmentIcon;
}
if (intl.string(t.XM9XGP) === a0) {
return VideoIcon;
}
if (intl.string(t.TNLcpx) === a0) {
return ImageIcon;
}
if (intl.string(t.F8Wf0e) === a0) {
return SoundboardIcon;
}
if (intl.string(t.PJgX2h) === a0) {
return StickerIcon;
}
}
export function getSearchFilterAuthorTypeIcon(a0) {
if (intl.string(t.tPZo4p) === a0) {
return UserIcon;
}
if (intl.string(t.JL7sRS) === a0) {
return RobotIcon;
}
if (intl.string(t.WjkIKU) === a0) {
return WebhookIcon;
}
}
export function toSearchListUserItem(a0, a1, a2) {
let guildId = getGuildIdFromSearchContext(a0);
if (a1 == null) {
return null;
}
let nickname = guildId == null ? RelationshipStore.getNickname(a1.id) : null;
if (nickname == null) {
nickname = GuildMemberStore.getNick(guildId, a1.id);
}
if (nickname == null) {
nickname = UserUtils.getName(a1);
}
if (guildId == null) {
guildId = void 0;
}
return {
type: SearchListItemTypes.DM,
props: {
type: RelationshipTypes.NONE,
user: a1,
nickname,
onPress: a2,
guildId
}
};
}
export function toSearchListChannelItem(a0, a1) {
let r16;
if (a0 == null) {
return null;
}
if (a0.isDM()) {
const user = UserStore.getUser(a0.getRecipientId());
const r0 = user == null;
let r23 = null;
if (!r0) {
let nickname = RelationshipStore.getNickname(user.id);
if (nickname == null) {
nickname = UserUtils.getName(user);
}
r23 = {
type: SearchListItemTypes.DM,
props: {
type: RelationshipTypes.NONE,
user,
nickname,
onPress: () => a1(a0.id)
}
};
}
return r23;
}
const isGroupDM = a0.isGroupDM();
const r4 = {
type: null,
props: null
};
if (isGroupDM) {
r4.type = SearchListItemTypes.GROUP_DM;
r4.props = {
channel: a0,
onPress: a1
};
r16 = r4;
} else {
r4.type = SearchListItemTypes.GUILD_TEXT_CHANNEL;
r4.props = {
channel: a0,
onPress: a1
};
r16 = r4;
}
return r16;
}
@@ -0,0 +1,29 @@
// Metro module 15473 (f15474).
import * as Module19 from "react";
import { useMemo } from "react";
import { SearchFilterAddLocations } from "../../../tracking/TrackingConstants";
import { useValidOrderedFilterTokens } from "../../../../tokens/hooks/useValidFilterTokens";
import { getSearchTokenLabel, getSearchTokenIcon, getSearchTokenPressHandler } from "./SearchFilterUtils";
import MobileVisualRefreshExperiment from "../../../../../themes/experiments/MobileVisualRefreshExperiment";
import { ContextMenu } from "../../../../../../design/components/ContextMenu/native/ContextMenu.native";
import { intl, t } from "../../../../../../intl/index.native";
import { IconButton } from "../../../../../../design/components/Button/native/IconButton.native";
import { FiltersHorizontalIcon } from "../../../../../../design/components/Icon/native/redesign/generated/FiltersHorizontalIcon";
const r23 = Module19.memo(function({ searchContext }) {
let c22041_2;
c22041_2 = void 0;
const validOrderedFilterTokens = useValidOrderedFilterTokens(searchContext);
const memo = useMemo(() => validOrderedFilterTokens.map((validOrderedFilterToken) => ({
label: getSearchTokenLabel(searchContext, validOrderedFilterToken),
IconComponent: getSearchTokenIcon(validOrderedFilterToken),
action: getSearchTokenPressHandler(searchContext, validOrderedFilterToken, SearchFilterAddLocations.CONTEXT_MENU)
})), [searchContext, validOrderedFilterTokens]);
c22041_2 = MobileVisualRefreshExperiment("SearchFilterButton");
return <ContextMenu items={memo} align="below" title={intl.string(t.oYEmhB)} keyboardShouldPersistTaps="handled">
{(a0) => {
const { ref, ...rest } = a0;
return <IconButton ref={a0.ref} {...rest} variant="tertiary" accessibilityLabel={intl.string(t.kP6oFy)} size={c22041_2 ? "md" : "sm"} icon={<FiltersHorizontalIcon size="sm" color="redesign-button-tertiary-text" />} />;
}}
</ContextMenu>;
});
export default r23;
@@ -0,0 +1,190 @@
// Metro module 15466 (f15467).
import * as Module19 from "react";
import { useMemo, useCallback, useEffect, useState, useRef } from "react";
import { View } from "react-native";
import { SearchFilterAddLocations } from "../../../tracking/TrackingConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import { getSearchTokenIcon, getSearchTokenSubLabel, getSearchFilterSuggestions, getSearchTokenPressHandler } from "./SearchFilterUtils";
import { TableRow } from "../../../../../../design/components/TableRow/native/TableRow.native";
import { Text } from "../../../../../../design/components/Text/native/Text";
import * as _ReanimatedRexport from "../../../../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedReaction } from "../../../../../reanimated/ReanimatedRexport";
import * as _spring from "../../../../../../design/animation/reanimated/spring/spring";
import * as _springPresets from "../../../../../../design/animation/reanimated/spring/springPresets";
import * as _TransitionGroup from "../../../../../../design/components/TransitionGroup/TransitionGroup";
import { TransitionGroup } from "../../../../../../design/components/TransitionGroup/TransitionGroup";
import { useValidFilterTokens } from "../../../../tokens/hooks/useValidFilterTokens";
import SearchPlatformUtils from "../../../SearchPlatformUtils";
function $mk96613() {
return (a0) => a0.text;
}
let useStyles, getSuggestionsKey, __initData, __initData2, AnimatedEnterExitContainer, EMPTY_SEARCH_FILTER_ROWS, __initData3, __initData4;
const SearchFilterPrefixRow = function SearchFilterPrefixRow(props) {
const { text, searchTokenType, onPress, ...props2 } = props;
const memo2 = useMemo(() => {
const SearchTokenIcon = getSearchTokenIcon(searchTokenType);
return SearchTokenIcon != null ? <SearchTokenIcon size="sm" /> : null;
}, [searchTokenType]);
const memo3 = useMemo(() => getSearchTokenSubLabel(searchTokenType), [searchTokenType]);
return <TableRow icon={memo2} onPress={useCallback(() => {
onPress(text);
}, [onPress, text])} label={<Text lineClamp={1} variant="text-md/semibold" color="mobile-text-heading-primary">{text}</Text>} subLabel={memo3} {...props2} />;
};
getSuggestionsKey = function getSuggestionsKey(a0) {
return a0.map($mk96613()).join(" ");
};
AnimatedEnterExitContainer = function AnimatedEnterExitContainer(props) {
const { children, state, cleanUp } = props;
const sharedValue = useSharedValue(0);
const l = () => {
const r10 = sharedValue.get();
const t = function t(a0) {
if (a0 ? state === _TransitionGroup.TransitionStates.YEETED : a0) {
_ReanimatedRexport.runOnJS(cleanUp)();
}
};
t.__closure = {
state,
TransitionStates: _TransitionGroup.TransitionStates,
runOnJS: _ReanimatedRexport.runOnJS,
cleanUp
};
t.__workletHash = 10696166249954;
t.__initData = __initData2;
return {
opacity: _spring.withSpring(r10, _springPresets.springStandard, "respect-motion-settings", t),
transform: [{
translateY: _spring.withSpring(sharedValue.get() === 1 ? 0 : -15, _springPresets.springStandard)
}]
};
};
l.__closure = {
withSpring: _spring.withSpring,
opacity: sharedValue,
springStandard: _springPresets.springStandard,
state,
TransitionStates: _TransitionGroup.TransitionStates,
runOnJS: _ReanimatedRexport.runOnJS,
cleanUp
};
l.__workletHash = 334512108462;
l.__initData = __initData;
const animatedStyle = useAnimatedStyle(l);
useEffect(() => {
sharedValue.set(state === _TransitionGroup.TransitionStates.YEETED ? 0 : 1);
}, [sharedValue, state]);
return <ReanimatedRexport.View style={animatedStyle}>{children}</ReanimatedRexport.View>;
};
useStyles = createStyles({
card: {
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGHEST,
borderRadius: Module712.radii.lg,
borderColor: Module712.colors.BORDER_SUBTLE,
borderWidth: 1,
...Module712.shadows.SHADOW_LOW
}
});
__initData = {
code: "function SearchFilterSuggestionsTsx1(){const{withSpring,opacity,springStandard,state,TransitionStates,runOnJS,cleanUp}=this.__closure;return{opacity:withSpring(opacity.get(),springStandard,'respect-motion-settings',function(finished){if(finished&&state===TransitionStates.YEETED){runOnJS(cleanUp)();}}),transform:[{translateY:withSpring(opacity.get()===1?0:-15,springStandard)}]};}"
};
__initData2 = {
code: "function SearchFilterSuggestionsTsx2(finished){const{state,TransitionStates,runOnJS,cleanUp}=this.__closure;if(finished&&state===TransitionStates.YEETED){runOnJS(cleanUp)();}}"
};
EMPTY_SEARCH_FILTER_ROWS = [];
__initData3 = {
code: "function SearchFilterSuggestionsTsx3(){const{dismissed}=this.__closure;return dismissed.get();}"
};
__initData4 = {
code: "function SearchFilterSuggestionsTsx4(isDismissed){const{runOnJS,setSuggestions,EMPTY_SEARCH_FILTER_ROWS}=this.__closure;if(isDismissed){runOnJS(setSuggestions)(EMPTY_SEARCH_FILTER_ROWS);}}"
};
const r61 = Module19.memo(function SearchFilterSuggestions(props) {
let memo, ref, callback;
const { searchContext, onLayoutMeasure, containerStyle, dismissed } = props;
memo = void 0;
ref = void 0;
callback = void 0;
const styles = useStyles();
const validFilterTokens = useValidFilterTokens(searchContext);
const [state2, setState] = useState([]);
useEffect(() => SearchPlatformUtils.subscribeSearchQueryState(searchContext, (a0) => ({
textInputValue: a0.getTextInputValue(),
isAutocompleteVisible: a0.isAutocompleteVisible()
}), (a0) => {
L6: {
const { textInputValue, isAutocompleteVisible } = a0;
if (textInputValue.trim() !== "" && !isAutocompleteVisible) {
let c30878_1;
const searchFilterSuggestions = getSearchFilterSuggestions(textInputValue);
if (searchFilterSuggestions.length !== 0) {
c30878_1 = [];
searchFilterSuggestions.forEach(({ text: text2, token }, index) => {
if (validFilterTokens.has(token)) {
c30878_1.push({
text: text2,
searchTokenType: token,
start: index === 0,
end: index === searchFilterSuggestions.length - 1,
onPress: getSearchTokenPressHandler(searchContext, token, SearchFilterAddLocations.SEARCH_INPUT_DROPDOWN)
});
}
});
setState((prevState) => {
const r4 = prevState.map($mk96613()).join(" ");
let r10 = c30878_1;
if (r4 === r10.map($mk96613()).join(" ")) {
r10 = prevState;
}
return r10;
});
break L6;
}
setState(EMPTY_SEARCH_FILTER_ROWS);
} else {
setState(EMPTY_SEARCH_FILTER_ROWS);
}
}
}), [validFilterTokens, searchContext, setState]);
const b = () => dismissed.get();
b.__closure = {
dismissed
};
b.__workletHash = 17191989548971;
b.__initData = __initData3;
const E = function E(a0) {
if (a0) {
_ReanimatedRexport.runOnJS(setState)(EMPTY_SEARCH_FILTER_ROWS);
}
};
E.__closure = {
runOnJS: _ReanimatedRexport.runOnJS,
setSuggestions: setState,
EMPTY_SEARCH_FILTER_ROWS
};
E.__workletHash = 8991360021943;
E.__initData = __initData4;
useAnimatedReaction(b, E);
memo = useMemo(() => [styles.card, containerStyle], [containerStyle, styles.card]);
ref = useRef(null);
callback = useCallback(() => {
setTimeout(() => {
const current = ref.current;
if (current != null) {
current.measure((a0, a1, a2, a3, a4, a5) => {
onLayoutMeasure({
top: a5,
bottom: a5 + a3,
left: a4,
right: a4 + a2
});
});
}
});
}, [onLayoutMeasure]);
return <TransitionGroup items={useMemo(() => state2.length > 0 ? [state2] : [], [state2])} renderItem={useCallback((a0, a1, a2, a3) => <AnimatedEnterExitContainer key={a0} state={a2} cleanUp={a3}>
<View ref={ref} style={memo} collapsable={false} onLayout={callback}>
{a1.map((item) => <SearchFilterPrefixRow key={item.text} {...item} />)}
</View>
</AnimatedEnterExitContainer>, [memo, callback])} getItemKey={getSuggestionsKey} />;
});
export default r61;
@@ -0,0 +1,189 @@
// Metro module 15467 (f15468).
import { EMPTY_SEARCH_QUERY_STRING, SearchQueryTagTypes } from "../../../../SearchConstants";
import { SearchFilterAddLocations } from "../../../tracking/TrackingConstants";
import { SEARCH_DATE_FORMAT, SearchTokenTypes, SearchTypes } from "../../../../../../Constants";
import { intl, t } from "../../../../../../intl/index.native";
import { UserIcon } from "../../../../../../design/components/Icon/native/redesign/generated/UserIcon";
import { AttachmentIcon } from "../../../../../../design/components/Icon/native/redesign/generated/AttachmentIcon";
import { ChannelListMagnifyingGlassIcon } from "../../../../../../design/components/Icon/native/redesign/generated/ChannelListMagnifyingGlassIcon";
import { AtIcon } from "../../../../../../design/components/Icon/native/redesign/generated/AtIcon";
import { CalendarIcon } from "../../../../../../design/components/Icon/native/redesign/generated/CalendarIcon";
import { CalendarMinusIcon } from "../../../../../../design/components/Icon/native/redesign/generated/CalendarMinusIcon";
import { CalendarPlusIcon } from "../../../../../../design/components/Icon/native/redesign/generated/CalendarPlusIcon";
import { RobotIcon } from "../../../../../../design/components/Icon/native/redesign/generated/RobotIcon";
import SearchTokens, { rebuildSearchTokenConfigs, isSearchFilterTokenType } from "../../../../tokens/SearchTokens";
import SearchPlatformActionCreators from "../../../SearchPlatformActionCreators";
import SearchPlatformUtils, { performKeyboardAwareNavigation } from "../../../SearchPlatformUtils";
import ActionSheetActionCreators from "../../../../../action_sheet/native/ActionSheetActionCreators";
import Tracking from "../../../tracking/Tracking";
export function getSearchTokenLabel(a0, a1) {
if (SearchTokenTypes.FILTER_FROM === a1) {
return intl.string(t["6iuVMn"]);
}
if (SearchTokenTypes.FILTER_HAS === a1) {
return intl.string(t.DMAzx8);
}
if (SearchTokenTypes.FILTER_MENTIONS === a1) {
return intl.string(t.CMKzQx);
}
if (SearchTokenTypes.FILTER_IN === a1) {
return a0.type === SearchTypes.DMS ? intl.string(t["8Fmo42"]) : intl.string(t.cdPmq8);
}
if (SearchTokenTypes.FILTER_ON === a1) {
return intl.string(t.h4qGfp);
}
if (SearchTokenTypes.FILTER_BEFORE === a1) {
return intl.string(t.c9qSBR);
}
if (SearchTokenTypes.FILTER_AFTER === a1) {
return intl.string(t.hcMwDW);
}
if (SearchTokenTypes.FILTER_AUTHOR_TYPE === a1) {
return intl.string(t.C4r6xL);
}
throw new Error(`[getSearchTokenLabel] Unhandled search token type: ${a1}`);
}
export function getSearchTokenSubLabel(a0) {
if (SearchTokenTypes.FILTER_FROM === a0) {
return intl.string(t.kkGlww);
}
if (SearchTokenTypes.FILTER_HAS === a0) {
return intl.string(t.gUfZa2);
}
if (SearchTokenTypes.FILTER_IN === a0) {
return intl.string(t.qDUdlT);
}
if (SearchTokenTypes.FILTER_MENTIONS === a0) {
return intl.string(t.ILtwK5);
}
if (SearchTokenTypes.FILTER_ON === a0) {
return intl.string(t.t8bWvr);
}
if (SearchTokenTypes.FILTER_BEFORE === a0) {
return intl.string(t.YEN3uU);
}
if (SearchTokenTypes.FILTER_AFTER === a0) {
return intl.string(t.hwbB7s);
}
if (SearchTokenTypes.FILTER_AUTHOR_TYPE === a0) {
return intl.string(t.tJPdhZ);
}
throw new Error(`[getSearchTokenSubLabel] Unhandled search token type: ${a0}`);
}
export function getSearchTokenIcon(a0) {
if (SearchTokenTypes.FILTER_FROM === a0) {
return UserIcon;
}
if (SearchTokenTypes.FILTER_HAS === a0) {
return AttachmentIcon;
}
if (SearchTokenTypes.FILTER_IN === a0) {
return ChannelListMagnifyingGlassIcon;
}
if (SearchTokenTypes.FILTER_MENTIONS === a0) {
return AtIcon;
}
if (SearchTokenTypes.FILTER_ON === a0) {
return CalendarIcon;
}
if (SearchTokenTypes.FILTER_BEFORE === a0) {
return CalendarMinusIcon;
}
if (SearchTokenTypes.FILTER_AFTER === a0) {
return CalendarPlusIcon;
}
if (SearchTokenTypes.FILTER_AUTHOR_TYPE === a0) {
return RobotIcon;
}
throw new Error(`[getSearchTokenIcon] Unhandled search token type: ${a0}`);
}
export function getSearchTokenPressHandler(c22037_0, a1, c22037_2) {
if (SearchTokenTypes.FILTER_FROM !== a1 && SearchTokenTypes.FILTER_IN !== a1 && SearchTokenTypes.FILTER_HAS !== a1 && SearchTokenTypes.FILTER_MENTIONS !== a1 && SearchTokenTypes.FILTER_AUTHOR_TYPE !== a1) {
if (SearchTokenTypes.FILTER_ON !== a1 && SearchTokenTypes.FILTER_BEFORE !== a1 && SearchTokenTypes.FILTER_AFTER !== a1) {
throw new Error(`[getSearchTokenPressHandler] Unhandled search token type: ${a1}`);
}
return () => {
const searchContext = c22037_0;
const searchTokenType2 = a1;
const location3 = c22037_2;
performKeyboardAwareNavigation(() => {
ActionSheetActionCreators.openLazy(import("../../../../../../components_native/DatePickerActionSheet"), "DatePicker", {
onSubmit: (a0) => {
let c32070_0 = a0.format(SEARCH_DATE_FORMAT);
SearchPlatformActionCreators.updateSearchQuery(searchContext, (a0) => {
if (location3 === SearchFilterAddLocations.SEARCH_INPUT_DROPDOWN) {
a0.setTextInputValue(EMPTY_SEARCH_QUERY_STRING);
}
a0.removePrefixTags();
const addTag = a0.addTag;
let r24 = SearchTokens[searchTokenType2];
if (r24 == null) {
rebuildSearchTokenConfigs();
r24 = SearchTokens[searchTokenType2];
}
let r31 = r24?.key;
if (r31 == null) {
r31 = searchTokenType2.toString();
}
addTag.call(a0, {
type: SearchQueryTagTypes.COMPLETE,
text: `${r31} ${c32070_0}`,
searchTokenType: searchTokenType2,
location: location3
});
});
Tracking.trackSearchFilterAdd({
searchContext,
searchTokenType: searchTokenType2,
location: location3
});
SearchPlatformUtils.fetchInitialMessages(searchContext);
}
});
});
};
}
return () => {
const searchTokenType = a1;
const location2 = c22037_2;
SearchPlatformActionCreators.updateSearchQuery(c22037_0, (a0) => {
if (location2 === SearchFilterAddLocations.CONTEXT_MENU) {
a0.saveDraftTextInputValue();
}
a0.setTextInputValue(EMPTY_SEARCH_QUERY_STRING);
const addTag = a0.addTag;
let r24 = SearchTokens[searchTokenType];
if (r24 == null) {
rebuildSearchTokenConfigs();
r24 = SearchTokens[searchTokenType];
}
let text = r24?.key;
if (text == null) {
text = searchTokenType.toString();
}
addTag.call(a0, {
type: SearchQueryTagTypes.PREFIX,
searchTokenType,
location: location2,
text
});
});
SearchPlatformUtils.syncAutocomplete(c22037_0);
};
}
export function getSearchFilterSuggestions(c22038_0) {
const r7 = [];
let c22038_1 = r7;
Object.keys(SearchTokens).forEach((item) => {
if (isSearchFilterTokenType(item)) {
const plainText = SearchTokens[item].plainText;
if (plainText != null && new RegExp(`^${plainText}(?:: ?)?\$`, "i").test(c22038_0)) {
c22038_1.push({
token: item,
text: plainText
});
}
}
});
return r7;
}
@@ -0,0 +1,71 @@
// Metro module 15461 (f15462).
import { useCallback, useEffect, useMemo } from "react";
import { useSharedValue } from "../../../../../reanimated/ReanimatedRexport";
import SearchPlatformUtils from "../../../SearchPlatformUtils";
import useSafeAreaInsets_native from "../../../../../safe_area/useSafeAreaInsets.native";
import { isAndroid } from "../../../../../../utils/PlatformUtils";
import { Gesture } from "../../../../../../_bundle/Module5273";
let inBoundingBox, __initData;
const inBoundingBox2 = function inBoundingBox(a0, a1, a2) {
const r4 = a0.allTouches[0];
return r4 != null && (a1.left < r4.absoluteX && r4.absoluteX < a1.right && a1.top < r4.absoluteY + a2 && r4.absoluteY + a2 < a1.bottom);
};
inBoundingBox2.__closure = {};
inBoundingBox2.__workletHash = 14606221606756;
inBoundingBox2.__initData = {
code: "function inBoundingBox_useSearchSuggestionsGestureTsx1(e,coordinates,safeAreaTop){const touch=e.allTouches[0];if(touch==null)return false;return coordinates.left<touch.absoluteX&&touch.absoluteX<coordinates.right&&coordinates.top<touch.absoluteY+safeAreaTop&&touch.absoluteY+safeAreaTop<coordinates.bottom;}"
};
inBoundingBox = inBoundingBox2;
__initData = {
code: "function useSearchSuggestionsGestureTsx2(e,manager){const{coordinates,inBoundingBox,safeAreaTop,dismissed}=this.__closure;manager.fail();const _coordinates=coordinates.get();if(_coordinates==null||inBoundingBox(e,_coordinates,safeAreaTop))return;dismissed.set(true);}"
};
export function useSearchSuggestionsGesture(a0) {
let top, memo, callback2, callback3;
let c22029_0 = a0;
const sharedValue = useSharedValue(false);
const sharedValue2 = useSharedValue(null);
const callback = useCallback((a0, a1) => {
if (a0 !== a1) {
sharedValue.set(false);
}
}, [sharedValue]);
useEffect(() => SearchPlatformUtils.subscribeTextInputValue(c22029_0, callback), [sharedValue, a0, callback]);
const top2 = useSafeAreaInsets_native().top;
top = isAndroid() ? top2 : 0;
memo = useMemo(() => {
const r4 = Gesture.Manual().manualActivation(true);
const e = function e(a0, a1) {
a1.fail();
const r14 = sharedValue2.get();
let r1 = r14 == null;
if (!r1) {
const r20 = a0.allTouches[0];
r1 = r20 != null && (r14.left < r20.absoluteX && r20.absoluteX < r14.right && r14.top < r20.absoluteY + top && r20.absoluteY + top < r14.bottom);
}
if (!r1) {
sharedValue.set(true);
}
};
e.__closure = {
coordinates: sharedValue2,
inBoundingBox,
safeAreaTop: top,
dismissed: sharedValue
};
e.__workletHash = 2369649298113;
e.__initData = __initData;
return r4.onTouchesDown(e);
}, [sharedValue2, top, sharedValue]);
callback2 = useCallback((a0) => {
sharedValue2.set(a0);
}, [sharedValue2]);
callback3 = useCallback(() => {
sharedValue.set(true);
}, [sharedValue]);
return useMemo(() => ({
gesture: memo,
dismissed: sharedValue,
onLayoutMeasure: callback2,
setDismissed: callback3
}), [sharedValue, callback3, memo, callback2]);
}
@@ -0,0 +1,184 @@
// Metro module 15488 (f15489).
import { memo, useRef } from "react";
import { StyleSheet, View } from "react-native";
import { SearchHistoryItemTypes, SearchListItemTypes } from "../../../SearchConstants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import DMRow from "./rows/DMRow";
import GroupDMRow from "./rows/GroupDMRow";
import SearchHistoryRow from "./rows/SearchHistoryRow";
import MediaGridItem from "./rows/MediaGridItem";
import MediaGridPlaceholder from "../tabs/pages/placeholders/MediaGridPlaceholder";
import FileOrLinkGridPlaceholder from "../tabs/pages/placeholders/FileOrLinkGridPlaceholder";
import MediaGrid from "./rows/MediaGrid";
import GuildTextChannelRow from "./rows/GuildTextChannelRow";
import GuildVoiceOrStageChannelRow from "./rows/GuildVoiceOrStageChannelRow";
import MessageRow from "./rows/MessageRow";
import FormRowPlaceholder from "../tabs/pages/placeholders/FormRowPlaceholder";
import LinkGridItem from "./rows/LinkGridItem";
import FileGridItem from "./rows/FileGridItem";
import GuildChannelMemberRow from "./rows/GuildChannelMemberRow";
import MemberRowPlaceholder from "../tabs/pages/placeholders/MemberRowPlaceholder";
import GenericTextRow from "./rows/GenericTextRow";
import SearchListSection from "./SearchListSection";
import useSafeAreaInsets_native from "../../../../safe_area/useSafeAreaInsets.native";
import ErrorScreen from "../tabs/pages/ErrorScreen";
import { intl, t } from "../../../../../intl/index.native";
import { AnimatedFlashList } from "../../../../../_bundle/noop_6676";
let useStyles, getItemType, renderItem;
const keyExtractor = function keyExtractor(a0) {
let r33, r115, type;
L40: {
type = a0.type;
const type2 = a0.type;
if (SearchListItemTypes.DM === type2) {
r33 = `${a0.section}-${a0.props.user.id}-${a0.props.guildId}`;
} else if (SearchListItemTypes.GUILD_CHANNEL_MEMBER === type2) {
r33 = `${a0.props.user.id}-${a0.props.guildId}`;
} else if (SearchListItemTypes.SEARCH_HISTORY_ITEM === type2) {
L37: {
const searchHistoryItem = a0.props.searchHistoryItem;
const type3 = searchHistoryItem.type;
if (SearchHistoryItemTypes.TEXT === type3) {
const { text, tags } = searchHistoryItem;
r115 = `${text} ${tags == null ? void 0 : tags.map((tag) => tag.text).join(" ")}`;
} else {
if (SearchHistoryItemTypes.GROUP_DM !== type3 && SearchHistoryItemTypes.GUILD_TEXT_CHANNEL !== type3 && SearchHistoryItemTypes.GUILD_VOICE_CHANNEL !== type3) {
const DM = SearchHistoryItemTypes.DM;
r115 = void 0;
if (DM !== type3) {
break L37;
}
r115 = `${searchHistoryItem.userId}`;
break L37;
}
r115 = `${searchHistoryItem.channelId}`;
}
}
r33 = r115;
} else if (SearchListItemTypes.MEDIA_GRID === type2) {
r33 = a0.props.media.map((item) => `${item.messageId}-${item.mediaIndex}`).join("-");
} else if (SearchListItemTypes.MEDIA === type2) {
r33 = `${a0.props.media.messageId}-${a0.props.media.mediaIndex}`;
} else {
if (SearchListItemTypes.MEDIA_PLACEHOLDER !== type2 && SearchListItemTypes.FILE_OR_LINK_PLACEHOLDER !== type2 && SearchListItemTypes.MESSAGE_PLACEHOLDER !== type2 && SearchListItemTypes.GUILD_CHANNEL_MEMBER_PLACEHOLDER !== type2) {
if (SearchListItemTypes.GROUP_DM === type2) {
r33 = `${a0.section}-${a0.props.channel.id}`;
break L40;
}
if (SearchListItemTypes.GUILD_TEXT_CHANNEL !== type2 && SearchListItemTypes.GUILD_VOICE_CHANNEL !== type2) {
if (SearchListItemTypes.MESSAGE === type2) {
r33 = `${a0.props.message.id}`;
break L40;
}
if (SearchListItemTypes.LINK === type2) {
r33 = `${a0.props.data.messageId}-${a0.props.data.linkIndex}`;
break L40;
}
if (SearchListItemTypes.FILE === type2) {
r33 = `${a0.props.data.messageId}-${a0.props.data.fileIndex}`;
break L40;
}
if (SearchListItemTypes.GENERIC === type2) {
r33 = `${a0.props.text}`;
break L40;
}
const SECTION = SearchListItemTypes.SECTION;
r33 = void 0;
if (SECTION !== type2) {
break L40;
}
r33 = `${a0.props.title}`;
break L40;
}
r33 = `${a0.props.channel.id}`;
break L40;
}
r33 = a0.key;
}
}
return `${type}-${r33}`;
};
getItemType = function getItemType(a0) {
return a0.type;
};
renderItem = function renderItem({ item }) {
const type = item.type;
if (SearchListItemTypes.DM === type) {
return <DMRow {...item.props} />;
}
if (SearchListItemTypes.GROUP_DM === type) {
return <GroupDMRow {...item.props} />;
}
if (SearchListItemTypes.SEARCH_HISTORY_ITEM === type) {
return <SearchHistoryRow {...item.props} />;
}
if (SearchListItemTypes.MEDIA === type) {
return <MediaGridItem {...item.props} />;
}
if (SearchListItemTypes.MEDIA_PLACEHOLDER === type) {
return <MediaGridPlaceholder {...item.props} />;
}
if (SearchListItemTypes.FILE_OR_LINK_PLACEHOLDER === type) {
return <FileOrLinkGridPlaceholder {...item.props} />;
}
if (SearchListItemTypes.MEDIA_GRID === type) {
return <MediaGrid {...item.props} />;
}
if (SearchListItemTypes.GUILD_TEXT_CHANNEL === type) {
return <GuildTextChannelRow {...item.props} />;
}
if (SearchListItemTypes.GUILD_VOICE_CHANNEL === type) {
return <GuildVoiceOrStageChannelRow {...item.props} />;
}
if (SearchListItemTypes.MESSAGE === type) {
return <MessageRow {...item.props} />;
}
if (SearchListItemTypes.MESSAGE_PLACEHOLDER === type) {
return <FormRowPlaceholder />;
}
if (SearchListItemTypes.LINK === type) {
return <LinkGridItem {...item.props} />;
}
if (SearchListItemTypes.FILE === type) {
return <FileGridItem {...item.props} />;
}
if (SearchListItemTypes.GUILD_CHANNEL_MEMBER === type) {
return <GuildChannelMemberRow {...item.props} />;
}
if (SearchListItemTypes.GUILD_CHANNEL_MEMBER_PLACEHOLDER === type) {
return <MemberRowPlaceholder />;
}
if (SearchListItemTypes.GENERIC === type) {
return <GenericTextRow {...item.props} />;
}
if (SearchListItemTypes.SECTION === type) {
return <SearchListSection {...item.props} />;
}
return null;
};
useStyles = createStyles({
container: {
flex: 1
}
});
const r38 = memo(function SearchList(props) {
const { contentContainerStyle, data, onEndReached, ItemSeparatorComponent, ListHeaderComponent, ListFooterComponent, numColumns } = props;
const ref = useRef(null);
const styles = useStyles();
const bottom = useSafeAreaInsets_native().bottom;
const onEndReachedThreshold = numColumns == null ? 0.5 : numColumns !== 1 ? numColumns !== 2 ? numColumns >= 3 ? 0.99 : void 0 : 0.8 : 0.5;
const r42 = data.length === 0 && ListFooterComponent == null && ListHeaderComponent == null;
return <View style={styles.container}>
{r42 && <View style={StyleSheet.absoluteFill}>
<ErrorScreen text={intl.string(t.V6nAfF)} />
</View>}
<AnimatedFlashList ref={ref} overrideProps={r42 ? {
importantForAccessibility: "no",
scrollEnabled: false
} : void 0} keyboardDismissMode="on-drag" keyboardShouldPersistTaps="handled" data={data} renderItem={renderItem} onEndReachedThreshold={onEndReachedThreshold} onEndReached={onEndReached} scrollsToTop contentContainerStyle={{
paddingBottom: 16 + bottom,
...contentContainerStyle
}} keyExtractor={keyExtractor} getItemType={getItemType} ListHeaderComponent={ListHeaderComponent} ListFooterComponent={ListFooterComponent} ItemSeparatorComponent={ItemSeparatorComponent} numColumns={numColumns} />
</View>;
});
export default r38;
@@ -0,0 +1,158 @@
// Metro module 15505 (f15506).
import { useMemo } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { Avatar, AvatarSizes, Icon } from "../../../../../design/void/native";
import { Text } from "../../../../../design/components/Text/native/Text";
import UserUtils from "../../../../../utils/UserUtils";
import useChannelName from "../../../../channel/useChannelName";
import GroupDMAvatar from "../../../../group_dm/native/GroupDMAvatar";
import { ForumIcon } from "../../../../../design/components/Icon/native/redesign/generated/ForumIcon";
import { intl, t } from "../../../../../intl/index.native";
import { getChannelIcon } from "../../../../../utils/native/ChannelUtils";
import { Card } from "../../../../../design/components/Card/native/Card.native";
let useStyles, SearchListPrivateChannel, SearchListGuildChannel;
const SearchListContentAuthor = function SearchListContentAuthor(props) {
const { author, avatarSource } = props;
const styles = useStyles();
return <View style={styles.author}>
<Avatar source={avatarSource} size={AvatarSizes.SIZE_16} style={styles.avatar} avatarDecoration={author.avatarDecoration} />
<Text style={styles.authorName} variant="text-xs/medium" color="interactive-text-default" lineClamp={1}>
{UserUtils.getName(author)}
</Text>
</View>;
};
SearchListPrivateChannel = function SearchListPrivateChannel(props) {
let r40;
const channel2 = props.channel;
const styles = useStyles();
const channelName = useChannelName(channel2);
const isGroupDM = channel2.isGroupDM();
const props2 = {
style: null,
children: null
};
if (isGroupDM) {
props2.style = styles.channel;
props2.children = [<View style={styles.gdmIcon}>
<GroupDMAvatar channel={channel2} size={AvatarSizes.SIZE_16} />
</View>, <Text style={styles.channelName} variant="text-xs/medium" color="interactive-text-default" lineClamp={1}>{channelName}</Text>];
r40 = <View {...props2} />;
} else {
props2.style = styles.privateChannelIcon;
props2.children = [<ForumIcon style={styles.icon} size="xs" color="interactive-text-default" />, <Text variant="text-xs/medium" color="interactive-text-default" lineClamp={1}>
{intl.string(t.ACgJhM)}
</Text>];
r40 = <View {...props2} />;
}
return r40;
};
SearchListGuildChannel = function SearchListGuildChannel(props) {
const channel2 = props.channel;
const styles = useStyles();
const channelName = useChannelName(channel2);
return <View style={styles.channel}>
<Icon size={Icon.Sizes.REFRESH_SMALL_16} source={getChannelIcon(channel2, {
ignoreTraits: true
})} color={styles.channelIcon.color} />
<Text style={styles.channelName} variant="text-xs/medium" color="interactive-text-default" lineClamp={1}>{channelName}</Text>
</View>;
};
useStyles = createStyles({
channelName: {
flexShrink: 1,
marginStart: 4
},
channelIcon: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
avatar: {
marginRight: 2
},
channel: {
flexDirection: "row",
alignItems: "center"
},
author: {
flexDirection: "row",
alignItems: "center"
},
authorName: {
flexShrink: 1,
marginStart: 2
},
container: {
flex: 1,
padding: 0,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
overflow: "hidden"
},
content: {
paddingTop: 12,
paddingHorizontal: 12,
paddingBottom: 4
},
footer: {
flexDirection: "column",
paddingTop: 4,
paddingHorizontal: 12,
paddingBottom: 12,
gap: 4
},
thumbnail: {
flex: 1,
overflow: "hidden",
borderTopRightRadius: Module712.radii.lg,
borderTopLeftRadius: Module712.radii.lg,
backgroundColor: Module712.colors.BACKGROUND_MOD_SUBTLE,
borderBottomWidth: 1,
borderBottomColor: Module712.colors.BORDER_SUBTLE
},
privateChannelIcon: {
flexDirection: "row",
alignItems: "center"
},
icon: {
marginRight: 4
},
gdmIcon: {
width: 18
}
});
export { SearchListContentAuthor };
export { SearchListGuildChannel };
export function SearchListCardContainer(props) {
const { children, onPress, containerStyle } = props;
return <Card shadow="low" border="subtle" onPress={onPress} style={[useStyles().container, containerStyle]}>{children}</Card>;
}
export function SearchListCardThumbnail(props) {
const thumbnail = props.thumbnail;
return <View style={useStyles().thumbnail}>{thumbnail}</View>;
}
export function SearchListCardContent(props) {
const { label, subLabel } = props;
const props2 = {
style: useStyles().content,
children: null
};
let r5 = label;
if (typeof r5 === "string") {
r5 = <Text variant="text-md/semibold" color="mobile-text-heading-primary" lineClamp={1}>{label}</Text>;
}
const children = [r5, ,];
let r20 = subLabel;
if (typeof r20 === "string") {
r20 = <Text variant="text-sm/normal" color="text-default" lineClamp={1}>{subLabel}</Text>;
}
children[1] = r20;
props2.children = children;
return <View {...props2} />;
}
export function SearchListCardFooter(props) {
const { author, avatarSource, channel } = props;
return <View style={useStyles().footer}>
<SearchListContentAuthor author={author} avatarSource={avatarSource} />
{useMemo(() => channel == null ? null : channel.getGuildId() == null ? <SearchListPrivateChannel channel={channel} /> : <SearchListGuildChannel channel={channel} />, [channel])}
</View>;
}
@@ -0,0 +1,58 @@
// Metro module 15490 (f15491).
import { memo } from "react";
import { View } from "react-native";
import { SEARCH_ROW_TAP_STATE_PADDING } from "../../../SearchConstants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { PressableHighlight } from "../../../../../design/void/Pressables/native/Pressables";
import { Text } from "../../../../../design/components/Text/native/Text";
const useStyles = createStyles((a0) => ({
pressable: {
paddingHorizontal: 16,
paddingVertical: SEARCH_ROW_TAP_STATE_PADDING
},
body: {
flexDirection: "row",
alignItems: "center"
},
labels: {
justifyContent: "center",
flex: 1
},
underlayColor: {
backgroundColor: Module712.colors.INTERACTIVE_BACKGROUND_ACTIVE
},
text: {
flexShrink: 1
},
iconContainer: {
marginRight: 12
},
extrasContainer: {
marginLeft: a0
}
}));
const r32 = memo(function(a0) {
const { containerStyle, onPress, label, subLabel, icon, iconContainerStyle } = a0;
let iconWidth = a0.iconWidth;
const { trailing, extras, header, accessible = true, accessibilityRole = "button", accessibilityLabel, accessibilityHint, accessibilityActions, onAccessibilityAction, bodyStyle } = a0;
if (iconWidth == null) {
iconWidth = 0;
}
const styles = useStyles(iconWidth);
const r35 = [header, , ,];
const r45 = [<View style={[styles.iconContainer, iconContainerStyle]}>{icon}</View>, , ,];
let r48 = label;
if (typeof r48 === "string") {
r48 = <Text lineClamp={1} variant="text-md/semibold" color="mobile-text-heading-primary" style={styles.text}>{label}</Text>;
}
r45[1] = <View style={styles.labels}>
{r48}
{subLabel}
</View>;
r45[2] = trailing;
r35[1] = <View style={[styles.body, bodyStyle]}>{r45}</View>;
r35[2] = extras != null && <View style={[styles.extrasContainer]}>{extras}</View>;
return <PressableHighlight accessible={accessible} accessibilityRole={accessibilityRole} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} style={[styles.pressable, containerStyle]} onPress={onPress} unstable_pressDelay={130} underlayColor={styles.underlayColor.backgroundColor}>{r35}</PressableHighlight>;
});
export { r32 as SearchListRow };
@@ -0,0 +1,26 @@
// Metro module 15519 (f15520).
import { memo } from "react";
import { View } from "react-native";
import { SEARCH_LIST_SECTION_TOP_PADDING } from "../../../SearchConstants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import { Text } from "../../../../../design/components/Text/native/Text";
const useStyles = createStyles({
section: {
flex: 1,
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
textTransform: "none",
paddingTop: SEARCH_LIST_SECTION_TOP_PADDING,
paddingHorizontal: 16,
paddingBottom: 8
}
});
const r32 = memo(function({ title, trailing }) {
return <View style={useStyles().section}>
<Text maxFontSizeMultiplier={2} accessibilityRole="header" variant="text-sm/semibold" color="interactive-text-default">{title}</Text>
{trailing}
</View>;
});
export default r32;
@@ -0,0 +1,145 @@
// Metro module 15503 (f15504).
import _slicedToArray from "../../../../../_bundle/_slicedToArray";
import * as Module19 from "react";
import { useMemo } from "react";
import { ImageBackground, StyleSheet, View } from "react-native";
import SearchMessageStore from "../../../SearchMessageStore";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import useTheme from "../../../../../hooks/useTheme";
import { isThemeDark } from "../../../../../design/shared";
import { ObscureReason } from "../../../../explicit_media_redaction/ObscureMediaModels";
import { SpoilerIcon } from "../../../../../design/components/Icon/native/redesign/generated/SpoilerIcon";
import { ImageWarningIcon } from "../../../../../design/components/Icon/native/redesign/generated/ImageWarningIcon";
import VisualEffectView from "../../../../visual_effect_view/native/VisualEffectView";
import { getSrcWithWidthAndHeight } from "../../../../../utils/native/ImageUtils";
import { getObscuredAlt, getObscureReasonForAttachment, getObscureReasonForEmbed, getObscureReasonForUnfurledMediaItem } from "../../../../messages/MessageAttachmentUtils";
import { isAndroid } from "../../../../../utils/PlatformUtils";
import { intl, t } from "../../../../../intl/index.native";
import { ImageWithPlaceholder } from "../../../../../components_native/common/ImageWithPlaceholder";
import { useEnabledHarmTypesBitmaskForChannelAndAuthorId } from "../../../../explicit_media_redaction/hooks/useContentHarmTypes";
import { getAttachmentUrl, flattenSource, getEmbedMedia, getEmbedUrl } from "../../../../media_viewer/native/MediaSourceUtil";
import { useStateFromStores } from "../../../../../_bundle/Module589";
import { CirclePlayIcon } from "../../../../../design/components/Icon/native/redesign/generated/CirclePlayIcon";
import { AttachmentIcon } from "../../../../media/native/AttachmentPreview";
let useStyles, Component;
const SearchMediaObscurityIcon = function SearchMediaObscurityIcon(props) {
const { obscureReason, height, width } = props;
const styles = useStyles();
const blurTheme = isThemeDark(useTheme()) ? "dark" : "light";
const memo = useMemo(() => ({
height,
width
}), [height, width]);
const memo2 = useMemo(() => {
if (ObscureReason.SPOILER === obscureReason) {
return <SpoilerIcon size="lg" />;
}
if (ObscureReason.EXPLICIT_CONTENT !== obscureReason && ObscureReason.GORE_CONTENT !== obscureReason && ObscureReason.SELF_HARM_CONTENT !== obscureReason) {
if (ObscureReason.POTENTIAL_EXPLICIT_CONTENT === obscureReason) {
return null;
}
return void 0;
}
return <ImageWarningIcon size="lg" />;
}, [obscureReason]);
return <>
<VisualEffectView blurTheme={blurTheme} style={[StyleSheet.absoluteFill, memo]} />
{memo2 != null && <View style={[StyleSheet.absoluteFill, styles.container]}>{memo2}</View>}
</>;
};
useStyles = createStyles({
container: {
justifyContent: "center",
alignItems: "center"
},
sound: {
justifyContent: "center",
alignItems: "center"
}
});
Component = Module19.memo(function({ mediaUrl, mediaHeight, mediaWidth, containerStyle, placeholder, placeholderVersion, renderFallback, obscureReason: obscureReason2, containerHeight, containerWidth, scale }) {
const memo = useMemo(() => ({
height: containerHeight,
width: containerWidth
}), [containerHeight, containerWidth]);
if (mediaUrl != null && mediaHeight != null && mediaWidth != null) {
const r26 = containerHeight * scale;
const r27 = containerWidth * scale;
const r42 = _slicedToArray(mediaWidth > mediaHeight ? [Math.round(mediaWidth * (r27 / mediaHeight)), r27] : [r26, Math.round(mediaHeight * (r26 / mediaWidth))], 2);
const srcWithWidthAndHeight = getSrcWithWidthAndHeight({
src: mediaUrl,
sourceWidth: mediaWidth,
sourceHeight: mediaHeight,
targetWidth: r42[0],
targetHeight: r42[1],
format: "png"
});
const obscuredAlt = getObscuredAlt(obscureReason2);
const r54 = obscureReason2 != null ? <SearchMediaObscurityIcon obscureReason={obscureReason2} height={containerHeight} width={containerWidth} /> : null;
if (isAndroid() && obscureReason2 != null) {
return <View style={containerStyle}>
<ImageBackground style={memo} source={{
uri: srcWithWidthAndHeight
}} blurRadius={10} resizeMode="cover" accessibilityLabel={obscuredAlt} />
{r54}
</View>;
}
return <View style={containerStyle}>
<ImageWithPlaceholder style={memo} uri={srcWithWidthAndHeight} placeholder={placeholder} placeholderVersion={placeholderVersion} alt={isAndroid() ? intl.string(t.jes7FG) : obscuredAlt} />
{r54}
</View>;
}
return renderFallback != null ? <>
{renderFallback()}
</> : null;
});
export function SearchAttachmentMediaImage(props) {
const { attachment, channelId, authorId, ...props2 } = props;
const enabledHarmTypesBitmaskForChannelAndAuthorId = useEnabledHarmTypesBitmaskForChannelAndAuthorId(channelId, authorId);
return <Component {...props2} obscureReason={useMemo(() => getObscureReasonForAttachment(attachment, enabledHarmTypesBitmaskForChannelAndAuthorId), [attachment, enabledHarmTypesBitmaskForChannelAndAuthorId])} mediaUrl={getAttachmentUrl(attachment)} mediaHeight={attachment.height} mediaWidth={attachment.width} />;
}
export function SearchEmbedMediaImage(props) {
const { embed, sources, messageId, channelId, authorId, ...props2 } = props;
const enabledHarmTypesBitmaskForChannelAndAuthorId2 = useEnabledHarmTypesBitmaskForChannelAndAuthorId(channelId, authorId);
const stateFromStores = useStateFromStores([SearchMessageStore], () => {
const message = SearchMessageStore.getMessage(messageId);
if (message == null) {
return null;
}
let r22 = flattenSource(sources, false)?.spoiler;
if (r22 == null) {
r22 = false;
}
return getObscureReasonForEmbed(embed, message, r22, enabledHarmTypesBitmaskForChannelAndAuthorId2);
});
const thumbnail = embed.thumbnail;
const embedMedia = getEmbedMedia(embed);
let mediaUrl = embedMedia != null ? getEmbedUrl(embedMedia) : null;
if (thumbnail != null) {
mediaUrl = thumbnail.url;
}
return <Component {...props2} obscureReason={stateFromStores} mediaUrl={mediaUrl} mediaHeight={thumbnail != null ? thumbnail.height : embedMedia?.height} mediaWidth={thumbnail != null ? thumbnail.width : embedMedia?.width} />;
}
export function SearchSoundMediaImage(props) {
const { height: height2, width: width2, containerStyle } = props;
return <View style={[useStyles().sound, containerStyle, useMemo(() => ({
height: height2,
width: width2
}), [height2, width2])]}>
<CirclePlayIcon size="lg" color="interactive-text-default" />
</View>;
}
export function SearchFileMediaImage(props) {
const { fileName, height: height3, width: width3, containerStyle } = props;
return <View style={[useStyles().sound, containerStyle, useMemo(() => ({
height: height3,
width: width3
}), [height3, width3])]}>
<AttachmentIcon fileName={fileName} />
</View>;
}
export function SearchComponentMediaImage(props) {
const { unfurledMediaItem, sources: sources2, channelId, authorId, isBot, ...props2 } = props;
const enabledHarmTypesBitmaskForChannelAndAuthorId3 = useEnabledHarmTypesBitmaskForChannelAndAuthorId(channelId, authorId);
return <Component {...props2} obscureReason={useMemo(() => getObscureReasonForUnfurledMediaItem(unfurledMediaItem, enabledHarmTypesBitmaskForChannelAndAuthorId3, !!flattenSource(sources2)?.spoiler, isBot), [unfurledMediaItem, enabledHarmTypesBitmaskForChannelAndAuthorId3, sources2, isBot])} mediaUrl={unfurledMediaItem.proxyUrl} mediaHeight={unfurledMediaItem.height} mediaWidth={unfurledMediaItem.width} />;
}
@@ -0,0 +1,139 @@
// Metro module 15489 (f15490).
import * as Module19 from "react";
import { useState, useCallback, useMemo } from "react";
import { ActivityIndicator, View } from "react-native";
import AccessibilityStore from "../../../../../a11y/AccessibilityStore";
import PresenceStore from "../../../../../../stores/PresenceStore";
import RelationshipStore from "../../../../../../stores/RelationshipStore";
import { RelationshipTypes, StatusTypes } from "../../../../../../Constants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import { Text } from "../../../../../../design/components/Text/native/Text";
import UserUtils, { getUserTag } from "../../../../../../utils/UserUtils";
import ActivityStatus from "../../../../../activity_status/native/ActivityStatus";
import { useStateFromStoresObject, useStateFromStores } from "../../../../../../_bundle/Module589";
import BotTag from "../../../../../applications/native/BotTag";
import { Icon, Avatar, AvatarSizes } from "../../../../../../design/void/native";
import Module8287 from "../../../../../../_bundle/Module8287";
import Module12532 from "../../../../../../_bundle/Module12532";
import { SearchListRow } from "../SearchListRow";
let useStyles;
const FriendPresence = function FriendPresence(props) {
const { user: user2, type: type2, animate, guildId: guildId2 } = props;
const styles2 = useStyles();
return type2 === RelationshipTypes.PENDING_INCOMING ? <Text lineClamp={1} variant="text-sm/medium" color="text-default">
{getUserTag(user2)}
</Text> : <ActivityStatus userId={user2.id} guildId={guildId2} iconStyle={styles2.activityStatusIcon} textStyle={styles2.activityStatusText} emojiSize={16} animate={animate} />;
};
useStyles = createStyles({
activityStatusIcon: {
width: 14,
height: 14
},
activityStatusText: {
color: Module712.colors.TEXT_SUBTLE,
fontSize: 14,
lineHeight: 18,
fontWeight: "400"
},
tag: {
marginLeft: 4
},
title: {
flexDirection: "row"
}
});
const r53 = Module19.memo(function DMRow(props) {
let isMobileOnline, isVROnline, status, stateFromStores, name;
const user = props.user;
let nickname = props.nickname;
const { premiumSince, isOwner, type, guildId, onPress } = props;
let trailing = props.trailing;
const { accessibilityActions, onAccessibilityAction } = props;
isMobileOnline = void 0;
isVROnline = void 0;
status = void 0;
stateFromStores = void 0;
name = void 0;
const styles = useStyles();
const [state, setState] = useState(false);
const stateFromStoresObject = useStateFromStoresObject([PresenceStore], () => ({
isMobileOnline: PresenceStore.isMobileOnline(user.id),
isVROnline: PresenceStore.isVROnline(user.id),
status: PresenceStore.getStatus(user.id)
}));
isMobileOnline = stateFromStoresObject.isMobileOnline;
isVROnline = stateFromStoresObject.isVROnline;
status = stateFromStoresObject.status;
stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
const stateFromStores2 = useStateFromStores([RelationshipStore], () => {
let r1 = nickname;
if (r1 == null) {
r1 = RelationshipStore.getNickname(user.id);
}
return r1;
});
nickname = stateFromStores2;
const callback = useCallback(async () => {
let c28058_2;
let c28058_3 = 0;
try {
setState(true);
c28058_3 = 1;
await onPress(user.id);
c28058_3 = 0;
(0, setState)(false);
} catch ($e) {
const r22 = $e;
let r7 = r22;
c28058_2 = r22;
if (c28058_3 !== 0) {
while (true) {
try {
const r56 = c28058_2;
c28058_3 = 0;
(0, setState)(false);
throw r56;
} catch (r53) {
r7 = r53;
c28058_2 = r53;
if (c28058_3 === 0) {
break;
}
}
}
}
throw r7;
}
}, [onPress, user.id]);
let r59 = stateFromStores2;
if (r59 == null) {
r59 = UserUtils.getName(user);
}
name = r59;
const memo = useMemo(() => {
const r22 = [<Text lineClamp={1} variant="text-md/semibold" color="mobile-text-heading-primary">{name}</Text>, , , ,];
r22[1] = user.bot && <BotTag style={styles.tag} verified={user.isVerifiedBot()} type={user.isSystemUser() ? BotTag.Types.SYSTEM_DM : BotTag.Types.BOT} />;
let r34 = isOwner;
if (isOwner) {
r34 = <View style={styles.tag}>
<Icon size={Icon.Sizes.REFRESH_SMALL_16} source={Module8287} disableColor />
</View>;
}
r22[2] = r34;
r22[3] = premiumSince != null && <View style={styles.tag}>
<Icon size={Icon.Sizes.REFRESH_SMALL_16} source={Module12532} disableColor />
</View>;
return <View style={styles.title}>{r22}</View>;
}, [styles.title, styles.tag, name, user, isOwner, premiumSince]);
const memo2 = useMemo(() => <Avatar user={user} guildId={guildId} status={StatusTypes.OFFLINE !== status ? status : null} isMobileOnline={isMobileOnline} isVROnline={isVROnline} size={AvatarSizes.LARGE_48} avatarDecoration={user.avatarDecoration} autoStatusCutout />, [user, status, isMobileOnline, isVROnline, guildId]);
const memo3 = useMemo(() => {
const userTag = UserUtils.getUserTag(user);
return userTag != null && !user.isProvisional ? <Text variant="text-sm/medium" color="text-muted">{userTag}</Text> : type != null ? <FriendPresence user={user} guildId={guildId} type={type} animate={!stateFromStores} /> : null;
}, [user, guildId, type, stateFromStores]);
if (state) {
trailing = <ActivityIndicator />;
}
return <SearchListRow label={memo} subLabel={memo3} icon={memo2} onPress={callback} trailing={trailing} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} />;
});
export default r53;
@@ -0,0 +1,64 @@
// Metro module 15515 (f15516).
import * as Module19 from "react";
import { useMemo, useCallback } from "react";
import { View, useWindowDimensions } from "react-native";
import ChannelStore from "../../../../../../stores/ChannelStore";
import { FILE_OR_LINK_IMAGE_BUFFER, SearchFileTypes } from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import { isImageFile, isVideoFile } from "../../../../../messages/MediaFormatTesters";
import { ImageIcon } from "../../../../../../design/components/Icon/native/redesign/generated/ImageIcon";
import { VideoIcon } from "../../../../../../design/components/Icon/native/redesign/generated/VideoIcon";
import { FileIcon } from "../../../../../../design/components/Icon/native/redesign/generated/FileIcon";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import getDisplayFilename from "../../../../../messages/getDisplayFilename";
import { SearchAttachmentMediaImage, SearchFileMediaImage, SearchSoundMediaImage } from "../SearchMediaImage";
import { SearchListCardContainer, SearchListCardThumbnail, SearchListCardContent, SearchListCardFooter } from "../SearchListCard";
import { sizeString } from "../../../../../../utils/FileUtils";
const useStyles = createStyles({
icon: {
alignItems: "center",
justifyContent: "center"
}
});
const r37 = Module19.memo(function FileGridItem(props) {
let fileName;
const { data, onPress, imageStyle, containerStyle } = props;
fileName = void 0;
const styles = useStyles();
const scale = useWindowDimensions().scale;
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(data.channelId));
const r30 = [data.author, ,];
const guild_id = stateFromStores?.guild_id;
const r32 = () => data.author.getAvatarSource(stateFromStores?.guild_id);
r30[1] = guild_id;
const memo = useMemo(r32, r30);
fileName = getDisplayFilename(data.attachment);
const size = data.attachment.size;
return <SearchListCardContainer containerStyle={containerStyle} onPress={useCallback(() => {
onPress({
channelId: data.channelId,
messageId: data.messageId
});
}, [data.channelId, data.messageId, onPress])}>
<SearchListCardThumbnail thumbnail={useMemo(() => {
const type = data.type;
if (SearchFileTypes.MEDIA_ATTACHMENT === type) {
return <SearchAttachmentMediaImage containerStyle={imageStyle} attachment={data.attachment} channelId={data.channelId} authorId={data.author.id} scale={scale} containerHeight={imageStyle.height + FILE_OR_LINK_IMAGE_BUFFER} containerWidth={imageStyle.width + FILE_OR_LINK_IMAGE_BUFFER} renderFallback={() => {
const filename = data.attachment.filename;
return <View style={[styles.icon, imageStyle]}>
{isImageFile(filename) ? <ImageIcon size="lg" color="interactive-text-default" /> : isVideoFile(filename) ? <VideoIcon size="lg" color="interactive-text-default" /> : <FileIcon size="lg" color="interactive-text-default" />}
</View>;
}} />;
}
if (SearchFileTypes.ATTACHMENT === type) {
return <SearchFileMediaImage fileName={fileName} containerStyle={imageStyle} height={imageStyle.height} width={imageStyle.width} />;
}
if (SearchFileTypes.AUDIO === type) {
return <SearchSoundMediaImage containerStyle={imageStyle} height={imageStyle.height} width={imageStyle.width} />;
}
}, [data, fileName, imageStyle, scale, styles.icon])} />
<SearchListCardContent label={fileName} subLabel={size > 0 ? sizeString(size) : void 0} />
<SearchListCardFooter author={data.author} avatarSource={memo} channel={stateFromStores} />
</SearchListCardContainer>;
});
export default r37;
@@ -0,0 +1,26 @@
// Metro module 15518 (f15519).
import { memo, useCallback } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import { Text } from "../../../../../../design/components/Text/native/Text";
import { SearchListRow } from "../SearchListRow";
const useStyles = createStyles({
title: {
flexDirection: "row"
},
container: {
padding: 10
}
});
const r32 = memo(function GenericTextRow(props) {
const { text, icon: Icon, onPress, trailing, accessibilityActions, onAccessibilityAction } = props;
const styles = useStyles();
const callback = useCallback(async () => {
await onPress(text);
}, [onPress, text]);
const label = <View style={styles.title}>
<Text lineClamp={1} variant="text-md/medium" color="mobile-text-heading-primary" style={styles.container}>{text}</Text>
</View>;
return <SearchListRow icon={Icon != null && <Icon size="sm" color="mobile-text-heading-primary" />} label={label} onPress={callback} trailing={trailing} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} />;
});
export default r32;
@@ -0,0 +1,23 @@
// Metro module 15491 (f15492).
import { useCallback } from "react";
import useChannelName from "../../../../../channel/useChannelName";
import GroupDMAvatar from "../../../../../group_dm/native/GroupDMAvatar";
import { AvatarSizes } from "../../../../../../design/void/native";
import { useRecipientsLabel } from "../../../../../main_tabs_v2/useRecipientsLabel";
import { Text } from "../../../../../../design/components/Text/native/Text";
import { SearchListRow } from "../SearchListRow";
export default function GroupDMRow(props) {
const { channel, trailing, onPress, onAccessibilityAction, accessibilityActions } = props;
let accessibilityLabel = useChannelName(channel);
const callback = useCallback(() => {
onPress(channel.id);
}, [channel.id, onPress]);
const icon = <GroupDMAvatar size={AvatarSizes.LARGE_48} channel={channel} />;
const recipientsLabel = useRecipientsLabel(channel);
const subLabel = recipientsLabel != null ? <Text variant="text-xs/medium" color="text-muted" lineClamp={1}>{recipientsLabel}</Text> : void 0;
const label = accessibilityLabel == null ? "" : accessibilityLabel;
if (accessibilityLabel == null) {
accessibilityLabel = "";
}
return <SearchListRow label={label} icon={icon} onPress={callback} accessibilityLabel={accessibilityLabel} subLabel={subLabel} trailing={trailing} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} />;
};
@@ -0,0 +1,5 @@
// Metro module 15516 (f15517).
import UserRow from "../../../../../main_tabs_v2/native/shared_components/user_list/UserRow";
export default function GuildChannelMemberRow(props) {
return <UserRow {...props} />;
};
@@ -0,0 +1,51 @@
// Metro module 15497 (f15498).
import { memo } from "react";
import { Image as Image2, View } from "react-native";
import { CHANNEL_LIST_SEARCH_LAYOUT } from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import useChannelName from "../../../../../channel/useChannelName";
import { renderChannelContent } from "../../../../../main_tabs_v2/native/shared_components/guild_channels/ChannelContent";
import { getSimpleChannelIcon } from "../../../../../../utils/native/ChannelUtils";
import { getChannelAccessibilityProps } from "../../../../../main_tabs_v2/native/shared_components/guild_channels/ChannelItem";
import { SearchListRow } from "../SearchListRow";
let useStyles;
const GuildChannelLabel = function GuildChannelLabel(props) {
const channel = props.channel;
return <View style={useStyles().content}>
{renderChannelContent({
channel,
layout: CHANNEL_LIST_SEARCH_LAYOUT,
name: useChannelName(channel)
})}
</View>;
};
useStyles = createStyles({
container: {
paddingVertical: 10
},
content: {
flexDirection: "row",
alignItems: "center"
},
iconContainer: {
marginRight: 0
},
simpleIcon: {
width: 20,
height: 20,
marginRight: 8,
tintColor: Module712.colors.TEXT_MUTED
}
});
const r41 = memo(function GuildChannelRow(props) {
const { channel, subtitle, trailing, extras, onPress, voiceStates, ...props2 } = props;
const styles = useStyles();
return <SearchListRow {...getChannelAccessibilityProps({
channel,
unread: false,
mentionCount: 0,
voiceStates
})} {...props2} containerStyle={styles.container} iconContainerStyle={styles.iconContainer} icon={<Image2 style={styles.simpleIcon} source={getSimpleChannelIcon(channel)} />} iconWidth={32} label={<GuildChannelLabel channel={channel} />} subLabel={subtitle} onPress={onPress} trailing={trailing} extras={extras} />;
});
export default r41;
@@ -0,0 +1,34 @@
// Metro module 15501 (f15502).
import { memo, useMemo, useCallback } from "react";
import { CHANNEL_LIST_SEARCH_LAYOUT } from "../../../../SearchConstants";
import SnowflakeUtils from "../../../../../../utils/SnowflakeUtils";
import { renderChannelSubtitle } from "../../../../../main_tabs_v2/native/shared_components/guild_channels/ChannelSubtitle";
import { getChannelActiveAgoTimestamp } from "../../../../SearchUtils";
import GuildChannelRow from "./GuildChannelRow";
import { HermesBuiltin } from "../../../../../../_hermes/prelude";
const r23 = memo(function GuildTextChannelRow(props) {
const { channel, trailing, lastMessageId, onPress } = props;
const r16 = {};
let r4 = null;
const props2 = HermesBuiltin.copyDataProperties(r16, props, {
__proto__: null,
channel: 0,
trailing: 0,
lastMessageId: 0,
onPress: 0
});
const { id, guild_id } = channel;
if (lastMessageId != null) {
r4 = SnowflakeUtils.extractTimestamp(lastMessageId);
}
let c22086_4 = r4;
return <GuildChannelRow {...props2} subtitle={useMemo(() => renderChannelSubtitle({
subtitle: c22086_4 != null ? getChannelActiveAgoTimestamp(c22086_4) : null,
layout: CHANNEL_LIST_SEARCH_LAYOUT,
channelId: id,
guildId: guild_id
}), [id, guild_id, r4])} channel={channel} trailing={trailing} onPress={useCallback(() => {
onPress(channel.id);
}, [channel.id, onPress])} />;
});
export default r23;
@@ -0,0 +1,144 @@
// Metro module 15493 (f15494).
import { useMemo, memo, useCallback } from "react";
import { View } from "react-native";
import StageInstanceStore from "../../../../../stage_channels/StageInstanceStore";
import { CHANNEL_LIST_SEARCH_LAYOUT } from "../../../../SearchConstants";
import * as _ChannelListLayout from "../../../../../main_tabs_v2/native/shared_components/guild_channels/layouts/ChannelListLayout";
import UserUtils from "../../../../../../utils/UserUtils";
import { t, intl } from "../../../../../../intl/index.native";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import { renderChannelSubtitle } from "../../../../../main_tabs_v2/native/shared_components/guild_channels/ChannelSubtitle";
import { useStageParticipantsCount } from "../../../../../stage_channels/StageChannelParticipantStoreHooks";
import { StageChannelParticipantNamedIndex } from "../../../../../stage_channels/StageChannelParticipants";
import VoiceOrStageSummaryRow from "../../../../../main_tabs_v2/native/shared_components/guild_channels/VoiceOrStageSummaryRow";
import GuildChannelRow from "./GuildChannelRow";
import { VocalChannelJoinButton } from "../../../../../channel_list_v2/native/components/index";
let useStyles, GuildVoiceChannelExtras;
const GuildVoiceChannelSubtitle = function GuildVoiceChannelSubtitle(props) {
const { channel, voiceStates } = props;
const { id, guild_id } = channel;
const styles = useStyles();
const stateFromStores = useStateFromStores([StageInstanceStore], () => StageInstanceStore.getStageInstanceByChannel(channel.id)?.topic, [channel.id]);
return <View style={styles.subtitle}>
{useMemo(() => {
let subtitle = stateFromStores;
if (stateFromStores == null) {
const isLayoutCompact = _ChannelListLayout.isLayoutCompact(CHANNEL_LIST_SEARCH_LAYOUT);
let r22 = null;
if (!isLayoutCompact) {
const length = voiceStates.length;
r22 = null;
if (length !== 0) {
if (length === 1) {
const r109 = t["/GCyII"];
const r110 = voiceStates[0];
let r112 = r110 == null ? void 0 : r110.member?.nick;
if (r112 == null) {
r112 = UserUtils.getName(voiceStates[0]?.user);
}
r22 = intl.formatToPlainString(r109, {
a: r112
});
} else if (length === 2) {
const r70 = t["2efxiV"];
const r71 = voiceStates[0];
let r73 = r71 == null ? void 0 : r71.member?.nick;
if (r73 == null) {
r73 = UserUtils.getName(voiceStates[0]?.user);
}
const r85 = voiceStates[1];
let r87 = r85 == null ? void 0 : r85.member?.nick;
if (r87 == null) {
r87 = UserUtils.getName(voiceStates[1]?.user);
}
r22 = intl.formatToPlainString(r70, {
a: r73,
b: r87
});
} else {
const o2nmbk = t.o2nmbk;
const r36 = voiceStates[0];
let r13 = r36 == null ? void 0 : r36.member?.nick;
if (r13 == null) {
r13 = UserUtils.getName(voiceStates[0]?.user);
}
const r45 = voiceStates[1];
let r47 = r45 == null ? void 0 : r45.member?.nick;
if (r47 == null) {
r47 = UserUtils.getName(voiceStates[1]?.user);
}
r22 = intl.formatToPlainString(o2nmbk, {
a: r13,
b: r47,
n: voiceStates.length - 2
});
}
}
}
subtitle = r22;
}
return renderChannelSubtitle({
subtitle,
muted: false,
layout: CHANNEL_LIST_SEARCH_LAYOUT,
channelId: id,
guildId: guild_id
});
}, [stateFromStores, voiceStates, id, guild_id])}
</View>;
};
GuildVoiceChannelExtras = function GuildVoiceChannelExtras(props) {
const { channel: channel3, users } = props;
const styles = useStyles();
const stageParticipantsCount = useStageParticipantsCount(channel3.id, StageChannelParticipantNamedIndex.AUDIENCE);
return <View style={styles.subtitle}>
{users.length !== 0 && <View style={styles.users}>
<VoiceOrStageSummaryRow users={users} max={5} guildId={channel3.guild_id} layout={CHANNEL_LIST_SEARCH_LAYOUT} audienceCount={stageParticipantsCount} />
</View>}
</View>;
};
useStyles = createStyles({
users: {
marginTop: 4
},
subtitle: {
marginEnd: 16
},
trailing: {
paddingVertical: 4,
alignItems: "center",
alignSelf: "center"
}
});
const r38 = memo(function GuildVoiceChannelRow(props) {
const channel2 = props.channel;
let voiceStates2 = props.voiceStates;
const speakerVoiceStates = props.speakerVoiceStates;
let trailing = props.trailing;
const onPress = props.onPress;
const styles = useStyles();
if (channel2.isGuildStageVoice()) {
voiceStates2 = speakerVoiceStates;
}
const users = voiceStates2.map((item) => item.user);
const props2 = {
onPress: useCallback(() => {
onPress(channel2.id);
}, [channel2.id, onPress]),
voiceStates: voiceStates2,
channel: channel2,
subtitle: <GuildVoiceChannelSubtitle channel={channel2} voiceStates={voiceStates2} users={users} />,
trailing: null,
extras: null
};
if (trailing == null) {
trailing = <View style={styles.trailing}>
<VocalChannelJoinButton channel={channel2} voiceStates={voiceStates2} />
</View>;
}
props2.trailing = trailing;
props2.extras = <GuildVoiceChannelExtras channel={channel2} voiceStates={voiceStates2} users={users} />;
return <GuildChannelRow {...props2} />;
});
export default r38;
@@ -0,0 +1,409 @@
// Metro module 15512 (f15513).
import * as Module19 from "react";
import { useState, useCallback, useMemo } from "react";
import { View, useWindowDimensions } from "react-native";
import ChannelStore from "../../../../../../stores/ChannelStore";
import SearchMessageStore from "../../../../SearchMessageStore";
import { FILE_OR_LINK_IMAGE_BUFFER, SearchLinkTypes } from "../../../../SearchConstants";
import { jsx } from "react/jsx-runtime";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import { intl, t } from "../../../../../../intl/index.native";
import { renderMessageMarkupWithParser } from "../../../../../messages/renderMessageMarkup";
import { NativeSearchResultLinkPreviewParser } from "../../../SearchResultLinkPreviewMarkup";
import { Text } from "../../../../../../design/components/Text/native/Text";
import { ChatIcon } from "../../../../../../design/components/Icon/native/redesign/generated/ChatIcon";
import { getUrlIcon } from "../../../SearchPlatformUtils";
import { LinkIcon } from "../../../../../../design/components/Icon/native/redesign/generated/LinkIcon";
import { isLinkTrusted } from "../../../../../markup/MarkupReactLinkUtils";
import { SearchListCardContainer, SearchListCardThumbnail, SearchListCardContent, SearchListCardFooter } from "../SearchListCard";
import { PressableHighlight } from "../../../../../../design/void/Pressables/native/Pressables";
import { SearchEmbedMediaImage } from "../SearchMediaImage";
import Module38 from "../../../../../../_bundle/Module38";
import * as _MaskedLinkUtils from "../../../../../../utils/MaskedLinkUtils";
function $mk96737($env) {
return (a0) => {
let env28059;
L25: {
const r5 = $env;
const r8 = $env.$parent;
const r7 = r5[0];
const r6 = r5[1];
const r16 = env28059 = {
$parent: r8
};
env28059[0] = r7;
env28059[1] = r6;
if (Array.isArray(a0)) {
a0.forEach($mk96737(r16));
} else {
if (a0.type !== "link" && a0.type !== "channelMention") {
if (a0.content == null) {
break L25;
}
let env28060;
const content = a0.content;
const r22 = env28060 = {
$parent: r8
};
env28060[0] = r7;
env28060[1] = r6;
if (Array.isArray(content)) {
content.forEach($mk96737(r22));
break L25;
}
if (content.type !== "link" && content.type !== "channelMention") {
if (content.content == null) {
break L25;
}
(0, r8[14])(content.content, r7, r6);
break L25;
}
if (r7 === 0) {
r6(content);
break L25;
}
(0, r8[14])(content, r7 - 1, r6);
break L25;
}
if (r7 === 0) {
r6(a0);
} else {
let env28061;
const r40 = r7 - 1;
const r41 = env28061 = {
$parent: r8
};
env28061[0] = r40;
env28061[1] = r6;
if (Array.isArray(a0)) {
a0.forEach($mk96737(r41));
} else {
if (a0.type !== "link" && a0.type !== "channelMention") {
if (a0.content == null) {
break L25;
}
(0, r8[14])(a0.content, r40, r6);
break L25;
}
if (r40 === 0) {
r6(a0);
} else {
(0, r8[14])(a0, r40 - 1, r6);
}
}
}
}
}
return a0;
};
}
let LinkParsedGridItem, LinkEmbedGridItem, useStyles;
let env11043 = {};
const getLinkNodeAtIndex = function getLinkNodeAtIndex(a0, a1, a2) {
let env22102;
L9: {
const r4 = env22102 = {
$parent: env11043
};
env22102[0] = a1;
env22102[1] = a2;
if (Array.isArray(a0)) {
a0.forEach($mk96737(r4));
} else {
if (a0.type !== "link" && a0.type !== "channelMention") {
if (a0.content == null) {
break L9;
}
getLinkNodeAtIndex(a0.content, a1, a2);
break L9;
}
if (a1 === 0) {
a2(a0);
} else {
getLinkNodeAtIndex(a0, a1 - 1, a2);
}
}
}
return a0;
};
LinkParsedGridItem = function LinkParsedGridItem(props) {
let stateFromStores2, state, setState, callback;
const { author, linkIndex, channelId, messageId, onPressSearchLink, onPressGuildVoiceChannelMention, onPress, imageStyle: imageStyle2, containerStyle } = props;
stateFromStores2 = void 0;
state = void 0;
setState = void 0;
callback = void 0;
const styles = useStyles();
let c22103_7 = styles;
const stateFromStores = useStateFromStores([SearchMessageStore], () => SearchMessageStore.getMessage(messageId));
stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId));
[state, setState] = useState(null);
callback = useCallback((a0) => {
let env28062;
L25: {
const r8 = env11043;
const r16 = env28062 = {
$parent: r8
};
env28062[0] = linkIndex;
env28062[1] = setState;
if (Array.isArray(a0)) {
a0.forEach($mk96737(r16));
} else {
if (a0.type !== "link" && a0.type !== "channelMention") {
if (a0.content == null) {
break L25;
}
let env28063;
const content = a0.content;
const r22 = env28063 = {
$parent: r8
};
env28063[0] = linkIndex;
env28063[1] = setState;
if (Array.isArray(content)) {
content.forEach($mk96737(r22));
break L25;
}
if (content.type !== "link" && content.type !== "channelMention") {
if (content.content == null) {
break L25;
}
getLinkNodeAtIndex(content.content, linkIndex, setState);
break L25;
}
if (linkIndex === 0) {
setState(content);
break L25;
}
getLinkNodeAtIndex(content, linkIndex - 1, setState);
break L25;
}
if (linkIndex === 0) {
setState(a0);
} else {
let env28064;
const r40 = linkIndex - 1;
const r41 = env28064 = {
$parent: r8
};
env28064[0] = r40;
env28064[1] = setState;
if (Array.isArray(a0)) {
a0.forEach($mk96737(r41));
} else {
if (a0.type !== "link" && a0.type !== "channelMention") {
if (a0.content == null) {
break L25;
}
getLinkNodeAtIndex(a0.content, r40, setState);
break L25;
}
if (r40 === 0) {
setState(a0);
} else {
getLinkNodeAtIndex(a0, r40 - 1, setState);
}
}
}
}
}
return a0;
}, [linkIndex]);
const memo = useMemo(() => {
if (stateFromStores == null) {
return intl.string(t.mE3KJN);
}
return <View pointerEvents="none">
<Text variant="text-md/semibold" color="mobile-text-heading-primary" lineClamp={1}>{renderMessageMarkupWithParser(NativeSearchResultLinkPreviewParser, stateFromStores, {
postProcessor: callback
}).content}</Text>
</View>;
}, [stateFromStores, callback]);
const memo2 = useMemo(() => {
if (state != null && state.type === "link" && state.target != null && state.target !== "") {
return (0, jsx)(Text, {
variant: "text-xs/normal",
color: "text-link",
lineClamp: 1,
children: state.target
});
}
if (state != null && state?.type === "channelMention") {
return (0, jsx)(Text, {
variant: "text-xs/normal",
color: "text-link",
lineClamp: 1,
children: state.originalLink
});
}
return (0, jsx)(Text, {
variant: "text-xs/normal",
color: "interactive-text-default",
lineClamp: 1,
style: c22103_7.tapToSee,
children: intl.string(t.q2IIoP)
});
}, [state, styles.tapToSee]);
const r57 = [state?.target, ,];
const type = state?.type;
const r59 = () => {
const type = state?.type;
if (type === "channelMention") {
return (0, jsx)(ChatIcon, {
size: "lg"
});
}
if (type === "link") {
return (0, jsx)(getUrlIcon(state.target), {
size: "lg"
});
}
return (0, jsx)(LinkIcon, {
size: "lg"
});
};
r57[1] = type;
const memo3 = useMemo(r59, r57);
const callback2 = useCallback(() => {
if (state == null) {
onPress({
channelId,
messageId
});
} else if (state.type === "link") {
onPressSearchLink({
url: state.target,
trusted: isLinkTrusted(state),
messageId,
channelId
});
} else if (state.type === "channelMention") {
const channelId3 = state.channelId;
const channel = ChannelStore.getChannel(channelId3);
if (channel == null ? void 0 : channel.isGuildVocal()) {
onPressGuildVoiceChannelMention({
channelId,
messageId,
mentionedChannelId: channelId3
});
} else {
onPressSearchLink({
url: state.originalLink,
trusted: true,
messageId,
channelId
});
}
}
}, [channelId, messageId, state, onPress, onPressGuildVoiceChannelMention, onPressSearchLink]);
const memo4 = useMemo(() => author.getAvatarSource(stateFromStores2?.guild_id), [author, stateFromStores2?.guild_id]);
return <SearchListCardContainer containerStyle={containerStyle} onPress={callback2}>
<SearchListCardThumbnail thumbnail={<View style={[styles.iconContainer, imageStyle2]}>{memo3}</View>} />
<SearchListCardContent label={memo} subLabel={memo2} />
<PressableHighlight onPress={useCallback(() => {
onPress({
channelId,
messageId
});
}, [channelId, messageId, onPress])}>
<SearchListCardFooter author={author} avatarSource={memo4} channel={stateFromStores2} />
</PressableHighlight>
</SearchListCardContainer>;
};
LinkEmbedGridItem = function LinkEmbedGridItem(props) {
let stateFromStores3, scale, url, url2;
const { embed, sources, author: author2, channelId: channelId2, messageId: messageId2, onPressSearchLink: onPressSearchLink2, onPress: onPress2, imageStyle, containerStyle } = props;
stateFromStores3 = void 0;
scale = void 0;
url = void 0;
url2 = void 0;
const styles = useStyles();
let c22104_8 = styles;
const stateFromStores4 = useStateFromStores([SearchMessageStore], () => SearchMessageStore.getMessage(messageId2));
stateFromStores3 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId2));
scale = (0, useWindowDimensions)().scale;
let url3 = embed.url;
url = url3;
let rawTitle = embed.rawTitle;
if (rawTitle == null) {
rawTitle = embed.author?.name;
}
if (rawTitle == null) {
rawTitle = embed.url;
}
url2 = rawTitle;
const memo = useMemo(() => <SearchEmbedMediaImage messageId={messageId2} channelId={channelId2} authorId={author2.id} sources={sources} embed={embed} containerStyle={imageStyle} renderFallback={() => <View style={[c22104_8.iconContainer, imageStyle]}>
<LinkIcon size="md" />
</View>} scale={scale} containerHeight={imageStyle.height + FILE_OR_LINK_IMAGE_BUFFER} containerWidth={imageStyle.width + FILE_OR_LINK_IMAGE_BUFFER} />, [author2.id, channelId2, embed, imageStyle, messageId2, scale, sources, styles.iconContainer]);
const memo2 = useMemo(() => author2.getAvatarSource(stateFromStores3?.guild_id), [author2, stateFromStores3?.guild_id]);
const callback2 = useCallback(() => {
Module38(url != null, "[LinkGridItem] Embed url cannot be null");
onPressSearchLink2({
url,
trusted: _MaskedLinkUtils.isLinkTrusted(url, url2),
messageId: messageId2,
channelId: channelId2
});
}, [url, onPressSearchLink2, url2, channelId2, messageId2]);
const callback3 = useCallback(() => {
onPress2({
channelId: channelId2,
messageId: messageId2
});
}, [channelId2, messageId2, onPress2]);
const r72 = [<SearchListCardThumbnail thumbnail={memo} />, , ,];
if (stateFromStores4 == null) {
rawTitle = intl.string(t.mE3KJN);
}
if (url == null) {
url3 = intl.string(t.q2IIoP);
}
r72[1] = <SearchListCardContent label={rawTitle} subLabel={<Text variant="text-xs/normal" color="text-link" lineClamp={1}>{url3}</Text>} />;
r72[2] = <PressableHighlight onPress={callback3}>
<SearchListCardFooter author={author2} avatarSource={memo2} channel={stateFromStores3} />
</PressableHighlight>;
return <SearchListCardContainer containerStyle={containerStyle} onPress={callback2}>{r72}</SearchListCardContainer>;
};
useStyles = createStyles({
iconContainer: {
alignItems: "center",
justifyContent: "center"
},
tapToSee: {
fontStyle: "italic"
}
});
const r45 = Module19.memo(function LinkGridItem({ data, onPressSearchLink: onPressSearchLink3, onPressGuildVoiceChannelMention: onPressGuildVoiceChannelMention2, onPress: onPress3, imageStyle: imageStyle2, containerStyle }) {
const type = data.type;
if (SearchLinkTypes.EMBED === type) {
return (0, jsx)(LinkEmbedGridItem, {
embed: data.embed,
sources: data.sources,
messageId: data.messageId,
channelId: data.channelId,
author: data.author,
linkIndex: data.linkIndex,
onPressSearchLink: onPressSearchLink3,
onPress: onPress3,
imageStyle: imageStyle2,
containerStyle
});
}
if (SearchLinkTypes.TEXT === type) {
return (0, jsx)(LinkParsedGridItem, {
messageId: data.messageId,
channelId: data.channelId,
author: data.author,
linkIndex: data.linkIndex,
onPressSearchLink: onPressSearchLink3,
onPressGuildVoiceChannelMention: onPressGuildVoiceChannelMention2,
onPress: onPress3,
imageStyle: imageStyle2,
containerStyle
});
}
return null;
});
export default r45;
@@ -0,0 +1,26 @@
// Metro module 15506 (f15507).
import { useCallback } from "react";
import { View } from "react-native";
import { MEDIA_ITEM_GAP_WIDTH, MEDIA_NUM_COLUMNS, SEARCH_LIST_HORIZONTAL_PADDING } from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import MediaGridItem from "./MediaGridItem";
import { getMediaGridItemStyles } from "../../../SearchPlatformUtils";
import { FlashList } from "../../../../../../_bundle/noop_6676";
import { MediaVerticalSeparator } from "./Separators";
const useStyles = createStyles({
container: {
paddingLeft: SEARCH_LIST_HORIZONTAL_PADDING - 2,
paddingRight: SEARCH_LIST_HORIZONTAL_PADDING + 4
}
});
export default function MediaGrid(props) {
const { media, mediaSize, onPress, animate } = props;
return <View style={useStyles().container}>
<FlashList numColumns={MEDIA_NUM_COLUMNS} data={media} renderItem={useCallback((a0) => <MediaGridItem animate={animate} size={mediaSize} media={a0.item} onPress={onPress} containerStyle={getMediaGridItemStyles({
itemIndex: a0.index,
numItems: media.length,
numColumns: MEDIA_NUM_COLUMNS,
spacing: MEDIA_ITEM_GAP_WIDTH
})} />, [media.length, mediaSize, onPress, animate])} ItemSeparatorComponent={MediaVerticalSeparator} scrollEnabled={false} />
</View>;
};
@@ -0,0 +1,92 @@
// Metro module 15502 (f15503).
import * as Module19 from "react";
import { useRef, useMemo, useCallback, useEffect } from "react";
import { Pressable, View, useWindowDimensions } from "react-native";
import ChannelStore from "../../../../../../stores/ChannelStore";
import { SearchMediaTypes } from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle } from "../../../../../reanimated/ReanimatedRexport";
import * as _timing from "../../../../../../design/animation/reanimated/timing/timing";
import * as _timingPresets from "../../../../../../design/animation/reanimated/timing/timingPresets";
import { SearchEmbedMediaImage, SearchAttachmentMediaImage, SearchSoundMediaImage, SearchComponentMediaImage } from "../SearchMediaImage";
import { Card } from "../../../../../../design/components/Card/native/Card.native";
import { Avatar, AvatarSizes } from "../../../../../../design/void/native";
const useStyles = createStyles({
container: {
borderRadius: Module712.radii.xs,
overflow: "hidden",
backgroundColor: Module712.colors.BORDER_SUBTLE
},
avatar: {
position: "absolute",
top: 8,
right: 8
},
card: {
padding: 0
}
});
let c11034_12 = {
HIDDEN: 0,
0: "HIDDEN",
VISIBLE: 1,
1: "VISIBLE"
};
const __initData = {
code: "function MediaGridItemTsx1(){const{withTiming,opacity,timingStandard}=this.__closure;return{opacity:withTiming(opacity.get(),timingStandard)};}"
};
const r53 = Module19.memo(function MediaGridItem(props) {
let sharedValue;
const { media, size, containerStyle, onPress, animate } = props;
sharedValue = void 0;
const styles = useStyles();
const scale = useWindowDimensions().scale;
const ref = useRef(null);
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(media.channelId));
const r34 = [media.author, ,];
const guild_id = stateFromStores?.guild_id;
const r36 = () => media.author.getAvatarSource(stateFromStores?.guild_id);
r34[1] = guild_id;
const memo = useMemo(r36, r34);
const callback = useCallback(() => {
onPress({
media,
originView: ref.current
});
}, [media, onPress]);
sharedValue = useSharedValue(animate ? c11034_12.HIDDEN : c11034_12.VISIBLE);
const f = () => ({
opacity: _timing.withTiming(sharedValue.get(), _timingPresets.timingStandard)
});
f.__closure = {
withTiming: _timing.withTiming,
opacity: sharedValue,
timingStandard: _timingPresets.timingStandard
};
f.__workletHash = 9644750191833;
f.__initData = __initData;
const animatedStyle = useAnimatedStyle(f);
useEffect(() => {
sharedValue.set(c11034_12.VISIBLE);
}, [sharedValue]);
const memo2 = useMemo(() => ({
width: size,
height: size
}), [size]);
return <ReanimatedRexport.View style={[styles.container, containerStyle, memo2, animatedStyle]}>
<Pressable ref={ref} style={memo2} accessibilityRole="button" onPress={callback}>
{media.type === SearchMediaTypes.EMBED && <SearchEmbedMediaImage sources={media.sources} embed={media.embed} messageId={media.messageId} channelId={media.channelId} authorId={media.author.id} scale={scale} containerHeight={size} containerWidth={size} />}
{media.type === SearchMediaTypes.ATTACHMENT && <SearchAttachmentMediaImage attachment={media.attachment} channelId={media.channelId} authorId={media.author.id} scale={scale} containerHeight={size} containerWidth={size} />}
{media.type === SearchMediaTypes.AUDIO && <SearchSoundMediaImage height={size} width={size} />}
{media.type === SearchMediaTypes.COMPONENT && <SearchComponentMediaImage unfurledMediaItem={media.unfurledMediaItem} sources={media.sources} channelId={media.channelId} authorId={media.author.id} isBot={media.author.bot} scale={scale} containerHeight={size} containerWidth={size} />}
{memo != null && <View style={styles.avatar}>
<Card shadow="low" style={styles.card}>
<Avatar source={memo} size={AvatarSizes.XSMALL} avatarDecoration={media.author.avatarDecoration} />
</Card>
</View>}
</Pressable>
</ReanimatedRexport.View>;
});
export default r53;
@@ -0,0 +1,173 @@
// Metro module 15507 (f15508).
import * as Module19 from "react";
import { useMemo, useEffect, useCallback } from "react";
import { View, Platform } from "react-native";
import AccessibilityStore from "../../../../../a11y/AccessibilityStore";
import FavoriteStore from "../../../../../favorites/FavoriteStore";
import ChannelStore from "../../../../../../stores/ChannelStore";
import GuildStore from "../../../../../../stores/GuildStore";
import UserGuildSettingsStore from "../../../../../../stores/UserGuildSettingsStore";
import { MessageFlags } from "../../../../../../Constants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import { getChannelIcon } from "../../../../../../utils/native/ChannelUtils";
import useChannelName from "../../../../../channel/useChannelName";
import { Icon, Avatar, AvatarSizes, RoleDot } from "../../../../../../design/void/native";
import { Text } from "../../../../../../design/components/Text/native/Text";
import Module10308 from "../../../../../../_bundle/Module10308";
import Module9624 from "../../../../../../_bundle/Module9624";
import BotTag from "../../../../../applications/native/BotTag";
import UserUtils from "../../../../../../utils/UserUtils";
import { getUser } from "../../../../../../actions/UserActionCreators";
import { useSearchMessageTimestamp } from "../../../hooks/useSearchMessageTimestamp";
import { BellZIcon } from "../../../../../../design/components/Icon/native/redesign/generated/BellZIcon";
import PollBadge from "../../../../../polls/native/PollBadge";
import useMessageAuthor from "../../../../../messages/useMessageAuthor";
import { useProcessColorStringsArray, useIsRoleStyleAndRoleColorsEligibleForERC } from "../../../../../premium/enhanced_role_colors/native/EnhancedRoleColorUtils";
import { useIsChannelSpoilerGated } from "../../../../../spoiler_channels/SpoilerChannelUtils";
import { SearchListRow } from "../SearchListRow";
import { intl, t } from "../../../../../../intl/index.native";
import { NativeMessageChannelRowPreview } from "../../../../../main_tabs_v2/native/shared_components/ChannelRowPreview";
import { ChannelListLayoutTypes } from "../../../../../main_tabs_v2/ChannelListLayoutTypes";
let useStyles, MessageRowIcon, PrivateChannelMessageRowLabel, GuildChannelMessageRowLabel;
const GuildChannelMessageRowHeader = function GuildChannelMessageRowHeader(props) {
const channel = props.channel;
let muted = props.muted;
let isFavorite = props.isFavorite;
const styles = useStyles();
const r45 = [<Icon source={getChannelIcon(channel, {
isRulesChannel: useStateFromStores([GuildStore], () => GuildStore.getGuild(channel.guild_id)?.rulesChannelId) === channel.id
})} size={Icon.Sizes.REFRESH_SMALL_16} style={styles.channelIcon} />, <Text lineClamp={1} variant="text-sm/semibold" color="interactive-text-default">
{useChannelName(channel)}
</Text>, , , ,];
if (muted) {
muted = <Icon source={Module10308} size={Icon.Sizes.EXTRA_SMALL} style={styles.channelStatus} />;
}
r45[2] = muted;
if (isFavorite) {
isFavorite = <Icon source={Module9624} size={Icon.Sizes.EXTRA_SMALL} style={styles.channelStatus} />;
}
r45[3] = isFavorite;
r45[4] = channel.isSystemDM() && <BotTag type={BotTag.Types.SYSTEM_DM} verified />;
return <View style={styles.header}>{r45}</View>;
};
MessageRowIcon = function MessageRowIcon(props) {
const message3 = props.message;
return <Avatar user={message3.author} guildId={props.channel.guild_id} size={AvatarSizes.LARGE_48} avatarDecoration={message3.author.avatarDecoration} />;
};
PrivateChannelMessageRowLabel = function PrivateChannelMessageRowLabel(props) {
const { message, channel: channel2 } = props;
let muted = props.muted;
const styles = useStyles();
const memo = useMemo(() => UserUtils.getName(message.author), [message.author]);
useEffect(() => {
if (channel2.isDM() || channel2.isGroupDM()) {
channel2.recipients.forEach((recipient) => getUser(recipient));
}
}, [channel2]);
const searchMessageTimestamp = useSearchMessageTimestamp(message, channel2);
const { timestamp, timestampAccessibilityLabel } = searchMessageTimestamp;
const r41 = [<Text lineClamp={1} variant="text-md/semibold" color="interactive-text-active">{memo}</Text>, , ,];
if (muted) {
muted = <Icon source={Module10308} size={Icon.Sizes.EXTRA_SMALL} style={styles.channelStatus} />;
}
r41[1] = muted;
r41[2] = channel2.isSystemDM() && <BotTag type={BotTag.Types.SYSTEM_DM} verified />;
return <View style={styles.labelContainer}>
<View style={styles.authorRow}>{r41}</View>
<Text variant="text-xs/medium" color="interactive-text-active" lineClamp={1} style={styles.timestamp} accessibilityLabel={timestampAccessibilityLabel}>{timestamp}</Text>
{message.hasFlag(MessageFlags.SUPPRESS_NOTIFICATIONS) ? <BellZIcon size="xs" style={styles.suppressNotificationsIcon} /> : null}
{message.isPoll() ? <PollBadge style={styles.pollBadge} /> : null}
</View>;
};
GuildChannelMessageRowLabel = function GuildChannelMessageRowLabel(props) {
const { message: message3, channel: channel3 } = props;
const styles = useStyles();
const stateFromStores4 = useStateFromStores([AccessibilityStore], () => AccessibilityStore.roleStyle);
const messageAuthor = useMessageAuthor(message3);
const { nick, colorString, colorStrings } = messageAuthor;
const style = stateFromStores4 === "username" && colorString != null ? {
color: colorString
} : {};
const processColorStringsArray = useProcessColorStringsArray(colorStrings);
const isRoleStyleAndRoleColorsEligibleForERC = useIsRoleStyleAndRoleColorsEligibleForERC(channel3.guild_id, message3.author.id, stateFromStores4, processColorStringsArray);
const searchMessageTimestamp = useSearchMessageTimestamp(message3, channel3);
return <View style={styles.labelContainer}>
<View style={styles.authorRow}>
{stateFromStores4 === "dot" && colorString != null && <RoleDot size="small" color={colorString} colors={colorStrings} />}
<Text variant="text-sm/semibold" color="interactive-text-active" lineClamp={1} style={style} gradientColors={isRoleStyleAndRoleColorsEligibleForERC ? processColorStringsArray : void 0}>{nick}</Text>
</View>
<Text variant="text-xs/medium" color="text-default" lineClamp={1} style={styles.timestamp} accessibilityLabel={searchMessageTimestamp.timestampAccessibilityLabel}>{searchMessageTimestamp.timestamp}</Text>
{message3.hasFlag(MessageFlags.SUPPRESS_NOTIFICATIONS) ? <BellZIcon size="xs" style={styles.suppressNotificationsIcon} /> : null}
{message3.isPoll() ? <PollBadge style={styles.pollBadge} /> : null}
</View>;
};
Platform;
useStyles = createStyles({
channelIcon: {
marginRight: 5,
alignSelf: "center"
},
channelStatus: {
marginLeft: 5,
alignSelf: "center",
tintColor: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
labelContainer: {
flexDirection: "row",
width: "100%",
marginBottom: 2,
alignItems: "center"
},
authorRow: {
flexShrink: 1,
minWidth: 0,
flexDirection: "row"
},
timestamp: {
marginLeft: 8
},
header: {
flexDirection: "row",
marginRight: 16,
marginBottom: 12
},
body: {
alignItems: "flex-start"
},
pollBadge: {
marginLeft: 8
},
suppressNotificationsIcon: {
marginLeft: 4
},
spoilerText: {
fontStyle: "italic"
}
});
const r61 = Module19.memo(function MessageRow(props) {
let guild_id, stateFromStores2, stateFromStores3;
const { message: message2, onPress, lineClamp, messageSizeCacheRef } = props;
guild_id = void 0;
stateFromStores2 = void 0;
stateFromStores3 = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(message2.channel_id));
guild_id = stateFromStores?.guild_id;
stateFromStores2 = useStateFromStores([FavoriteStore], () => guild_id != null && FavoriteStore.isFavorite(message2.channel_id));
stateFromStores3 = useStateFromStores([UserGuildSettingsStore], () => UserGuildSettingsStore.isChannelMuted(guild_id, message2.channel_id));
const isChannelSpoilerGated = useIsChannelSpoilerGated(stateFromStores);
const callback = useCallback(() => {
onPress({
channelId: message2.channel_id,
messageId: message2.id
});
}, [message2.channel_id, message2.id, onPress]);
const Memo = useMemo(() => stateFromStores?.guild_id == null ? PrivateChannelMessageRowLabel : GuildChannelMessageRowLabel, [stateFromStores?.guild_id]);
const memo2 = useMemo(() => stateFromStores?.guild_id != null ? <GuildChannelMessageRowHeader channel={stateFromStores} muted={stateFromStores3} isFavorite={stateFromStores2} /> : null, [stateFromStores, stateFromStores2, stateFromStores3]);
return stateFromStores == null ? null : <SearchListRow header={memo2} icon={<MessageRowIcon message={message2} channel={stateFromStores} />} label={<Memo message={message2} channel={stateFromStores} muted={stateFromStores3} />} subLabel={isChannelSpoilerGated ? <Text variant="text-sm/normal" color="text-muted" style={styles.spoilerText}>
{intl.string(t["5uaI/7"])}
</Text> : <NativeMessageChannelRowPreview message={message2} channel={stateFromStores} muted={false} layout={ChannelListLayoutTypes.COZY} color="interactive-text-default" lineClamp={lineClamp} messageSizeCacheRef={messageSizeCacheRef} />} onPress={callback} bodyStyle={styles.body} />;
});
export default r61;
@@ -0,0 +1,285 @@
// Metro module 15492 (f15493).
import * as Module19 from "react";
import { useCallback, useEffect, useMemo } from "react";
import { View } from "react-native";
import ChannelStore from "../../../../../../stores/ChannelStore";
import ReadStateStore from "../../../../../../stores/ReadStateStore";
import UserStore from "../../../../../../stores/UserStore";
import { SearchHistoryItemTypes } from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../_bundle/Module712";
import SearchPlatformActionCreators from "../../../SearchPlatformActionCreators";
import { PressableHighlight } from "../../../../../../design/void/Pressables/native/Pressables";
import { XSmallIcon } from "../../../../../../design/components/Icon/native/redesign/generated/XSmallIcon";
import { useOnPressSearchHistoryText, useOnPressGroupDMItem, useOnPressDMItem, useOnPressGuildVoiceChannel, useOnPressGuildTextChannel } from "../../../hooks/useOnPressSearchItem";
import Tracking from "../../../tracking/Tracking";
import { SearchListRow } from "../SearchListRow";
import { Text } from "../../../../../../design/components/Text/native/Text";
import { MagnifyingGlassIcon } from "../../../../../../design/components/Icon/native/redesign/generated/MagnifyingGlassIcon";
import { useStateFromStores } from "../../../../../../_bundle/defaultAreStatesEqual";
import GroupDMRow from "./GroupDMRow";
import { getUser } from "../../../../../../actions/UserActionCreators";
import ChannelActionCreators from "../../../../../../actions/ChannelActionCreators";
import DMRow from "./DMRow";
import GuildVoiceOrStageChannelRow from "./GuildVoiceOrStageChannelRow";
import GuildTextChannelRow from "./GuildTextChannelRow";
import { intl, t } from "../../../../../../intl/index.native";
function $mk96699($env) {
return (a0) => {
if (a0.nativeEvent.actionName === "remove") {
const r7 = $env;
const r8 = $env.$parent;
(0, r8[1])(r8[2][10]).removeSearchHistoryItem(r7[0], r7[1]);
}
};
}
let SearchHistoryTextRow, SearchHistoryGroupDMRow, SearchHistoryDMRow, SearchHistoryGuildVoiceChannelRow, SearchHistoryGuildTextChannelRow, useStyles, c11025_17;
let $mk96698 = function() {
return () => [{
name: "remove",
label: intl.string(t.Ov3VO7)
}];
};
let env11025 = {};
const SearchHistoryRemoveIcon = function SearchHistoryRemoveIcon(props) {
const { searchContext, searchHistoryItem } = props;
return <PressableHighlight onPress={useCallback(() => {
SearchPlatformActionCreators.removeSearchHistoryItem(searchContext, searchHistoryItem);
}, [searchContext, searchHistoryItem])} accessibilityRole="button" unstable_pressDelay={130} style={{
marginLeft: 16
}} hitSlop={{
bottom: 16,
left: 16,
right: 16,
top: 16
}}>
<XSmallIcon size="sm" color="interactive-text-default" />
</PressableHighlight>;
};
SearchHistoryTextRow = function SearchHistoryTextRow(props) {
const { searchContext: searchContext2, searchHistoryItem: searchHistoryItem2 } = props;
const styles = useStyles();
let c22072_2 = styles;
const onPressSearchHistoryText = useOnPressSearchHistoryText({
searchContext: searchContext2
});
const callback = useCallback(() => {
Tracking.trackSearchHistoryClicked({
searchContext: searchContext2,
searchHistoryItemType: searchHistoryItem2.type
});
onPressSearchHistoryText(searchHistoryItem2.text, searchHistoryItem2.tags);
}, [onPressSearchHistoryText, searchContext2, searchHistoryItem2.tags, searchHistoryItem2.text, searchHistoryItem2.type]);
const tags = searchHistoryItem2.tags;
return <SearchListRow label={<View style={styles.textContainer}>
{tags == null ? void 0 : tags.map((tag) => <View key={tag.text} accessibilityRole="button" style={c22072_2.tag}>
<Text lineClamp={1} variant="text-sm/semibold" color="mobile-text-heading-primary">{tag.text}</Text>
</View>)}
<Text lineClamp={1} variant="text-md/semibold" color="mobile-text-heading-primary" style={styles.text}>{searchHistoryItem2.text}</Text>
</View>} onPress={callback} trailing={<SearchHistoryRemoveIcon searchContext={searchContext2} searchHistoryItem={searchHistoryItem2} />} iconContainerStyle={styles.textIconContainer} icon={<View style={styles.iconContainer}>
<MagnifyingGlassIcon size="sm" color="interactive-text-default" />
</View>} />;
};
SearchHistoryGroupDMRow = function SearchHistoryGroupDMRow(props) {
let onPressGroupDMItem;
let env22074;
const { searchContext: searchContext3, searchHistoryItem: searchHistoryItem3 } = props;
onPressGroupDMItem = void 0;
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(searchHistoryItem3.channelId));
useEffect(() => {
if (stateFromStores == null) {
SearchPlatformActionCreators.removeSearchHistoryItem(searchContext3, searchHistoryItem3);
}
}, [stateFromStores, searchContext3, searchHistoryItem3]);
onPressGroupDMItem = useOnPressGroupDMItem({
searchContext: searchContext3
});
const callback = useCallback((a0) => {
Tracking.trackSearchHistoryClicked({
searchContext: searchContext3,
channelId: a0,
searchHistoryItemType: searchHistoryItem3.type
});
onPressGroupDMItem(a0);
}, [onPressGroupDMItem, searchContext3, searchHistoryItem3.type]);
const r31 = env22074 = {
$parent: env11025
};
env22074[0] = searchContext3;
env22074[1] = searchHistoryItem3;
const memo = useMemo($mk96698(), []);
const callback2 = useCallback($mk96699(r31), [searchContext3, searchHistoryItem3]);
const trailing = <SearchHistoryRemoveIcon searchContext={searchContext3} searchHistoryItem={searchHistoryItem3} />;
return stateFromStores != null ? <GroupDMRow channel={stateFromStores} onPress={callback} accessibilityActions={memo} onAccessibilityAction={callback2} trailing={trailing} /> : null;
};
SearchHistoryDMRow = function SearchHistoryDMRow(props) {
let c22076_0;
let env22077;
let env22075 = {
$parent: env11025
};
const searchContext6 = props.searchContext;
env22075[0] = searchContext6;
const searchHistoryItem6 = props.searchHistoryItem;
env22075[1] = searchHistoryItem6;
env22075[2] = void 0;
const stateFromStores4 = useStateFromStores([UserStore], () => UserStore.getUser(env22075[1].userId));
useEffect(() => {
getUser(env22075[1].userId);
}, [searchHistoryItem6.userId]);
const onPressDMItem = useOnPressDMItem({
searchContext: searchContext6
});
env22075[2] = onPressDMItem;
c22076_0 = void 0;
c22076_0 = async (c30885_0) => {
let c30885_2;
c30885_2 = void 0;
let c31765_0 = c30885_0;
const orEnsurePrivateChannel = await ChannelActionCreators.getOrEnsurePrivateChannel(c30885_0);
const r46 = c30885_2;
let c31765_1 = orEnsurePrivateChannel;
const r53 = r46.$parent;
Tracking.trackSearchHistoryClicked({
searchContext: r53[0],
channelId: c31765_1,
searchHistoryItemType: r53[1].type
});
(0, r53[2])(c31765_0, c31765_1);
};
const callback = useCallback(function() {
return c22076_0.apply(this, arguments);
}, [onPressDMItem, searchContext6, searchHistoryItem6.type]);
const r36 = env22077 = {
$parent: env11025
};
env22077[0] = searchContext6;
env22077[1] = searchHistoryItem6;
const memo = useMemo($mk96698(), []);
const callback2 = useCallback($mk96699(r36), [searchContext6, searchHistoryItem6]);
const trailing = <SearchHistoryRemoveIcon searchContext={searchContext6} searchHistoryItem={searchHistoryItem6} />;
return stateFromStores4 != null ? <DMRow user={stateFromStores4} onPress={callback} accessibilityActions={memo} onAccessibilityAction={callback2} trailing={trailing} /> : null;
};
SearchHistoryGuildVoiceChannelRow = function SearchHistoryGuildVoiceChannelRow(props) {
let onPressGuildVoiceChannel;
const { searchContext: searchContext4, searchHistoryItem: searchHistoryItem4 } = props;
onPressGuildVoiceChannel = void 0;
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(searchHistoryItem4.channelId));
useEffect(() => {
if (stateFromStores2 == null) {
SearchPlatformActionCreators.removeSearchHistoryItem(searchContext4, searchHistoryItem4);
}
}, [stateFromStores2, searchContext4, searchHistoryItem4]);
onPressGuildVoiceChannel = useOnPressGuildVoiceChannel({
searchContext: searchContext4
});
const callback = useCallback((a0) => {
Tracking.trackSearchHistoryClicked({
searchContext: searchContext4,
channelId: a0,
searchHistoryItemType: searchHistoryItem4.type
});
onPressGuildVoiceChannel(a0);
}, [onPressGuildVoiceChannel, searchContext4, searchHistoryItem4.type]);
let r31 = null;
if (stateFromStores2 != null) {
const voiceStates = c11025_17;
r31 = <GuildVoiceOrStageChannelRow channel={stateFromStores2} voiceStates={voiceStates} speakerVoiceStates={voiceStates} trailing={<SearchHistoryRemoveIcon searchContext={searchContext4} searchHistoryItem={searchHistoryItem4} />} onPress={callback} />;
}
return r31;
};
SearchHistoryGuildTextChannelRow = function SearchHistoryGuildTextChannelRow(props) {
let onPressGuildTextChannel;
let env22080;
const { searchContext: searchContext5, searchHistoryItem: searchHistoryItem5 } = props;
onPressGuildTextChannel = void 0;
const stateFromStores3 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(searchHistoryItem5.channelId));
useEffect(() => {
if (stateFromStores3 == null) {
SearchPlatformActionCreators.removeSearchHistoryItem(searchContext5, searchHistoryItem5);
}
}, [stateFromStores3, searchContext5, searchHistoryItem5]);
const stateFromStores4 = useStateFromStores([ReadStateStore], () => {
let r8 = ReadStateStore.lastMessageId(searchHistoryItem5.channelId);
if (r8 == null) {
r8 = stateFromStores3?.lastMessageId;
}
if (r8 == null) {
r8 = null;
}
return r8;
});
onPressGuildTextChannel = useOnPressGuildTextChannel({
searchContext: searchContext5
});
const callback = useCallback((a0) => {
Tracking.trackSearchHistoryClicked({
searchContext: searchContext5,
channelId: a0,
searchHistoryItemType: searchHistoryItem5.type
});
onPressGuildTextChannel(a0);
}, [onPressGuildTextChannel, searchContext5, searchHistoryItem5.type]);
const r38 = env22080 = {
$parent: env11025
};
env22080[0] = searchContext5;
env22080[1] = searchHistoryItem5;
const memo = useMemo($mk96698(), []);
const callback2 = useCallback($mk96699(r38), [searchContext5, searchHistoryItem5]);
const trailing = <SearchHistoryRemoveIcon searchContext={searchContext5} searchHistoryItem={searchHistoryItem5} />;
return stateFromStores3 != null ? <GuildTextChannelRow channel={stateFromStores3} lastMessageId={stateFromStores4} onPress={callback} accessibilityActions={memo} onAccessibilityAction={callback2} trailing={trailing} /> : null;
};
useStyles = createStyles({
iconContainer: {
height: 48,
width: 48,
borderRadius: Module712.radii.xl,
backgroundColor: Module712.colors.INPUT_BACKGROUND_DEFAULT,
alignItems: "center",
justifyContent: "center"
},
text: {
flexShrink: 1
},
textContainer: {
flexDirection: "row",
alignItems: "center",
flexWrap: "wrap",
gap: 2
},
textIconContainer: {
alignSelf: "flex-start"
},
tag: {
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: Module712.radii.lg,
overflow: "hidden",
margin: 2,
flexDirection: "row",
alignItems: "center",
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST
}
});
c11025_17 = [];
const r68 = Module19.memo(function({ searchHistoryItem: searchHistoryItem6, ...props }) {
const type = searchHistoryItem6.type;
if (SearchHistoryItemTypes.GROUP_DM === type) {
return <SearchHistoryGroupDMRow {...props} searchHistoryItem={searchHistoryItem6} />;
}
if (SearchHistoryItemTypes.DM === type) {
return <SearchHistoryDMRow {...props} searchHistoryItem={searchHistoryItem6} />;
}
if (SearchHistoryItemTypes.TEXT === type) {
return <SearchHistoryTextRow {...props} searchHistoryItem={searchHistoryItem6} />;
}
if (SearchHistoryItemTypes.GUILD_TEXT_CHANNEL === type) {
return <SearchHistoryGuildTextChannelRow {...props} searchHistoryItem={searchHistoryItem6} />;
}
if (SearchHistoryItemTypes.GUILD_VOICE_CHANNEL === type) {
return <SearchHistoryGuildVoiceChannelRow {...props} searchHistoryItem={searchHistoryItem6} />;
}
return null;
});
export default r68;
@@ -0,0 +1,25 @@
// Metro module 15487 (f15488).
import { View } from "react-native";
import * as _SearchConstants from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
const { MEDIA_ITEM_GAP_WIDTH, FILES_OR_LINKS_GAP_WIDTH } = _SearchConstants;
const useStyles = createStyles({
filesOrLinksSeparator: {
height: FILES_OR_LINKS_GAP_WIDTH
},
mediaSeparator: {
height: MEDIA_ITEM_GAP_WIDTH
},
messageSeparator: {
height: 4
}
});
export function MessageVerticalSeparator() {
return <View style={useStyles().messageSeparator} />;
}
export function MediaVerticalSeparator() {
return <View style={useStyles().mediaSeparator} />;
}
export function CardVerticalSeparator() {
return <View style={useStyles().filesOrLinksSeparator} />;
}
@@ -0,0 +1,66 @@
// Metro module 15691 (f15692).
import { memo, useEffect } from "react";
import { View } from "react-native";
import { SearchEntrypointAnalyticsLocations } from "../../tracking/TrackingConstants";
import { SearchNavigatorScreens } from "./SearchNavigatorConstants";
import { SearchTypes } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { createNativeStackNavigator } from "../../../../../_bundle/Module9109";
import { useAccessibilityNativeStackOptions } from "../../../../../design/components/Navigator/native/Navigator.native";
import Tracking from "../../tracking/Tracking";
import useSafeAreaInsets_native from "../../../../safe_area/useSafeAreaInsets.native";
import * as _SearchNavigatorScreen from "./SearchNavigatorScreen";
import { renderHeader, getRenderBackImage } from "../../../../main_tabs_v2/native/shared_components/HeaderShared";
import SearchNavigatorPreviewHeader from "./SearchNavigatorPreviewHeader";
import * as _SearchNavigatorPreviewScreen from "./SearchNavigatorPreviewScreen";
const useStyles = createStyles({
container: {
flex: 1,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST
}
});
const nativeStackNavigator = createNativeStackNavigator();
const r47 = memo(function(a0) {
const searchContext = a0.route.params.searchContext;
const accessibilityNativeStackOptions = useAccessibilityNativeStackOptions();
useEffect(() => {
Tracking.trackSearchOpened({
searchContext,
searchLocation: searchContext.type === SearchTypes.GUILD ? SearchEntrypointAnalyticsLocations.GUILD : SearchEntrypointAnalyticsLocations.DM_LIST
});
return () => {
Tracking.trackSearchClosed({
searchContext
});
};
}, [searchContext]);
const styles = useStyles();
const safeAreaInsets_native = useSafeAreaInsets_native();
return <View style={[styles.container, {
paddingLeft: safeAreaInsets_native.left,
paddingRight: safeAreaInsets_native.right
}]}>
<nativeStackNavigator.Navigator id="search-navigator" screenOptions={{
...accessibilityNativeStackOptions
}}>
<nativeStackNavigator.Screen initialParams={{
searchContext
}} name={SearchNavigatorScreens.SEARCH_TABS} options={{
headerShown: false,
fullScreenGestureEnabled: true
}} getComponent={() => _SearchNavigatorScreen.default} />
<nativeStackNavigator.Screen name={SearchNavigatorScreens.SEARCH_CHAT_PREVIEW} options={(a0) => {
const route = a0.route;
return {
headerShown: true,
header: renderHeader,
headerLeft: getRenderBackImage(a0.navigation),
headerTitle: () => <SearchNavigatorPreviewHeader channelId={route.params.channelId} />,
fullScreenGestureEnabled: true
};
}} getComponent={() => _SearchNavigatorPreviewScreen.default} />
</nativeStackNavigator.Navigator>
</View>;
});
export default r47;
@@ -0,0 +1,6 @@
// Metro module 15481 (f15482).
const r8 = {
SEARCH_TABS: "search_tabs",
SEARCH_CHAT_PREVIEW: "search_chat_preview"
};
export { r8 as SearchNavigatorScreens };
@@ -0,0 +1,19 @@
// Metro module 15687 (f15688).
import { memo } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import ChannelHeader from "../../../../main_tabs_v2/native/channel/header/ChannelHeader";
const useStyles = createStyles({
container: {
flexShrink: 1,
paddingRight: 12,
flexDirection: "row",
alignItems: "center"
}
});
const r29 = memo(function({ channelId }) {
return <View style={useStyles().container}>
<ChannelHeader channelId={channelId} screenIndex="none" pressable={false} isGuildMemberCountVisible={false} isNavigationScreen />
</View>;
});
export default r29;
@@ -0,0 +1,46 @@
// Metro module 15688 (f15689).
import { useCallback } from "react";
import { ScrollView } from "react-native";
import { SearchTypes } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import { useNavigation } from "../../../../../design/components/Navigator/native/useNavigation.native";
import { useRoute } from "../../../../../_bundle/Module1483";
import Tracking from "../../tracking/Tracking";
import MessagePreview from "../../../../../components_native/common/MessagePreview";
const useStyles = createStyles({
container: {
flex: 1
}
});
export default function SearchNavigatorPreviewScreen() {
const styles = useStyles();
const navigation = useNavigation();
const route = useRoute();
const channelId = route.params.channelId;
const searchContext = route.params.searchContext;
const onBeforeJumpToMessage = route.params.onBeforeJumpToMessage;
const callback = useCallback(() => {
Tracking.trackSearchJumpToMessage({
searchContext,
channelId
});
if (onBeforeJumpToMessage != null) {
onBeforeJumpToMessage();
}
const type = searchContext.type;
if (!(SearchTypes.DMS !== type && (SearchTypes.GUILD !== type && SearchTypes.CHANNEL !== type))) {
const parent = navigation.getParent();
if (parent == null) {
return void 0;
}
parent.goBack();
}
}, [searchContext, channelId, onBeforeJumpToMessage, navigation]);
const type = searchContext.type;
if (SearchTypes.CHANNEL !== type && SearchTypes.GUILD_CHANNEL !== type) {
return <MessagePreview channelId={channelId} onBeforeJumpToMessage={callback} />;
}
return <ScrollView horizontal scrollEnabled={false} bounces={false} contentContainerStyle={styles.container}>
<MessagePreview channelId={channelId} onBeforeJumpToMessage={callback} />
</ScrollView>;
};
@@ -0,0 +1,54 @@
// Metro module 15692 (f15693).
import { useMemo } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../_bundle/Module712";
import { useSearchSuggestionsGesture } from "../layout/autocomplete/useSearchSuggestionsGesture";
import useBaseAppContainerDimensions from "../../../../screen/native/useBaseAppContainerDimensions";
import useSearchLayoutInsetTop from "../../hooks/useSearchLayoutInsetTop";
import { PressableOpacity } from "../../../../../design/void/Pressables/native/Pressables";
import { intl, t } from "../../../../../intl/index.native";
import { ArrowLargeLeftIcon } from "../../../../../design/components/Icon/native/redesign/generated/ArrowLargeLeftIcon";
import ThemedGradient from "../../../../client_themes/native/ThemedGradient";
import { NonCollapsableGestureDetector } from "../../../../gesture_handlers/native/NonCollapsableGestureDetector";
import SearchScreenSearchBar from "../layout/SearchScreenSearchBar";
import SearchScreenLayout from "../layout/SearchScreenLayout";
const useStyles = createStyles({
wrapper: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
flex: 1
},
tabs: {
flex: 1,
marginTop: Module712.space.PX_16
},
back: {
marginLeft: Module712.space.PX_16,
marginRight: Module712.space.PX_12
}
});
export default function SearchNavigatorScreen(props) {
const navigation = props.navigation;
const searchContext = props.route.params.searchContext;
const styles = useStyles();
const searchSuggestionsGesture = useSearchSuggestionsGesture(searchContext);
const { gesture, dismissed, setDismissed, onLayoutMeasure } = searchSuggestionsGesture;
const width = useBaseAppContainerDimensions().width;
return <>
<ThemedGradient absolute wide tall />
<NonCollapsableGestureDetector gesture={gesture}>
<View style={[styles.wrapper, {
paddingTop: useSearchLayoutInsetTop()
}]}>
<SearchScreenSearchBar searchContext={searchContext} suggestionsDismissed={dismissed} setSuggestionsDismissed={setDismissed} onSuggestionsLayoutMesure={onLayoutMeasure} backButton={useMemo(() => <View>
<PressableOpacity style={styles.back} accessibilityLabel={intl.string(t["13/7kX"])} accessibilityRole="button" onPress={navigation.goBack}>
<ArrowLargeLeftIcon color={Module712.colors.INTERACTIVE_TEXT_DEFAULT} />
</PressableOpacity>
</View>, [navigation.goBack, styles.back])} />
<View style={styles.tabs}>
<SearchScreenLayout searchContext={searchContext} width={width} />
</View>
</View>
</NonCollapsableGestureDetector>
</>;
};
@@ -0,0 +1,11 @@
// Metro module 15554 (f15555).
import { useMemo } from "react";
import { useToken } from "../../../../../design/tokens/native/useToken";
import Module712 from "../../../../../_bundle/Module712";
import { hexWithOpacity } from "../../../../../utils/ColorUtils";
import TabsGradient_native from "../../../../../design/components/Tabs/native/TabsGradient.native";
export default function SearchTabsGradient(props) {
const state = props.state;
const token = useToken(Module712.colors.BACKGROUND_BASE_LOW);
return <TabsGradient_native state={state} colors={useMemo(() => [token, hexWithOpacity(token, 0)], [token])} />;
};
@@ -0,0 +1,240 @@
// Metro module 15475 (f15476).
import * as Module19 from "react";
import { useEffect, useMemo, useCallback, useRef, useContext } from "react";
import { View } from "react-native";
import SearchMessageStore from "../../../SearchMessageStore";
import SearchQueryStore from "../../stores/SearchQueryStore";
import SearchTabsLayoutStore from "../../stores/SearchTabsLayoutStore";
import { MESSAGE_SEARCH_RESULT_TABS_SET, SEARCH_MESSAGE_TAB_SENTINEL, SearchTabs } from "../../../SearchConstants";
import { ComponentActions } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import { debounce } from "../../../../../_bundle/Module12";
import Tracking from "../../tracking/Tracking";
import ErrorScreen from "./pages/ErrorScreen";
import { intl, t } from "../../../../../intl/index.native";
import { getTabTitle, getSearchTabFetchId, getSearchContextId } from "../../../SearchUtils";
import SearchTabsPage, { SearchTabsPageContext } from "./SearchTabsPage";
import SearchSessionAnalyticsManager from "../../../managers/native/SearchSessionAnalyticsManager";
import SearchPlatformUtils from "../../SearchPlatformUtils";
import { useSearchSegmentedControlState } from "./hooks/useSearchSegmentedControlState";
import { SwipeForMemberListContext } from "../../../../main_tabs_v2/native/channel/SwipeForMemberListWrapper";
import { Gesture } from "../../../../../_bundle/Module5273";
import { useSharedValue } from "../../../../reanimated/ReanimatedRexport";
import SearchPlatformActionCreators from "../../SearchPlatformActionCreators";
import SearchActionCreators from "../../../SearchActionCreators";
import SearchTabsFetchManager from "../../../managers/SearchTabsFetchManager";
import { ComponentDispatch } from "../../../../../utils/ComponentDispatchUtils";
import SearchTabsTransitionGroup from "./SearchTabsTransitionGroup";
import SearchTabsGradient from "./SearchTabsGradient";
import { SegmentedControlPages } from "../../../../../design/components/SegmentedControl/native/SegmentedControlPages.native";
import { useStateFromStoresObject } from "../../../../../_bundle/Module589";
import { useAutoSearchGuildChannelTab } from "../../hooks/useAutoSearchGuildChannelTab";
import { useAutoSearchMembersTab } from "../../hooks/useAutoSearchMembersTab";
import { useAutoSearchPeopleTab } from "../../hooks/useAutoSearchPeopleTab";
import { useAutoTrackSearchTabCountsViewedAnalytics } from "../../hooks/useAutoTrackSearchTabCountsViewedAnalytics";
let useStyles, c11009_16, __initData, __initData2, __initData3, Component;
const NoSearchResultsScreen = function NoSearchResultsScreen(props) {
const searchContext = props.searchContext;
useEffect(() => {
Tracking.trackSearchEmptyResult({
searchContext
});
}, [searchContext]);
return <ErrorScreen text={intl.string(t.V6nAfF)} />;
};
useStyles = createStyles({
controls: {
flex: 0,
minHeight: 32
},
pages: {
flex: 1
}
});
c11009_16 = debounce((a0) => Tracking.trackSearchTabSelected({
searchContext: a0
}), 500);
__initData = {
code: "function SearchTabsLayoutTsx1({contentOffset:contentOffset}){const{isDragging,disallowMemberListGesture}=this.__closure;var _disallowMemberListGe;isDragging.set(true);(_disallowMemberListGe=disallowMemberListGesture)===null||_disallowMemberListGe===void 0||_disallowMemberListGe.set(contentOffset.x>0);}"
};
__initData2 = {
code: "function SearchTabsLayoutTsx2(){const{isDragging,disallowMemberListGesture}=this.__closure;var _disallowMemberListGe;isDragging.set(false);(_disallowMemberListGe=disallowMemberListGesture)===null||_disallowMemberListGe===void 0||_disallowMemberListGe.set(false);}"
};
__initData3 = {
code: "function SearchTabsLayoutTsx3({contentOffset:contentOffset}){const{isDragging,disallowMemberListGesture}=this.__closure;if(isDragging.get()){var _disallowMemberListGe;(_disallowMemberListGe=disallowMemberListGesture)===null||_disallowMemberListGe===void 0||_disallowMemberListGe.set(contentOffset.x>0);}}"
};
Component = Module19.memo(function({ searchContext: searchContext2, visibleTabs, visibleTabCounts, width }) {
let selectedTab, setActiveIndex, callback, context, gesture, disallowGesture, channelId, screenIndex, sharedValue, callback2;
let visibleTabs2, setActiveIndex2, ref;
selectedTab = void 0;
setActiveIndex = void 0;
callback = void 0;
context = void 0;
gesture = void 0;
disallowGesture = void 0;
channelId = void 0;
screenIndex = void 0;
sharedValue = void 0;
callback2 = void 0;
const styles = useStyles();
const searchSegmentedControlState = useSearchSegmentedControlState({
items: useMemo(() => {
const r0 = [];
let c28035_0 = r0;
visibleTabs.forEach((visibleTab) => {
const r15 = {
label: getTabTitle(visibleTab),
id: visibleTab,
page: <SearchTabsPage tab={visibleTab} searchContext={searchContext2} width={width} />,
count: null
};
let count = visibleTabCounts == null ? void 0 : visibleTabCounts[visibleTab];
if (count == null) {
count = void 0;
}
r15.count = count;
c28035_0.push(r15);
});
return r0;
}, [visibleTabCounts, visibleTabs, searchContext2, width]),
visibleTabs,
onSelectedTabChange: useCallback((a0) => {
SearchSessionAnalyticsManager.setSelectedTab(searchContext2, a0);
c11009_16(searchContext2);
const searchTabFetchId = getSearchTabFetchId(searchContext2, SEARCH_MESSAGE_TAB_SENTINEL, SearchQueryStore.getQueryString(searchContext2));
const isFetching = SearchMessageStore.getIsFetching(searchTabFetchId);
const isInitialFetchComplete = SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId);
const r29 = MESSAGE_SEARCH_RESULT_TABS_SET.has(a0);
if (!((r29 ? isInitialFetchComplete : !r29) || isFetching)) {
SearchPlatformUtils.fetchInitialMessagesDebounced(searchContext2);
}
}, [searchContext2]),
width
});
const segmentedControlState = searchSegmentedControlState.segmentedControlState;
selectedTab = searchSegmentedControlState.selectedTab;
setActiveIndex = segmentedControlState.setActiveIndex;
visibleTabs2 = visibleTabs;
setActiveIndex2 = setActiveIndex;
ref = void 0;
ref = useRef(() => {
setActiveIndex2(visibleTabs2.findIndex((item) => item === SearchTabs.MEDIA));
});
useEffect(() => {
ref.current = () => {
setActiveIndex2(visibleTabs2.findIndex((item) => item === SearchTabs.MEDIA));
};
}, [visibleTabs, setActiveIndex]);
callback = useCallback(() => ref.current(), []);
const memo2 = useMemo(() => ({
selectedTab,
selectMediaTab: callback
}), [callback, selectedTab]);
context = useContext(SwipeForMemberListContext);
const r58 = context == null ? {} : context;
gesture = r58.gesture;
disallowGesture = r58.disallowGesture;
channelId = r58.channelId;
screenIndex = r58.screenIndex;
const memo = useMemo(() => {
if (gesture != null) {
return Gesture.Native().simultaneousWithExternalGesture(gesture);
}
}, [gesture]);
sharedValue = useSharedValue(false);
const D = function D({ contentOffset }) {
sharedValue.set(true);
if (disallowGesture != null) {
disallowGesture.set(contentOffset.x > 0);
}
};
D.__closure = {
isDragging: sharedValue,
disallowMemberListGesture: disallowGesture
};
D.__workletHash = 766628353255;
D.__initData = __initData;
const callback4 = useCallback(D, [disallowGesture, sharedValue]);
const G = function G() {
sharedValue.set(false);
if (disallowGesture != null) {
disallowGesture.set(false);
}
};
G.__closure = {
isDragging: sharedValue,
disallowMemberListGesture: disallowGesture
};
G.__workletHash = 5683301645106;
G.__initData = __initData2;
const callback3 = useCallback(G, [disallowGesture, sharedValue]);
const A = function A({ contentOffset }) {
if (sharedValue.get() && disallowGesture != null) {
disallowGesture.set(contentOffset.x > 0);
}
};
A.__closure = {
isDragging: sharedValue,
disallowMemberListGesture: disallowGesture
};
A.__workletHash = 229712012692;
A.__initData = __initData3;
const callback5 = useCallback(A, [disallowGesture, sharedValue]);
callback2 = useCallback(() => {
SearchPlatformActionCreators.deleteSearchQuery(searchContext2);
SearchActionCreators.clearAllSearchMesssages();
SearchActionCreators.clearSearchRecentMessages();
SearchTabsFetchManager.cleanUp(getSearchContextId(searchContext2));
}, [searchContext2]);
useEffect(() => {
if (context == null) {
return () => callback2();
}
}, [context, callback2]);
useEffect(() => {
const handleChannelDetailsHidden2 = function handleChannelDetailsHidden({ channelId: channelId2, screenIndex: screenIndex2 }) {
if (channelId2 === channelId && screenIndex2 === screenIndex) {
setActiveIndex(0, false, true);
callback2();
}
};
if (context != null) {
ComponentDispatch.subscribe(ComponentActions.CHANNEL_DETAILS_HIDDEN, handleChannelDetailsHidden2);
return () => {
ComponentDispatch.unsubscribe(ComponentActions.CHANNEL_DETAILS_HIDDEN, handleChannelDetailsHidden2);
};
}
}, [channelId, screenIndex, setActiveIndex, context, callback2]);
return segmentedControlState.items.length === 0 ? <NoSearchResultsScreen searchContext={searchContext2} /> : <>
{[<View style={styles.controls}>
<SearchTabsTransitionGroup state={segmentedControlState} />
<SearchTabsGradient state={segmentedControlState} />
</View>, <View style={styles.pages}>
<SearchTabsPageContext.Provider value={memo2}>
<SegmentedControlPages state={segmentedControlState} bounces={context == null} nativeGesture={memo} onBeginDragWorklet={context != null ? callback4 : void 0} onEndDragWorklet={context != null ? callback3 : void 0} onScrollWorklet={context != null ? callback5 : void 0} />
</SearchTabsPageContext.Provider>
</View>]}
</>;
});
export default function ConnectedSearchTabsLayout(props) {
let candidateTabs;
const { searchContext: searchContext3, width: width2 } = props;
candidateTabs = void 0;
const stateFromStoresObject = useStateFromStoresObject([SearchTabsLayoutStore], () => ({
visibleTabs: SearchTabsLayoutStore.getVisibleTabs(searchContext3),
visibleTabCounts: SearchTabsLayoutStore.getVisibleTabCounts(searchContext3),
candidateTabs: SearchTabsLayoutStore.getCandidateTabs(searchContext3)
}), [searchContext3]);
const { visibleTabs: visibleTabs3, visibleTabCounts: visibleTabCounts2 } = stateFromStoresObject;
candidateTabs = stateFromStoresObject.candidateTabs;
const memo = useMemo(() => new Set(candidateTabs), [candidateTabs]);
useAutoSearchGuildChannelTab(searchContext3, !memo.has(SearchTabs.GUILD_CHANNELS));
useAutoSearchMembersTab(searchContext3, !memo.has(SearchTabs.MEMBERS));
useAutoSearchPeopleTab(searchContext3, !memo.has(SearchTabs.PEOPLE));
useAutoTrackSearchTabCountsViewedAnalytics({
searchContext: searchContext3,
visibleTabCounts: visibleTabCounts2,
visibleTabs: visibleTabs3
});
return <Component searchContext={searchContext3} visibleTabs={visibleTabs3} visibleTabCounts={visibleTabCounts2} width={width2} />;
};
@@ -0,0 +1,99 @@
// Metro module 15477 (f15478).
import { useState, useEffect, createContext, useContext } from "react";
import { View } from "react-native";
import ChannelStore from "../../../../../stores/ChannelStore";
import { SearchTabs } from "../../../SearchConstants";
import { SearchTypes } from "../../../../../Constants";
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../../../_bundle/Module589";
import { useIsChannelSpoilerGated } from "../../../../spoiler_channels/SpoilerChannelUtils";
import { useIsChannelContentGated } from "../../../../age_gate/AgeGateUtils";
import GuildNSFW from "../../../../../components_native/warnings/GuildNSFW";
import ChannelSpoiler from "../../../../spoiler_channels/native/ChannelSpoiler";
import RecentScreen from "./pages/RecentScreen";
import PeopleScreen from "./pages/PeopleScreen";
import MembersScreen from "./pages/MembersScreen";
import ChannelsScreen from "./pages/ChannelsScreen";
import MediaScreen from "./pages/messages/MediaScreen";
import FilesScreen from "./pages/messages/FilesScreen";
import LinksScreen from "./pages/messages/LinksScreen";
import { SearchTabsThreadScreen } from "../../../../main_tabs_v2/native/sidebar/details/screens/ThreadsScreen";
import MessagesScreen from "./pages/messages/MessagesScreen";
import PinsScreen from "./pages/messages/PinsScreen";
import Module38 from "../../../../../_bundle/Module38";
import useStateFromSharedValue from "../../../../reanimated/native/useStateFromSharedValue";
let useStyles, context;
const SearchTabsPage = function SearchTabsPage(props) {
const { tab, searchContext, isFocused, selectMediaTab, width } = props;
const [state, setState] = useState(isFocused);
useEffect(() => {
setTimeout(() => {
setState(true);
}, 10);
}, []);
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(searchContext.type !== SearchTypes.GUILD_CHANNEL ? searchContext.type === SearchTypes.THREAD ? searchContext.channelId : void 0 : searchContext.channelId));
const isChannelSpoilerGated = useIsChannelSpoilerGated(stateFromStores);
const isChannelContentGated = useIsChannelContentGated(stateFromStores);
if (state) {
L7: {
if (tab !== SearchTabs.MEMBERS) {
if (searchContext.type !== SearchTypes.GUILD_CHANNEL && searchContext.type !== SearchTypes.THREAD) {
break L7;
}
if (isChannelContentGated) {
return <GuildNSFW guildId={searchContext.guildId} channelId={searchContext.channelId} />;
}
if (isChannelSpoilerGated) {
return <ChannelSpoiler guildId={searchContext.guildId} channelId={searchContext.channelId} />;
}
}
}
if (SearchTabs.RECENT === tab) {
return <RecentScreen onJumpToMedia={selectMediaTab} searchContext={searchContext} width={width} />;
}
if (SearchTabs.PEOPLE === tab) {
return <PeopleScreen searchContext={searchContext} />;
}
if (SearchTabs.MEMBERS === tab) {
return <MembersScreen searchContext={searchContext} />;
}
if (SearchTabs.GUILD_CHANNELS === tab) {
return <ChannelsScreen searchContext={searchContext} />;
}
if (SearchTabs.MEDIA === tab) {
return <MediaScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
}
if (SearchTabs.FILES === tab) {
return <FilesScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
}
if (SearchTabs.LINKS === tab) {
return <LinksScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
}
if (SearchTabs.THREADS === tab) {
return <SearchTabsThreadScreen searchContext={searchContext} />;
}
if (SearchTabs.MESSAGES === tab) {
return <MessagesScreen tab={tab} searchContext={searchContext} isFocused={isFocused} />;
}
if (SearchTabs.PINS === tab) {
return <PinsScreen tab={tab} searchContext={searchContext} isFocused={isFocused} />;
}
return null;
}
return null;
};
useStyles = createStyles({
container: {
flex: 1
}
});
context = createContext(void 0);
export default function ConnectedSearchTabsPage(props) {
const { tab, searchContext: searchContext2, width } = props;
const context2 = useContext(context);
Module38(context2 != null, "[SearchTabsPageContext] Context should not be null.");
return <View style={useStyles().container}>
<SearchTabsPage isFocused={useStateFromSharedValue(context2.selectedTab) === tab} selectMediaTab={context2.selectMediaTab} tab={tab} searchContext={searchContext2} width={width} />
</View>;
};
export { context as SearchTabsPageContext };
@@ -0,0 +1,115 @@
// Metro module 15553 (f15554).
import { useEffect, useCallback, useContext } from "react";
import { SearchResultExactCountEnabled } from "../../../../user_settings/UserSettings";
import { defaultCountFormatter } from "../../../../../design/components/Tabs/native/Tabs.native";
import * as _ReanimatedRexport from "../../../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedReaction } from "../../../../reanimated/ReanimatedRexport";
import * as _TransitionGroup from "../../../../../design/components/TransitionGroup/TransitionGroup";
import { TransitionGroup } from "../../../../../design/components/TransitionGroup/TransitionGroup";
import * as _spring from "../../../../../design/animation/reanimated/spring/spring";
import * as _springPresets from "../../../../../design/animation/reanimated/spring/springPresets";
import { SwipeForMemberListContext } from "../../../../main_tabs_v2/native/channel/SwipeForMemberListWrapper";
import { Tabs } from "../../../../../design/components/Tabs/native/Tabs.native";
let __initData, __initData2, __initData3, __initData4, __initData5, AnimatedTabs, renderItem;
const getItemKey = function getItemKey(a0) {
return a0.items.map((item) => item.id).join("-");
};
AnimatedTabs = function AnimatedTabs(props) {
let context;
const { state, transitionState, cleanUp } = props;
context = void 0;
const r0 = transitionState === _TransitionGroup.TransitionStates.MOUNTED ? 1 : 0;
let setting;
const sharedValue = useSharedValue(r0);
const f = () => {
const r7 = sharedValue.get();
const t = function t(a0) {
if (a0 ? transitionState === _TransitionGroup.TransitionStates.YEETED : a0) {
_ReanimatedRexport.runOnJS(cleanUp)();
}
};
t.__closure = {
transitionState,
TransitionStates: _TransitionGroup.TransitionStates,
runOnJS: _ReanimatedRexport.runOnJS,
cleanUp
};
t.__workletHash = 15209468679721;
t.__initData = __initData2;
return {
opacity: _spring.withSpring(r7, _springPresets.springStandard, "respect-motion-settings", t),
position: sharedValue.get() === 1 ? "relative" : "absolute"
};
};
f.__closure = {
withSpring: _spring.withSpring,
opacity: sharedValue,
springStandard: _springPresets.springStandard,
transitionState,
TransitionStates: _TransitionGroup.TransitionStates,
runOnJS: _ReanimatedRexport.runOnJS,
cleanUp
};
f.__workletHash = 10740262883803;
f.__initData = __initData;
const animatedStyle = useAnimatedStyle(f);
useEffect(() => {
sharedValue.set(transitionState === _TransitionGroup.TransitionStates.YEETED ? 0 : 1);
}, [sharedValue, transitionState]);
setting = void 0;
setting = SearchResultExactCountEnabled.useSetting();
const callback = useCallback((a0) => !setting && a0 > 1000 ? `(${defaultCountFormatter(1000)}+)` : `(${defaultCountFormatter(a0)})`, [setting]);
context = useContext(SwipeForMemberListContext);
const h = function h() {
if (context != null) {
context.disallowGesture.set(false);
}
};
h.__closure = {
swipeForMemberListContext: context
};
h.__workletHash = 5080152010224;
h.__initData = __initData3;
const callback2 = useCallback(h, [context]);
const F = () => state.scrollOffset.get() > 0;
F.__closure = {
state
};
F.__workletHash = 7791091456487;
F.__initData = __initData4;
const w = function w(a0, a1) {
if (a0 !== a1 && context != null) {
context.disallowGesture.set(a0);
}
};
w.__closure = {
swipeForMemberListContext: context
};
w.__workletHash = 15386779064911;
w.__initData = __initData5;
useAnimatedReaction(F, w);
return <ReanimatedRexport.View style={animatedStyle}>
<Tabs state={state} grow={false} formatCount={callback} simultaneousHandlers={context?.gesture} onEndDrag={context != null ? callback2 : void 0} />
</ReanimatedRexport.View>;
};
renderItem = function renderItem(a0, a1, a2, a3) {
return <AnimatedTabs key={a0} state={a1} transitionState={a2} cleanUp={a3} />;
};
__initData = {
code: "function SearchTabsTransitionGroupTsx1(){const{withSpring,opacity,springStandard,transitionState,TransitionStates,runOnJS,cleanUp}=this.__closure;return{opacity:withSpring(opacity.get(),springStandard,'respect-motion-settings',function(finished){if(finished&&transitionState===TransitionStates.YEETED){runOnJS(cleanUp)();}}),position:opacity.get()===1?'relative':'absolute'};}"
};
__initData2 = {
code: "function SearchTabsTransitionGroupTsx2(finished){const{transitionState,TransitionStates,runOnJS,cleanUp}=this.__closure;if(finished&&transitionState===TransitionStates.YEETED){runOnJS(cleanUp)();}}"
};
__initData3 = {
code: "function SearchTabsTransitionGroupTsx3(){const{swipeForMemberListContext}=this.__closure;var _swipeForMemberListCo;(_swipeForMemberListCo=swipeForMemberListContext)===null||_swipeForMemberListCo===void 0||_swipeForMemberListCo.disallowGesture.set(false);}"
};
__initData4 = {
code: "function SearchTabsTransitionGroupTsx4(){const{state}=this.__closure;return state.scrollOffset.get()>0;}"
};
__initData5 = {
code: "function SearchTabsTransitionGroupTsx5(isOffsetFromStart,prevIsOffsetFromStart){const{swipeForMemberListContext}=this.__closure;if(isOffsetFromStart!==prevIsOffsetFromStart){var _swipeForMemberListCo;(_swipeForMemberListCo=swipeForMemberListContext)===null||_swipeForMemberListCo===void 0||_swipeForMemberListCo.disallowGesture.set(isOffsetFromStart);}}"
};
export default function SearchTabsTransitionGroup(props) {
return <TransitionGroup items={[props.state]} getItemKey={getItemKey} renderItem={renderItem} />;
};
@@ -0,0 +1,22 @@
// Metro module 15523 (f15524).
import * as _SearchConstants from "../../../../SearchConstants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
const { SEARCH_LIST_SECTION_TOP_PADDING, SEARCH_ROW_TAP_STATE_PADDING, SEARCH_LIST_HORIZONTAL_PADDING } = _SearchConstants;
const useStyles = createStyles({
filesOrLinksContentContainer: {
paddingTop: SEARCH_LIST_HORIZONTAL_PADDING,
paddingHorizontal: SEARCH_LIST_HORIZONTAL_PADDING
},
mediaContentContainer: {
paddingTop: SEARCH_LIST_SECTION_TOP_PADDING,
paddingHorizontal: SEARCH_LIST_HORIZONTAL_PADDING
},
messagesContentContainer: {
paddingTop: SEARCH_LIST_SECTION_TOP_PADDING - SEARCH_ROW_TAP_STATE_PADDING
},
membersContentContainer: {
paddingTop: SEARCH_LIST_SECTION_TOP_PADDING,
paddingHorizontal: SEARCH_LIST_HORIZONTAL_PADDING
}
});
export { useStyles as useContentContainerStyles };
@@ -0,0 +1,8 @@
// Metro module 15528 (f15529).
import SearchMessageStore from "../../../../SearchMessageStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import { getSearchTabFetchId } from "../../../../SearchUtils";
export function useSearchMessages(a0, a1) {
return useStateFromStores([SearchQueryStore, SearchMessageStore], () => SearchMessageStore.getMessages(getSearchTabFetchId(a0, a1, SearchQueryStore.getSearchResultsQuery(a0))), [a0, a1]);
}
@@ -0,0 +1,26 @@
// Metro module 15529 (f15530).
import SearchMessageStore from "../../../../SearchMessageStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { SEARCH_TABS_TO_SEARCH_QUERY_LIMITS } from "../../../../SearchConstants";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import { useStateFromStoresObject } from "../../../../../../_bundle/Module589";
import { getSearchTabFetchId } from "../../../../SearchUtils";
export function useSearchMessagesLoadingState({ searchContext, tab, placeholderHeight, numColumns }) {
const fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight,
numColumns
});
return useStateFromStoresObject([SearchQueryStore, SearchMessageStore], () => {
const searchTabFetchId = getSearchTabFetchId(searchContext, tab, SearchQueryStore.getSearchResultsQuery(searchContext));
const isInitialFetchComplete = SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId);
const isFetching = SearchMessageStore.getIsFetching(searchTabFetchId);
const isFirstPageLoading = !isInitialFetchComplete;
const isNextPageLoading = isInitialFetchComplete ? isFetching : !isFirstPageLoading;
const r27 = Math.max(fullscreenPlaceholderCount, SEARCH_TABS_TO_SEARCH_QUERY_LIMITS[tab]);
return {
isFirstPageLoading,
isNextPageLoading,
placeholderCount: isInitialFetchComplete ? isNextPageLoading ? r27 : 0 : r27
};
});
}
@@ -0,0 +1,98 @@
// Metro module 15552 (f15553).
import { useMemo } from "react";
import * as _ReanimatedRexport from "../../../../../reanimated/ReanimatedRexport";
import { useSharedValue, useDerivedValue, useAnimatedReaction } from "../../../../../reanimated/ReanimatedRexport";
import { useSegmentedControlState } from "../../../../../../design/components/SegmentedControl/native/SegmentedControlState.native";
const __initData = {
code: "function useSearchSegmentedControlStateTsx1(){const{visibleTabsStateful}=this.__closure;return visibleTabsStateful;}"
};
const __initData2 = {
code: "function useSearchSegmentedControlStateTsx2(){const{visibleTabs,activeIndex}=this.__closure;return visibleTabs.get()[activeIndex.get()];}"
};
const __initData3 = {
code: "function useSearchSegmentedControlStateTsx3(){const{visibleTabs}=this.__closure;return visibleTabs.get();}"
};
const __initData4 = {
code: "function useSearchSegmentedControlStateTsx4(visibleTabs){const{lastSelectedTab,runOnJS,setActiveIndex}=this.__closure;if(visibleTabs.length===0)return;const lastSelectedTabIndex=visibleTabs.indexOf(lastSelectedTab.get());const targetIndex=Math.max(0,lastSelectedTabIndex);const maxIndex=Math.max(0,visibleTabs.length-1);const nextActiveIndex=Math.min(targetIndex,maxIndex);runOnJS(setActiveIndex)(nextActiveIndex,false);}"
};
const __initData5 = {
code: "function useSearchSegmentedControlStateTsx5(){const{selectedTab}=this.__closure;return selectedTab.get();}"
};
const __initData6 = {
code: "function useSearchSegmentedControlStateTsx6(selectedTab){const{lastSelectedTab,runOnJS,onSelectedTabChange}=this.__closure;if(selectedTab==null)return;lastSelectedTab.set(selectedTab);runOnJS(onSelectedTabChange)(selectedTab);}"
};
export function useSearchSegmentedControlState({ items, visibleTabs, onSelectedTabChange, width }) {
let derivedValue, segmentedControlState, activeIndex, setActiveIndex, derivedValue2;
derivedValue = void 0;
segmentedControlState = void 0;
activeIndex = void 0;
setActiveIndex = void 0;
derivedValue2 = void 0;
const sharedValue = useSharedValue(visibleTabs[0]);
const T = () => visibleTabs;
T.__closure = {
visibleTabsStateful: visibleTabs
};
T.__workletHash = 17125959946782;
T.__initData = __initData;
derivedValue = useDerivedValue(T);
segmentedControlState = useSegmentedControlState({
items,
defaultIndex: 0,
pageWidth: width
});
activeIndex = segmentedControlState.activeIndex;
setActiveIndex = segmentedControlState.setActiveIndex;
const x = () => derivedValue.get()[activeIndex.get()];
x.__closure = {
visibleTabs: derivedValue,
activeIndex
};
x.__workletHash = 6189329624535;
x.__initData = __initData2;
derivedValue2 = useDerivedValue(x);
const f = () => derivedValue.get();
f.__closure = {
visibleTabs: derivedValue
};
f.__workletHash = 9222891018885;
f.__initData = __initData3;
const v = function v(a0) {
if (a0.length !== 0) {
const r23 = Math.min(Math.max(0, a0.indexOf(sharedValue.get())), Math.max(0, a0.length - 1));
_ReanimatedRexport.runOnJS(setActiveIndex)(r23, false);
}
};
v.__closure = {
lastSelectedTab: sharedValue,
runOnJS: _ReanimatedRexport.runOnJS,
setActiveIndex
};
v.__workletHash = 13456384876758;
v.__initData = __initData4;
useAnimatedReaction(f, v);
const C = () => derivedValue2.get();
C.__closure = {
selectedTab: derivedValue2
};
C.__workletHash = 2491149576387;
C.__initData = __initData5;
const I = function I(a0) {
if (a0 != null) {
sharedValue.set(a0);
_ReanimatedRexport.runOnJS(onSelectedTabChange)(a0);
}
};
I.__closure = {
lastSelectedTab: sharedValue,
runOnJS: _ReanimatedRexport.runOnJS,
onSelectedTabChange
};
I.__workletHash = 8452224388929;
I.__initData = __initData6;
useAnimatedReaction(C, I);
return useMemo(() => ({
segmentedControlState,
selectedTab: derivedValue2
}), [segmentedControlState, derivedValue2]);
}
@@ -0,0 +1,166 @@
// Metro module 15526 (f15527).
import * as Module19 from "react";
import { useEffect, useCallback, useMemo } from "react";
import SortedVoiceStateStore from "../../../../../../stores/views/SortedVoiceStateStore";
import SearchGuildChannelTabStore from "../../../stores/SearchGuildChannelTabStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { CHANNELS_ESTIMATED_ITEM_SIZE, EMPTY_VOICE_STATES, SearchListItemTypes } from "../../../../SearchConstants";
import { SearchResultContentEntityTypes } from "../../../tracking/TrackingConstants";
import { getSearchContextId } from "../../../../SearchUtils";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import useStageChannelSpeakerVoiceStates from "../../../../../stage_channels/useStageChannelSpeakerVoiceStates";
import { useOnPressGuildTextChannel, useOnPressGuildVoiceChannel } from "../../../hooks/useOnPressSearchItem";
import { intl, t } from "../../../../../../intl/index.native";
import { AccessibilityAnnouncer } from "../../../../../../_bundle/Module3902";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import Tracking from "../../../tracking/Tracking";
import { useMessageTabCountsErrorText } from "../../../hooks/useSearchScreenError";
import ErrorScreen from "./ErrorScreen";
import SearchList from "../../list/SearchList";
const r34 = Module19.memo(function ChannelsScreen(props) {
let stateFromStores2, stateFromStores3, c22116_5, onPressGuildTextChannel, onPressGuildVoiceChannel, stateFromStores4, stateFromStores5, fullscreenPlaceholderCount, callback, callback2;
const searchContext = props.searchContext;
stateFromStores2 = void 0;
stateFromStores3 = void 0;
c22116_5 = void 0;
onPressGuildTextChannel = void 0;
onPressGuildVoiceChannel = void 0;
stateFromStores4 = void 0;
stateFromStores5 = void 0;
fullscreenPlaceholderCount = void 0;
callback = void 0;
callback2 = void 0;
const searchContextId = getSearchContextId(searchContext);
const stateFromStores = useStateFromStores([SearchGuildChannelTabStore], () => SearchGuildChannelTabStore.getTextChannels(searchContextId));
stateFromStores2 = useStateFromStores([SearchGuildChannelTabStore], () => SearchGuildChannelTabStore.getVoiceChannels(searchContextId));
stateFromStores3 = useStateFromStores([SortedVoiceStateStore], () => SortedVoiceStateStore.getVoiceStates(searchContext.guildId), [searchContext.guildId]);
const stageChannelSpeakerVoiceStates = useStageChannelSpeakerVoiceStates(searchContext.guildId);
c22116_5 = stageChannelSpeakerVoiceStates;
onPressGuildTextChannel = useOnPressGuildTextChannel({
searchContext
});
onPressGuildVoiceChannel = useOnPressGuildVoiceChannel({
searchContext
});
stateFromStores4 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(searchContext));
stateFromStores5 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.getQueryString(searchContext), [searchContext]);
useEffect(() => {
if (stateFromStores5.trim() !== "") {
const count = stateFromStores.length + stateFromStores2.length;
AccessibilityAnnouncer.announce(count > 0 ? intl.formatToPlainString(t.ZGVL3g, {
count
}) : intl.string(t.f5cMAg));
}
}, [stateFromStores, stateFromStores2, stateFromStores5]);
fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: CHANNELS_ESTIMATED_ITEM_SIZE,
numColumns: 1
});
callback = useCallback((a0, a1) => {
onPressGuildTextChannel(a0);
Tracking.trackSearchResultClicked({
searchContext,
channelId: a0,
index: a1,
entityType: SearchResultContentEntityTypes.CHANNEL
});
}, [onPressGuildTextChannel, searchContext]);
callback2 = useCallback((a0, a1) => {
onPressGuildVoiceChannel(a0);
Tracking.trackSearchResultClicked({
searchContext,
channelId: a0,
index: a1,
entityType: SearchResultContentEntityTypes.CHANNEL
});
}, [onPressGuildVoiceChannel, searchContext]);
const memo = useMemo(() => {
const r4 = [];
let c28068_0 = r4;
let c28068_1 = 0;
if (stateFromStores.length > 0) {
r4.push({
type: SearchListItemTypes.SECTION,
props: {
title: intl.string(t.nIfr0Y)
}
});
stateFromStores.forEach((stateFromStore, index) => {
let c30889_0 = c28068_1 + index;
c28068_0.push({
type: SearchListItemTypes.GUILD_TEXT_CHANNEL,
props: {
channel: stateFromStore.channel,
lastMessageId: stateFromStore.lastMessageId,
onPress: (a0) => callback(a0, c30889_0)
}
});
});
c28068_1 = 0 + stateFromStores.length;
}
if (stateFromStores2.length > 0) {
r4.push({
type: SearchListItemTypes.SECTION,
props: {
title: intl.string(t.CYnO4s)
}
});
const stateFromStores6 = stateFromStores3;
let c28069_1 = c22116_5;
stateFromStores2.sort(function({ channel }, b) {
let r7 = stateFromStores6;
let r15 = (channel.isGuildStageVoice() ? c28069_1 : stateFromStores6)[channel.id];
if (r15 == null) {
r15 = EMPTY_VOICE_STATES;
}
const channel2 = b.channel;
if (channel2.isGuildStageVoice()) {
r7 = c28069_1;
}
let r20 = r7[channel2.id];
if (r20 == null) {
r20 = EMPTY_VOICE_STATES;
}
return r15.length < r20.length ? 1 : r15.length > r20.length ? -1 : 0;
}).forEach((item, index) => {
let c30890_0 = c28068_1 + index;
let voiceStates = stateFromStores3[item.channel.id];
if (voiceStates == null) {
voiceStates = EMPTY_VOICE_STATES;
}
let speakerVoiceStates = c22116_5[item.channel.id];
if (speakerVoiceStates == null) {
speakerVoiceStates = EMPTY_VOICE_STATES;
}
c28068_0.push({
type: SearchListItemTypes.GUILD_VOICE_CHANNEL,
props: {
channel: item.channel,
voiceStates,
speakerVoiceStates,
onPress: (a0) => callback2(a0, c30890_0)
}
});
});
}
if (!stateFromStores4 && r4.length === 0) {
const r69 = 0 < fullscreenPlaceholderCount;
let r73 = 0;
if (r69) {
do {
r4.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r73}`
});
r73 = r73 + 1;
} while (r73 < fullscreenPlaceholderCount);
}
}
return r4;
}, [fullscreenPlaceholderCount, callback, callback2, stateFromStores4, stageChannelSpeakerVoiceStates, stateFromStores, stateFromStores2, stateFromStores3]);
const messageTabCountsErrorText = useMessageTabCountsErrorText({
searchContext
});
return messageTabCountsErrorText != null ? <ErrorScreen text={messageTabCountsErrorText} /> : <SearchList data={memo} />;
});
export default r34;
@@ -0,0 +1,34 @@
// Metro module 15476 (f15477).
import { memo, useEffect } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import useSafeAreaInsetsKeyboardAware_native from "../../../../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import { AccessibilityAnnouncer } from "../../../../../../_bundle/Module3902";
import { Text } from "../../../../../../design/components/Text/native/Text";
const useStyles = createStyles({
container: {
justifyContent: "center",
alignItems: "center",
height: "100%",
display: "flex"
},
text: {
textAlign: "center",
width: "75%"
}
});
const r30 = memo(function({ text }) {
const styles = useStyles();
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
useEffect(() => {
AccessibilityAnnouncer.announce(text, "polite");
}, [text]);
return <View style={[styles.container, {
paddingBottom: insets.bottom
}]}>
<Text variant="text-sm/medium" color="text-muted" style={styles.text}>{text}</Text>
</View>;
});
export default r30;
@@ -0,0 +1,226 @@
// Metro module 15522 (f15523).
import * as Module19 from "react";
import { useCallback, useEffect, useMemo } from "react";
import { View } from "react-native";
import { EVERYONE_CHANNEL_ID } from "../../../../../../stores/ChannelMemberStore";
import ChannelStore from "../../../../../../stores/ChannelStore";
import GuildMemberStore from "../../../../../../stores/GuildMemberStore";
import GuildStore from "../../../../../../stores/GuildStore";
import SelectedChannelStore from "../../../../../../stores/SelectedChannelStore";
import SearchMemberTabStore from "../../../stores/SearchMemberTabStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { MESSAGE_PLACEHOLDER_ITEM_SIZE, SearchListItemTypes } from "../../../../SearchConstants";
import { SearchResultContentEntityTypes } from "../../../tracking/TrackingConstants";
import { RelationshipTypes, SearchTypes } from "../../../../../../Constants";
import { createStyles } from "../../../../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../../../../_bundle/defaultAreStatesEqual";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../../../app_analytics/useAnalyticsLocations";
import { getSearchContextId } from "../../../../SearchUtils";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import { getGuildVisualOwnerId } from "../../../../../../utils/PermissionUtils";
import { dismissGlobalKeyboard } from "../../../../../../utils/native/KeyboardManagerUtils";
import Tracking from "../../../tracking/Tracking";
import showUserProfileActionSheet from "../../../../../user_profile/native/showUserProfileActionSheet";
import { intl, t } from "../../../../../../intl/index.native";
import { AccessibilityAnnouncer } from "../../../../../../_bundle/Module3902";
import { useContentContainerStyles } from "../hooks/useContentContainerStyles";
import { useMessageTabCountsErrorText } from "../../../hooks/useSearchScreenError";
import ErrorScreen from "./ErrorScreen";
import GuildChannelUserList from "../../../../../main_tabs_v2/native/shared_components/user_list/GuildChannelUserList";
import SearchList from "../../list/SearchList";
import ThreadChannelUserList from "../../../../../main_tabs_v2/native/shared_components/user_list/ThreadChannelUserList";
import AnalyticsLocation from "../../../../../app_analytics/AnalyticsLocation";
import PrivateChannelUserList from "../../../../../main_tabs_v2/native/shared_components/user_list/PrivateChannelUserList";
let useStyles, ThreadMembersScreen;
const SearchableMembersScreen = function SearchableMembersScreen(props) {
let r120;
let EVERYONE_CHANNEL_ID2, stateFromStores2, fullscreenPlaceholderCount, stateFromStores3, callback, stateFromStores4, stateFromStores5;
let searchContext2;
const { searchContext, guildId } = props;
EVERYONE_CHANNEL_ID2 = void 0;
stateFromStores2 = void 0;
fullscreenPlaceholderCount = void 0;
stateFromStores3 = void 0;
callback = void 0;
stateFromStores4 = void 0;
stateFromStores5 = void 0;
const styles = useStyles();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const searchContextId = getSearchContextId(searchContext);
const stateFromStores = useStateFromStores([SearchMemberTabStore], () => SearchMemberTabStore.getResults(searchContextId));
searchContext2 = searchContext;
const stateFromStores6 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.getChannelIds(searchContext2), [searchContext]);
const r21 = stateFromStores6.size === 0 ? EVERYONE_CHANNEL_ID : stateFromStores6.size === 1 ? Array.from(stateFromStores6)[0] : null;
L12: {
EVERYONE_CHANNEL_ID2 = r21;
stateFromStores2 = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: MESSAGE_PLACEHOLDER_ITEM_SIZE,
numColumns: 1
});
stateFromStores3 = useStateFromStores([GuildStore], () => {
const guild = GuildStore.getGuild(guildId);
return guild != null ? getGuildVisualOwnerId(guild) : void 0;
});
const stateFromStores7 = useStateFromStores([ChannelStore], () => {
if (EVERYONE_CHANNEL_ID2 === EVERYONE_CHANNEL_ID) {
return EVERYONE_CHANNEL_ID2;
}
const channel = ChannelStore.getChannel(EVERYONE_CHANNEL_ID2);
return channel != null ? channel.isAnnouncementThread() ? channel.parent_id != null ? channel.parent_id : EVERYONE_CHANNEL_ID2 : EVERYONE_CHANNEL_ID2 : EVERYONE_CHANNEL_ID2;
});
callback = useCallback((a0, a1) => {
dismissGlobalKeyboard();
Tracking.trackSearchResultClicked({
searchContext,
userId: a0.id,
index: a1,
entityType: SearchResultContentEntityTypes.USER
});
let channelId2 = EVERYONE_CHANNEL_ID2;
if (EVERYONE_CHANNEL_ID2 === EVERYONE_CHANNEL_ID) {
channelId2 = stateFromStores2;
}
showUserProfileActionSheet({
userId: a0.id,
channelId: channelId2,
sourceAnalyticsLocations: analyticsLocations
});
}, [searchContext, EVERYONE_CHANNEL_ID2, stateFromStores2, analyticsLocations]);
const callback2 = useCallback((a0) => {
Tracking.trackSearchResultClicked({
searchContext,
userId: a0.user.id,
index: a0.index,
entityType: SearchResultContentEntityTypes.USER
});
dismissGlobalKeyboard();
}, [searchContext]);
const callback3 = useCallback((a0) => {
callback(a0.user, a0.index);
}, [callback]);
stateFromStores4 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(searchContext), [searchContext]);
stateFromStores5 = useStateFromStores([SearchMemberTabStore], () => SearchMemberTabStore.getIsFetching(searchContextId));
useEffect(() => {
if (!stateFromStores4 && !stateFromStores5) {
const length = stateFromStores.length;
AccessibilityAnnouncer.announce(length > 0 ? intl.formatToPlainString(t.ZGVL3g, {
count: length
}) : intl.string(t.tuL9TW));
}
}, [stateFromStores, stateFromStores4, stateFromStores5]);
const memo = useMemo(() => {
let r4;
let c28067_0;
L5: {
r4 = [];
c28067_0 = r4;
stateFromStores.forEach((stateFromStore, index) => {
const member = GuildMemberStore.getMember(guildId, stateFromStore.record.id);
const nick = member?.nick;
const colorString = member?.colorString;
const colorStrings = member?.colorStrings;
let premiumSince = member?.premiumSince;
if (premiumSince == null) {
premiumSince = void 0;
}
c28067_0.push({
type: SearchListItemTypes.GUILD_CHANNEL_MEMBER,
props: {
type: RelationshipTypes.NONE,
user: stateFromStore.record,
nickname: nick,
usernameColor: colorString,
roleColors: colorStrings,
isNameplatedRow: true,
premiumSince,
isOwner: stateFromStores3 === stateFromStore.record.id,
guildId,
onLongPress: (a0) => callback(a0, index),
onPress: (a0) => callback(a0, index),
start: index === 0,
end: index === stateFromStores.length - 1,
canShowDisplayNameStylesFont: true
}
});
});
if (!stateFromStores5) {
if (stateFromStores4) {
break L5;
}
if (r4.length !== 0) {
break L5;
}
}
let r0 = 0;
while (r0 < fullscreenPlaceholderCount) {
r4.push({
type: SearchListItemTypes.GUILD_CHANNEL_MEMBER_PLACEHOLDER,
key: `guild-channel-member-placeholder-${r0}`
});
r0 = r0 + 1;
}
}
return r4;
}, [stateFromStores, stateFromStores5, stateFromStores4, guildId, stateFromStores3, callback, fullscreenPlaceholderCount]);
const styles2 = useContentContainerStyles();
const messageTabCountsErrorText = useMessageTabCountsErrorText({
searchContext
});
if (messageTabCountsErrorText != null) {
r120 = <ErrorScreen text={messageTabCountsErrorText} />;
} else {
if (stateFromStores4 && stateFromStores7 != null) {
r120 = <GuildChannelUserList onUserPress={callback2} onUserLongPress={callback3} channelId={stateFromStores7} guildId={guildId} disableStickySections listStyleOverride={styles.userList} isNameplatedList canShowDisplayNameStylesFont />;
break L12;
}
r120 = <SearchList contentContainerStyle={styles2.membersContentContainer} data={memo} />;
}
}
return r120;
};
ThreadMembersScreen = function ThreadMembersScreen(props) {
const { searchContext: searchContext3, channelId, guildId: guildId2 } = props;
const stateFromStores6 = useStateFromStores([ChannelStore], () => {
const channel = ChannelStore.getChannel(channelId);
let r8 = channel == null ? void 0 : channel.isAnnouncementThread();
if (r8 == null) {
r8 = false;
}
return r8;
});
const stateFromStores7 = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(searchContext3) && !SearchQueryStore.isTagsEmpty(searchContext3), [searchContext3]);
return !stateFromStores6 && stateFromStores7 ? <ThreadChannelUserList channelId={channelId} guildId={guildId2} onUserPress={dismissGlobalKeyboard} disableStickySections /> : <SearchableMembersScreen searchContext={searchContext3} guildId={guildId2} />;
};
useStyles = createStyles({
container: {
flex: 1,
flexGrow: 1
},
userList: {
backgroundColor: "transparent"
}
});
const r58 = Module19.memo(function MembersScreen(props) {
const searchContext4 = props.searchContext;
const styles = useStyles();
const analyticsLocations2 = useAnalyticsLocations(AnalyticsLocation.SEARCH_MEMBERS).analyticsLocations;
const type = searchContext4.type;
if (SearchTypes.CHANNEL === type) {
return <AnalyticsLocationProvider value={analyticsLocations2}>
<View style={styles.container}>
<PrivateChannelUserList channelId={searchContext4.channelId} disableStickySections listStyleOverride={styles.userList} onUserPress={dismissGlobalKeyboard} />
</View>
</AnalyticsLocationProvider>;
}
if (SearchTypes.THREAD === type) {
return <ThreadMembersScreen searchContext={searchContext4} channelId={searchContext4.channelId} guildId={searchContext4.guildId} />;
}
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.GUILD !== type) {
throw new Error(`[MembersScreen] Unsupported search context type: ${searchContext4.type}`);
}
return <AnalyticsLocationProvider value={analyticsLocations2}>
<SearchableMembersScreen searchContext={searchContext4} guildId={searchContext4.guildId} />
</AnalyticsLocationProvider>;
});
export default r58;
@@ -0,0 +1,146 @@
// Metro module 15520 (f15521).
import * as Module19 from "react";
import { useCallback, useMemo } from "react";
import SearchPeopleTabStore from "../../../stores/SearchPeopleTabStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { USER_ESTIMATED_ITEM_SIZE, SearchListItemTypes } from "../../../../SearchConstants";
import { SearchResultContentEntityTypes } from "../../../tracking/TrackingConstants";
import { jsx } from "react/jsx-runtime";
import { getSearchContextId } from "../../../../SearchUtils";
import { useStateFromStores } from "../../../../../../_bundle/Module589";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import { useOnPressGroupDMItem, useOnPressDMItem } from "../../../hooks/useOnPressSearchItem";
import ChannelActionCreators from "../../../../../../actions/ChannelActionCreators";
import Tracking from "../../../tracking/Tracking";
import { useMessageTabCountsErrorText } from "../../../hooks/useSearchScreenError";
import ErrorScreen from "./ErrorScreen";
import SearchList from "../../list/SearchList";
let env11050 = {};
const r33 = Module19.memo(function PeopleScreen(a0) {
let c22108_0;
let env22107 = {
$parent: env11050
};
const searchContext = a0.searchContext;
env22107[0] = searchContext;
env22107[1] = void 0;
env22107[2] = void 0;
env22107[3] = void 0;
env22107[4] = void 0;
env22107[5] = void 0;
env22107[6] = void 0;
env22107[7] = void 0;
env22107[8] = void 0;
env22107[1] = getSearchContextId(searchContext);
const stateFromStores2 = useStateFromStores([SearchPeopleTabStore], () => SearchPeopleTabStore.getResults(env22107[1]));
env22107[2] = stateFromStores2;
const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(env22107[0]));
env22107[3] = stateFromStores;
const fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: USER_ESTIMATED_ITEM_SIZE,
numColumns: 1
});
env22107[4] = fullscreenPlaceholderCount;
const onPressGroupDMItem = useOnPressGroupDMItem({
searchContext
});
env22107[5] = onPressGroupDMItem;
const onPressDMItem = useOnPressDMItem({
searchContext
});
env22107[6] = onPressDMItem;
c22108_0 = void 0;
c22108_0 = async (c30886_0, c30886_1) => {
let c30886_3;
c30886_3 = void 0;
let c31766_0 = c30886_0;
let c31766_1 = c30886_1;
const orEnsurePrivateChannel = await ChannelActionCreators.getOrEnsurePrivateChannel(c30886_0);
const r48 = c30886_3;
let c31766_2 = orEnsurePrivateChannel;
const r54 = r48.$parent;
Tracking.trackSearchResultClicked({
searchContext: r54[0],
userId: c31766_0,
channelId: c31766_2,
index: c31766_1,
entityType: SearchResultContentEntityTypes.CHANNEL
});
(0, r54[6])(c31766_0, c31766_2);
};
const callback = useCallback(function() {
return c22108_0.apply(this, arguments);
}, [onPressDMItem, searchContext]);
env22107[7] = callback;
const callback2 = useCallback((a0, a1) => {
Tracking.trackSearchResultClicked({
searchContext: env22107[0],
channelId: a0,
index: a1,
entityType: SearchResultContentEntityTypes.CHANNEL
});
(0, env22107[5])(a0);
}, [onPressGroupDMItem, searchContext]);
env22107[8] = callback2;
const memo = useMemo(() => {
const r4 = [];
let c28066_0 = r4;
env22107[2].forEach(({ title, items }) => {
if (title != null && items.length > 0) {
c28066_0.push({
type: SearchListItemTypes.SECTION,
props: {
title
}
});
}
items.forEach((item, c31767_0) => {
if ("user" in item) {
const { type, user, firstMatch } = item;
c28066_0.push({
type: SearchListItemTypes.DM,
section: title,
props: {
type,
user,
nickname: user.username !== firstMatch ? firstMatch : void 0,
onPress: (a0) => (0, env22107[7])(a0, c31767_0)
}
});
} else {
c28066_0.push({
type: SearchListItemTypes.GROUP_DM,
section: title,
props: {
channel: item,
onPress: (a0) => (0, env22107[8])(a0, c31767_0)
}
});
}
});
});
if (!env22107[3] && r4.length === 0) {
const r3 = 0 < env22107[4];
let r19 = 0;
if (r3) {
do {
r4.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r19}`
});
r19 = r19 + 1;
} while (r19 < env22107[4]);
}
}
return r4;
}, [callback, callback2, stateFromStores, fullscreenPlaceholderCount, stateFromStores2]);
const messageTabCountsErrorText = useMessageTabCountsErrorText({
searchContext
});
return messageTabCountsErrorText != null ? (0, jsx)(ErrorScreen, {
text: messageTabCountsErrorText
}) : (0, jsx)(SearchList, {
data: memo
});
});
export default r33;
@@ -0,0 +1,329 @@
// Metro module 15478 (f15479).
import * as Module19 from "react";
import { useState, useCallback, useMemo } from "react";
import SearchMessageStore from "../../../../SearchMessageStore";
import SearchGuildChannelTabStore from "../../../stores/SearchGuildChannelTabStore";
import SearchHistoryStore from "../../../stores/SearchHistoryStore";
import SearchQueryStore from "../../../stores/SearchQueryStore";
import { SearchTabs, MESSAGE_PLACEHOLDER_ITEM_SIZE, SearchListItemTypes, EMPTY_SEARCH_QUERY_STRING } from "../../../../SearchConstants";
import { EMPTY_MEDIA_RESULTS } from "../../../SearchPlatformConstants";
import { SearchTypes } from "../../../../../../Constants";
import { jsx } from "react/jsx-runtime";
import { PressableHighlight } from "../../../../../../design/void/Pressables/native/Pressables";
import SearchPlatformActionCreators from "../../../SearchPlatformActionCreators";
import { intl, t } from "../../../../../../intl/index.native";
import { Text } from "../../../../../../design/components/Text/native/Text";
import useUserListData from "../../../../../main_tabs_v2/native/shared_components/user_list/useUserListData";
import { useOnPressMediaItem, useOnPressDMItem, useOnPressGuildTextChannel } from "../../../hooks/useOnPressSearchItem";
import ChannelActionCreators from "../../../../../../actions/ChannelActionCreators";
import Tracking from "../../../tracking/Tracking";
import { getSearchTabFetchId, getSearchContextId } from "../../../../SearchUtils";
import { useStateFromStoresObject, useStateFromStores } from "../../../../../../_bundle/Module589";
import { useFocusEffect } from "../../../../../../_bundle/Module1481";
import useSearchMediaSize from "../../../hooks/useSearchMediaSize";
import { getMedia } from "../../../SearchPlatformUtils";
import { shouldAgeVerifyForSearchMedia } from "../../../../../explicit_media_redaction/native/ExplicitMediaRedactionNativeUtils";
import AgeVerificationActionCreators_native from "../../../../../age_assurance/AgeVerificationActionCreators.native";
import { AgeVerificationModalEntryPoint } from "../../../../../age_assurance/AgeVerificationAnalyticsUtils";
import { useFullscreenPlaceholderCount } from "../../../hooks/usePlaceholderStyles";
import { RecentsMediaGridPlaceholder } from "./placeholders/MediaGridPlaceholder";
import SearchList from "../../list/SearchList";
let ViewAll, Component, c11012_20, c11012_21;
let env11012 = {};
const ClearAllHistory = function ClearAllHistory(props) {
const searchContext = props.searchContext;
return <PressableHighlight onPress={() => SearchPlatformActionCreators.clearSearchHistory(searchContext)} accessibilityRole="button" unstable_pressDelay={130} accessibilityLabel={intl.string(t.LFTAUp)}>
<Text variant="text-sm/semibold" color="text-brand">
{intl.string(t.LFTAUp)}
</Text>
</PressableHighlight>;
};
ViewAll = function ViewAll(props) {
return <PressableHighlight onPress={props.onJumpToMedia} accessibilityRole="button" unstable_pressDelay={130} accessibilityLabel={intl.string(t.Ofpgwh)}>
<Text variant="text-sm/semibold" color="text-brand">
{intl.string(t.Ofpgwh)}
</Text>
</PressableHighlight>;
};
Component = Module19.memo(function({ searchContext: searchContext2, onJumpToMedia, width, suggestedData }) {
let messages, isLoadingMediaGrid, isInitialSearchQuery, state, mediaSize, memo, onPressMediaItem, callback, fullscreenPlaceholderCount;
let searchContextId, setState;
messages = void 0;
isLoadingMediaGrid = void 0;
isInitialSearchQuery = void 0;
state = void 0;
mediaSize = void 0;
memo = void 0;
onPressMediaItem = void 0;
callback = void 0;
fullscreenPlaceholderCount = void 0;
const stateFromStoresObject = useStateFromStoresObject([SearchQueryStore, SearchMessageStore], () => {
const searchTabFetchId = getSearchTabFetchId(searchContext2, SearchTabs.MEDIA, SearchQueryStore.getSearchResultsQuery(searchContext2));
return {
messages: SearchMessageStore.getMessages(searchTabFetchId),
isLoadingMediaGrid: !SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId),
isInitialSearchQuery: SearchQueryStore.isInitialSearchQuery(searchContext2)
};
});
messages = stateFromStoresObject.messages;
isLoadingMediaGrid = stateFromStoresObject.isLoadingMediaGrid;
isInitialSearchQuery = stateFromStoresObject.isInitialSearchQuery;
searchContextId = getSearchContextId(searchContext2);
setState = void 0;
let state2;
[state2, setState] = useState(() => SearchHistoryStore.getSearchHistory(searchContextId));
useFocusEffect(useCallback(() => {
const handleChange2 = function handleChange() {
setState(SearchHistoryStore.getSearchHistory(searchContextId));
};
setState(SearchHistoryStore.getSearchHistory(searchContextId));
SearchHistoryStore.addReactChangeListener(handleChange2);
return () => {
SearchHistoryStore.removeReactChangeListener(handleChange2);
};
}, [searchContextId]));
state = state2;
mediaSize = useSearchMediaSize(width);
memo = useMemo(() => {
if (messages != null && messages.length !== 0) {
const r26 = [];
let c28037_0 = r26;
for (const message of messages) {
getMedia(searchContext2, [message]).forEach((item) => c28037_0.push(item));
if (!(r26.length >= 9)) {
continue;
}
break;
}
return r26;
}
return EMPTY_MEDIA_RESULTS;
}, [messages, searchContext2]);
onPressMediaItem = useOnPressMediaItem({
searchContext: searchContext2,
allMediaResults: memo
});
callback = useCallback(({ media, originView }) => {
if (shouldAgeVerifyForSearchMedia(media, messages == null ? void 0 : messages.find((message) => message.id === media.messageId))) {
AgeVerificationActionCreators_native.showAgeVerificationGetStartedModal({
entryPoint: AgeVerificationModalEntryPoint.SEARCH_MEDIA_PREVIEW
});
} else {
onPressMediaItem(media, originView);
}
}, [messages, onPressMediaItem]);
fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: MESSAGE_PLACEHOLDER_ITEM_SIZE,
numColumns: 1
});
return (0, jsx)(SearchList, {
data: useMemo(() => {
const r4 = [];
let c28039_0 = r4;
if (!isInitialSearchQuery && r4.length === 0) {
const r3 = 0 < fullscreenPlaceholderCount;
let r18 = 0;
if (r3) {
do {
r4.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r18}`
});
r18 = r18 + 1;
} while (r18 < fullscreenPlaceholderCount);
}
return r4;
}
if (state.length > 0) {
r4.push({
type: SearchListItemTypes.SECTION,
props: {
title: intl.string(t.ZZpBr4),
trailing: (0, jsx)(ClearAllHistory, {
searchContext: searchContext2
})
}
});
state.forEach((item) => {
c28039_0.push({
type: SearchListItemTypes.SEARCH_HISTORY_ITEM,
props: {
searchHistoryItem: item,
searchContext: searchContext2
}
});
});
}
if (suggestedData != null) {
suggestedData.forEach((item) => c28039_0.push(item));
}
if (memo.length > 0) {
r4.push({
type: SearchListItemTypes.SECTION,
props: {
title: intl.string(t.LBYpDH),
trailing: (0, jsx)(ViewAll, {
onJumpToMedia
})
}
});
r4.push({
type: SearchListItemTypes.MEDIA_GRID,
props: {
media: memo.slice(0, 9),
mediaSize,
onPress: callback,
animate: true
}
});
}
return r4;
}, [callback, isInitialSearchQuery, memo, mediaSize, onJumpToMedia, fullscreenPlaceholderCount, searchContext2, state, suggestedData]),
ListFooterComponent: useMemo(() => isLoadingMediaGrid ? () => (0, jsx)(RecentsMediaGridPlaceholder, {
numRows: 3,
visible: true,
size: mediaSize
}) : null, [isLoadingMediaGrid, mediaSize])
});
});
c11012_20 = Module19.memo(function(a0) {
const searchContext4 = a0.searchContext;
let env22052 = {
$parent: env11012
};
env22052[0] = searchContext4;
env22052[1] = void 0;
env22052[2] = void 0;
env22052[3] = void 0;
const userListData = useUserListData({
query: EMPTY_SEARCH_QUERY_STRING,
withGuildMembers: false,
withAffinitySuggestions: true,
affinitySuggestionsLimit: 3,
withFriends: false,
withFriendSuggestions: false,
withFriendRequests: false,
withFriendRequestsIncoming: false,
withFriendRequestsOutgoing: false,
excludeCurrentUser: true
});
env22052[1] = userListData;
const onPressDMItem = useOnPressDMItem({
searchContext: searchContext4
});
env22052[2] = onPressDMItem;
let c22053_0 = async (c31763_0) => {
let c31763_2;
c31763_2 = void 0;
let c32071_0 = c31763_0;
const orEnsurePrivateChannel = await ChannelActionCreators.getOrEnsurePrivateChannel(c31763_0);
const r46 = c31763_2;
let c32071_1 = orEnsurePrivateChannel;
const r53 = r46.$parent;
Tracking.trackSuggestedSearchClicked({
searchContext: r53[0],
channelId: c32071_1
});
(0, r53[2])(c32071_0, c32071_1);
};
const callback3 = useCallback(function() {
return c22053_0.apply(this, arguments);
}, [onPressDMItem, searchContext4]);
env22052[3] = callback3;
return <Component {...a0} suggestedData={useMemo(() => {
const r1 = [];
let c30880_0 = r1;
const r4 = env22052[1];
if (r4.length !== 0) {
r4.forEach(({ title, items }) => {
if (items.length !== 0 && title != null) {
c30880_0.push({
type: SearchListItemTypes.SECTION,
props: {
title
}
});
items.forEach((item) => {
c30880_0.push({
type: SearchListItemTypes.DM,
props: {
user: item.user,
onPress: env22052[3]
}
});
});
}
});
}
return r1;
}, [callback3, userListData])} />;
});
c11012_21 = Module19.memo(function(a0) {
let onPressGuildTextChannel, memo2, callback2;
const searchContext3 = a0.searchContext;
onPressGuildTextChannel = void 0;
memo2 = void 0;
callback2 = void 0;
const searchContextId2 = getSearchContextId(searchContext3);
const stateFromStores = useStateFromStores([SearchGuildChannelTabStore], () => SearchGuildChannelTabStore.getTextChannels(searchContextId2));
onPressGuildTextChannel = useOnPressGuildTextChannel({
searchContext: searchContext3
});
memo2 = useMemo(() => stateFromStores.slice(0, 3), [stateFromStores]);
callback2 = useCallback((a0) => {
Tracking.trackSuggestedSearchClicked({
searchContext: searchContext3,
channelId: a0
});
onPressGuildTextChannel(a0);
}, [onPressGuildTextChannel, searchContext3]);
return <Component {...a0} suggestedData={useMemo(() => {
const r2 = [];
let c30881_0 = r2;
if (memo2.length !== 0) {
r2.push({
type: SearchListItemTypes.SECTION,
props: {
title: intl.string(t.HbJ7eD)
}
});
memo2.forEach((item) => {
c30881_0.push({
type: SearchListItemTypes.GUILD_TEXT_CHANNEL,
props: {
channel: item.channel,
lastMessageId: item.lastMessageId,
onPress: callback2
}
});
});
}
return r2;
}, [callback2, memo2])} />;
});
const r55 = Module19.memo(function RecentScreenContainer({ searchContext: searchContext4, onJumpToMedia: onJumpToMedia2, width }) {
const type = searchContext4.type;
if (SearchTypes.DMS === type) {
return (0, jsx)(c11012_20, {
searchContext: searchContext4,
onJumpToMedia: onJumpToMedia2,
width
});
}
if (SearchTypes.GUILD === type) {
return (0, jsx)(c11012_21, {
searchContext: searchContext4,
onJumpToMedia: onJumpToMedia2,
width
});
}
if (SearchTypes.GUILD_CHANNEL !== type && SearchTypes.CHANNEL !== type) {
return null;
}
return (0, jsx)(Component, {
searchContext: searchContext4,
onJumpToMedia: onJumpToMedia2,
width
});
});
export default r55;
@@ -0,0 +1,114 @@
// Metro module 15530 (f15531).
import { useCallback, useEffect, useMemo } from "react";
import SearchMessageStore from "../../../../../SearchMessageStore";
import SearchQueryStore from "../../../../stores/SearchQueryStore";
import { SearchResultContentEntityTypes } from "../../../../tracking/TrackingConstants";
import Tracking from "../../../../tracking/Tracking";
import { useStateFromStoresObject } from "../../../../../../../_bundle/Module589";
import { getSearchTabFetchId } from "../../../../../SearchUtils";
import { useMessageSearchErrorScreen } from "../../../../hooks/useSearchScreenError";
import { useSearchFetchPendingManager } from "./SearchFetchPendingManager";
import SearchPlatformUtils from "../../../../SearchPlatformUtils";
import SearchHistoricalIndexingHeader from "./SearchHistoricalIndexingHeader";
import SearchIndexingScreen from "./SearchIndexingScreen";
import ErrorScreen from "../ErrorScreen";
import SearchList from "../../../list/SearchList";
export default function BaseMessagesScreen(props) {
let r66;
let isNextPageLoading, isHistoricalIndexing, documentsIndexed, hasError, isErrorToast, showErrorToast, searchFetchPendingManager;
const { data, searchContext, tab, isFocused } = props;
let isFirstPageLoading = props.isFirstPageLoading;
const { isNextPageLoading: isNextPageLoading2, contentContainerStyle, ItemSeparatorComponent, numColumns } = props;
isNextPageLoading = void 0;
isHistoricalIndexing = void 0;
documentsIndexed = void 0;
hasError = void 0;
isErrorToast = void 0;
showErrorToast = void 0;
searchFetchPendingManager = void 0;
if (!isFirstPageLoading) {
isFirstPageLoading = isNextPageLoading2;
}
L9: {
isNextPageLoading = isFirstPageLoading;
const stateFromStoresObject = useStateFromStoresObject([SearchQueryStore, SearchMessageStore], () => {
const searchTabFetchId = getSearchTabFetchId(searchContext, tab, SearchQueryStore.getSearchResultsQuery(searchContext));
return {
isIndexing: SearchMessageStore.getIsIndexing(searchTabFetchId),
isHistoricalIndexing: SearchMessageStore.getIsHistoricalIndexing(searchTabFetchId),
documentsIndexed: SearchMessageStore.getDocumentsIndexed(searchTabFetchId)
};
});
const isIndexing = stateFromStoresObject.isIndexing;
isHistoricalIndexing = stateFromStoresObject.isHistoricalIndexing;
documentsIndexed = stateFromStoresObject.documentsIndexed;
const messageSearchErrorScreen = useMessageSearchErrorScreen({
searchContext,
tab,
hasListItems: data.length > 0
});
hasError = messageSearchErrorScreen.hasError;
const { errorText, isErrorFullscreen } = messageSearchErrorScreen;
isErrorToast = messageSearchErrorScreen.isErrorToast;
showErrorToast = messageSearchErrorScreen.showErrorToast;
searchFetchPendingManager = useSearchFetchPendingManager(searchContext);
const callback = useCallback(() => {
if (data.length !== 0) {
if (isNextPageLoading) {
searchFetchPendingManager.add(tab);
} else if (isFocused) {
if (hasError) {
searchFetchPendingManager.add(tab);
} else {
SearchPlatformUtils.fetchNextMessages(searchContext, tab);
}
} else {
searchFetchPendingManager.add(tab);
}
}
}, [data.length, isNextPageLoading, isFocused, hasError, searchContext, tab, searchFetchPendingManager]);
useEffect(() => {
let r2 = isFocused;
if (isFocused) {
r2 = !isNextPageLoading;
}
if (r2) {
searchFetchPendingManager.flush(searchContext, tab);
}
}, [isFocused, isNextPageLoading, searchContext, searchFetchPendingManager, tab]);
useEffect(() => {
let r2 = isErrorToast;
if (isErrorToast) {
r2 = !isNextPageLoading;
}
if (r2) {
r2 = isFocused;
}
if (r2) {
showErrorToast();
}
}, [isErrorToast, isNextPageLoading, isFocused, showErrorToast]);
const memo = useMemo(() => isHistoricalIndexing ? documentsIndexed != null ? documentsIndexed > 0 ? <SearchHistoricalIndexingHeader searchContext={searchContext} documentsIndexed={documentsIndexed} tab={tab} /> : null : null : null, [documentsIndexed, isHistoricalIndexing, searchContext, tab]);
if (isIndexing) {
r66 = <SearchIndexingScreen searchContext={searchContext} />;
} else {
if (isErrorFullscreen && !isNextPageLoading) {
r66 = <ErrorScreen text={errorText} />;
break L9;
}
r66 = <SearchList contentContainerStyle={contentContainerStyle} data={data} onEndReached={callback} ListHeaderComponent={memo} ItemSeparatorComponent={ItemSeparatorComponent} numColumns={numColumns} />;
}
}
return r66;
};
export function trackMessageItemPress({ searchContext: searchContext2, channelId, messageId, index }) {
const message = SearchMessageStore.getMessage(messageId);
Tracking.trackSearchResultClicked({
searchContext: searchContext2,
channelId,
messageId,
userId: message == null ? void 0 : message.author?.id,
index,
entityType: SearchResultContentEntityTypes.MESSAGE
});
}
@@ -0,0 +1,97 @@
// Metro module 15535 (f15536).
import { memo, useCallback, useMemo } from "react";
import { CARD_ESTIMATED_ITEM_SIZE, FILES_OR_LINKS_GAP_WIDTH, FILES_OR_LINKS_NUM_COLUMNS, SearchListItemTypes } from "../../../../../SearchConstants";
import { useContentContainerStyles } from "../../hooks/useContentContainerStyles";
import { useSearchMessages } from "../../hooks/useSearchMessages";
import { useFileOrLinkImageDimensions } from "../../../../hooks/useFileOrLinkImageDimensions";
import { useOnPressMessageItem } from "../../../../hooks/useOnPressSearchItem";
import BaseMessagesScreen, { trackMessageItemPress } from "./BaseMessagesScreen";
import { useSearchMessagesLoadingState } from "../../hooks/useSearchMessagesLoadingState";
import { getFiles, getGridItemSpacingStyles } from "../../../../SearchPlatformUtils";
import { getAdjustedPlaceholderCount } from "../placeholders/PlaceholderUtils";
import { CardVerticalSeparator } from "../../../list/rows/Separators";
const r26 = memo(function FilesScreen(props) {
let placeholderCount;
const { searchContext, tab, isFocused, width } = props;
placeholderCount = void 0;
const styles = useContentContainerStyles();
const searchMessages = useSearchMessages(searchContext, tab);
const fileOrLinkImageDimensions = useFileOrLinkImageDimensions(width);
const onPressMessageItem = useOnPressMessageItem({
searchContext
});
const callback = useCallback(({ channelId, messageId }, a1) => {
trackMessageItemPress({
searchContext,
channelId,
messageId,
index: a1
});
onPressMessageItem(channelId, messageId);
}, [onPressMessageItem, searchContext]);
const searchMessagesLoadingState = useSearchMessagesLoadingState({
searchContext,
tab,
placeholderHeight: CARD_ESTIMATED_ITEM_SIZE,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
});
const { isFirstPageLoading, isNextPageLoading } = searchMessagesLoadingState;
placeholderCount = searchMessagesLoadingState.placeholderCount;
return <BaseMessagesScreen data={useMemo(() => {
const r5 = [];
let c28073_0 = r5;
let c28073_1 = 0;
if (searchMessages != null) {
searchMessages.forEach((searchMessage) => {
const files = getFiles(searchMessage);
files.forEach((file, index) => {
const itemIndex = c28073_1 + index;
let c31768_0 = itemIndex;
c28073_0.push({
type: SearchListItemTypes.FILE,
props: {
data: file,
onPress: (a0) => callback(a0, c31768_0),
imageStyle: fileOrLinkImageDimensions,
containerStyle: getGridItemSpacingStyles({
itemIndex,
spacing: FILES_OR_LINKS_GAP_WIDTH,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
})
}
});
});
c28073_1 = c28073_1 + files.length;
});
}
if (placeholderCount > 0) {
const length = r5.length;
const adjustedPlaceholderCount = getAdjustedPlaceholderCount({
numColumns: FILES_OR_LINKS_NUM_COLUMNS,
numResults: length,
placeholderCount
});
const r4 = 0 < adjustedPlaceholderCount;
let r31 = 0;
if (r4) {
do {
r5.push({
type: SearchListItemTypes.FILE_OR_LINK_PLACEHOLDER,
key: `file-or-link-placeholder-${r31}`,
props: {
imageStyle: fileOrLinkImageDimensions,
containerStyle: getGridItemSpacingStyles({
itemIndex: length + r31,
spacing: FILES_OR_LINKS_GAP_WIDTH,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
})
}
});
r31 = r31 + 1;
} while (r31 < adjustedPlaceholderCount);
}
}
return r5;
}, [callback, fileOrLinkImageDimensions, searchMessages, placeholderCount])} searchContext={searchContext} tab={tab} isFocused={isFocused} contentContainerStyle={styles.filesOrLinksContentContainer} ItemSeparatorComponent={CardVerticalSeparator} numColumns={FILES_OR_LINKS_NUM_COLUMNS} isFirstPageLoading={isFirstPageLoading} isNextPageLoading={isNextPageLoading} />;
});
export default r26;
@@ -0,0 +1,121 @@
// Metro module 15537 (f15538).
import { memo, useCallback, useMemo } from "react";
import { CARD_ESTIMATED_ITEM_SIZE, FILES_OR_LINKS_GAP_WIDTH, FILES_OR_LINKS_NUM_COLUMNS, SearchListItemTypes } from "../../../../../SearchConstants";
import { useContentContainerStyles } from "../../hooks/useContentContainerStyles";
import { useSearchMessages } from "../../hooks/useSearchMessages";
import { useFileOrLinkImageDimensions } from "../../../../hooks/useFileOrLinkImageDimensions";
import { useOnPressMessageItem, useOnPressSearchLink, useOnPressGuildVoiceChannel } from "../../../../hooks/useOnPressSearchItem";
import { useSearchMessagesLoadingState } from "../../hooks/useSearchMessagesLoadingState";
import BaseMessagesScreen, { trackMessageItemPress } from "./BaseMessagesScreen";
import { getLinks, getGridItemSpacingStyles } from "../../../../SearchPlatformUtils";
import { getAdjustedPlaceholderCount } from "../placeholders/PlaceholderUtils";
import { CardVerticalSeparator } from "../../../list/rows/Separators";
const r26 = memo(function LinksScreen(props) {
let callback2, callback3;
const { searchContext, tab, isFocused, width } = props;
callback2 = void 0;
callback3 = void 0;
const styles = useContentContainerStyles();
const searchMessages = useSearchMessages(searchContext, tab);
const fileOrLinkImageDimensions = useFileOrLinkImageDimensions(width);
const onPressMessageItem = useOnPressMessageItem({
searchContext
});
const onPressSearchLink2 = useOnPressSearchLink(searchContext);
const onPressGuildVoiceChannel = useOnPressGuildVoiceChannel({
searchContext
});
const searchMessagesLoadingState = useSearchMessagesLoadingState({
searchContext,
tab,
placeholderHeight: CARD_ESTIMATED_ITEM_SIZE,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
});
const { isFirstPageLoading, isNextPageLoading, placeholderCount } = searchMessagesLoadingState;
const callback = useCallback(({ channelId, messageId }, a1) => {
trackMessageItemPress({
searchContext,
channelId,
messageId,
index: a1
});
onPressMessageItem(channelId, messageId);
}, [onPressMessageItem, searchContext]);
callback2 = useCallback(({ channelId, messageId, url, trusted }, a1) => {
trackMessageItemPress({
searchContext,
channelId,
messageId,
index: a1
});
onPressSearchLink2(url, trusted);
}, [onPressSearchLink2, searchContext]);
callback3 = useCallback(({ channelId, messageId, mentionedChannelId }, a1) => {
trackMessageItemPress({
searchContext,
channelId,
messageId,
index: a1
});
onPressGuildVoiceChannel(mentionedChannelId);
}, [onPressGuildVoiceChannel, searchContext]);
return <BaseMessagesScreen data={useMemo(() => {
const r5 = [];
let c28074_0 = r5;
let c28074_1 = 0;
if (searchMessages != null) {
searchMessages.forEach((searchMessage) => {
const links = getLinks(searchContext, searchMessage);
links.forEach((link, index) => {
const itemIndex = c28074_1 + index;
let c31769_0 = itemIndex;
c28074_0.push({
type: SearchListItemTypes.LINK,
props: {
data: link,
onPress: (a0) => callback(a0, c31769_0),
onPressSearchLink: (a0) => callback2(a0, c31769_0),
onPressGuildVoiceChannelMention: (a0) => callback3(a0, c31769_0),
imageStyle: fileOrLinkImageDimensions,
containerStyle: getGridItemSpacingStyles({
itemIndex,
spacing: FILES_OR_LINKS_GAP_WIDTH,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
})
}
});
});
c28074_1 = c28074_1 + links.length;
});
}
if (placeholderCount > 0) {
const length = r5.length;
const adjustedPlaceholderCount = getAdjustedPlaceholderCount({
numColumns: FILES_OR_LINKS_NUM_COLUMNS,
numResults: length,
placeholderCount
});
const r4 = 0 < adjustedPlaceholderCount;
let r31 = 0;
if (r4) {
do {
r5.push({
type: SearchListItemTypes.FILE_OR_LINK_PLACEHOLDER,
key: `file-or-link-placeholder-${r31}`,
props: {
imageStyle: fileOrLinkImageDimensions,
containerStyle: getGridItemSpacingStyles({
itemIndex: length + r31,
spacing: FILES_OR_LINKS_GAP_WIDTH,
numColumns: FILES_OR_LINKS_NUM_COLUMNS
})
}
});
r31 = r31 + 1;
} while (r31 < adjustedPlaceholderCount);
}
}
return r5;
}, [callback3, callback2, callback, fileOrLinkImageDimensions, searchMessages, placeholderCount, searchContext])} searchContext={searchContext} tab={tab} isFocused={isFocused} contentContainerStyle={styles.filesOrLinksContentContainer} ItemSeparatorComponent={CardVerticalSeparator} numColumns={FILES_OR_LINKS_NUM_COLUMNS} isFirstPageLoading={isFirstPageLoading} isNextPageLoading={isNextPageLoading} />;
});
export default r26;
@@ -0,0 +1,130 @@
// Metro module 15527 (f15528).
import * as Module19 from "react";
import { useMemo, useCallback } from "react";
import SearchMessageStore from "../../../../../SearchMessageStore";
import SearchQueryStore from "../../../../stores/SearchQueryStore";
import { MEDIA_ITEM_GAP_WIDTH, MEDIA_NUM_COLUMNS, SearchListItemTypes, SearchMediaTypes } from "../../../../../SearchConstants";
import { EMPTY_MEDIA_RESULTS } from "../../../../SearchPlatformConstants";
import { MEDIA_MODAL_KEY } from "../../../../../../../Constants";
import { useContentContainerStyles } from "../../hooks/useContentContainerStyles";
import useSearchMediaSize from "../../../../hooks/useSearchMediaSize";
import { useSearchMessages } from "../../hooks/useSearchMessages";
import { useSearchMessagesLoadingState } from "../../hooks/useSearchMessagesLoadingState";
import SearchPlatformUtils, { getMedia, getMediaGridItemStyles } from "../../../../SearchPlatformUtils";
import { isModalOpen } from "../../../../../../main_tabs_v2/helpers/NavigationRouteUtils.native";
import { getSearchTabFetchId } from "../../../../../SearchUtils";
import { setMediaViewerSources } from "../../../../../../media_viewer/native/useMediaViewerSources";
import { useOnPressMediaItem } from "../../../../hooks/useOnPressSearchItem";
import { shouldAgeVerifyForSearchMedia } from "../../../../../../explicit_media_redaction/native/ExplicitMediaRedactionNativeUtils";
import AgeVerificationActionCreators_native from "../../../../../../age_assurance/AgeVerificationActionCreators.native";
import { AgeVerificationModalEntryPoint } from "../../../../../../age_assurance/AgeVerificationAnalyticsUtils";
import BaseMessagesScreen, { trackMessageItemPress } from "./BaseMessagesScreen";
import { getAdjustedPlaceholderCount } from "../placeholders/PlaceholderUtils";
import { MediaVerticalSeparator } from "../../../list/rows/Separators";
const r36 = Module19.memo(function MediaScreen(props) {
let onPressMediaItem, callback;
const { searchContext, tab, isFocused, width } = props;
onPressMediaItem = void 0;
callback = void 0;
const styles = useContentContainerStyles();
const size = useSearchMediaSize(width);
const searchMessages = useSearchMessages(searchContext, tab);
const searchMessagesLoadingState = useSearchMessagesLoadingState({
searchContext,
tab,
placeholderHeight: size,
numColumns: MEDIA_NUM_COLUMNS
});
const { isFirstPageLoading, isNextPageLoading, placeholderCount } = searchMessagesLoadingState;
const memo = useMemo(() => searchMessages != null ? getMedia(searchContext, searchMessages) : EMPTY_MEDIA_RESULTS, [searchMessages, searchContext]);
onPressMediaItem = useOnPressMediaItem({
searchContext,
allMediaResults: memo,
onEndReached: useCallback(() => {
SearchPlatformUtils.fetchNextMessages(searchContext, tab, () => {
if (isModalOpen(MEDIA_MODAL_KEY)) {
const messages = SearchMessageStore.getMessages(getSearchTabFetchId(searchContext, tab, SearchQueryStore.getSearchResultsQuery(searchContext)));
if (messages != null) {
const media2 = getMedia(searchContext, messages);
const sources = [];
let c30891_0 = sources;
media2.forEach((item) => {
if (!(item.type !== SearchMediaTypes.ATTACHMENT && item.type !== SearchMediaTypes.EMBED && item.type !== SearchMediaTypes.COMPONENT)) {
c30891_0.push(item.sources);
}
});
setMediaViewerSources({
sources
});
}
}
});
}, [searchContext, tab]),
onEndReachedThreshold: 500
});
callback = useCallback(({ media, originView }, a1) => {
if (shouldAgeVerifyForSearchMedia(media, searchMessages == null ? void 0 : searchMessages.find((searchMessage) => searchMessage.id === media.messageId))) {
AgeVerificationActionCreators_native.showAgeVerificationGetStartedModal({
entryPoint: AgeVerificationModalEntryPoint.SEARCH_MEDIA_PREVIEW
});
} else {
trackMessageItemPress({
searchContext,
channelId: media.channelId,
messageId: media.messageId,
index: a1
});
onPressMediaItem(media, originView);
}
}, [onPressMediaItem, searchContext, searchMessages]);
return <BaseMessagesScreen data={useMemo(() => {
const r6 = [];
let c28071_0 = r6;
memo.forEach((item, index) => {
c28071_0.push({
type: SearchListItemTypes.MEDIA,
props: {
media: item,
size,
onPress: (a0) => callback(a0, index),
containerStyle: getMediaGridItemStyles({
itemIndex: index,
numItems: memo.length,
numColumns: MEDIA_NUM_COLUMNS,
spacing: MEDIA_ITEM_GAP_WIDTH - 2
})
}
});
});
if (placeholderCount > 0) {
const length = r6.length;
const adjustedPlaceholderCount = getAdjustedPlaceholderCount({
numColumns: MEDIA_NUM_COLUMNS,
numResults: length,
placeholderCount
});
const r5 = 0 < adjustedPlaceholderCount;
let r31 = 0;
if (r5) {
do {
r6.push({
type: SearchListItemTypes.MEDIA_PLACEHOLDER,
key: `media-placeholder-${length + r31}`,
props: {
size,
containerStyle: getMediaGridItemStyles({
itemIndex: length + r31,
numItems: memo.length,
numColumns: MEDIA_NUM_COLUMNS,
spacing: MEDIA_ITEM_GAP_WIDTH - 2
})
}
});
r31 = r31 + 1;
} while (r31 < adjustedPlaceholderCount);
}
}
return r6;
}, [callback, memo, size, placeholderCount])} searchContext={searchContext} tab={tab} isFocused={isFocused} contentContainerStyle={styles.mediaContentContainer} ItemSeparatorComponent={MediaVerticalSeparator} numColumns={MEDIA_NUM_COLUMNS} isFirstPageLoading={isFirstPageLoading} isNextPageLoading={isNextPageLoading} />;
});
export default r36;
@@ -0,0 +1,81 @@
// Metro module 15544 (f15545).
import * as Module19 from "react";
import { useCallback, useRef, useMemo } from "react";
import SearchQueryStore from "../../../../stores/SearchQueryStore";
import { MESSAGE_PLACEHOLDER_ITEM_SIZE, SEARCH_FILTERS_BY_TAB, SEARCH_MESSAGES_DEFAULT_LINE_CLAMP, SEARCH_PINNED_MESSAGES_LINE_CLAMP, SearchFilter, SearchListItemTypes } from "../../../../../SearchConstants";
import { useSearchMessages } from "../../hooks/useSearchMessages";
import { useStateFromStores } from "../../../../../../../_bundle/Module589";
import { useOnPressMessageItem } from "../../../../hooks/useOnPressSearchItem";
import BaseMessagesScreen, { trackMessageItemPress } from "./BaseMessagesScreen";
import MessageSearchResultParser from "../../../../message_parsers/MessageSearchResultParser";
import { useSearchMessagesLoadingState } from "../../hooks/useSearchMessagesLoadingState";
import { getAdjustedPlaceholderCount } from "../placeholders/PlaceholderUtils";
import { useContentContainerStyles } from "../../hooks/useContentContainerStyles";
import { MessageVerticalSeparator } from "../../../list/rows/Separators";
const r30 = Module19.memo(function MessagesScreen(props) {
let onPressMessageItem, callback, ref, SEARCH_PINNED_MESSAGES_LINE_CLAMP2, memo, placeholderCount;
const { searchContext, tab, isFocused } = props;
onPressMessageItem = void 0;
callback = void 0;
ref = void 0;
SEARCH_PINNED_MESSAGES_LINE_CLAMP2 = void 0;
memo = void 0;
placeholderCount = void 0;
const searchMessages = useSearchMessages(searchContext, tab);
const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.getSearchResultsQuery(searchContext), [searchContext]);
onPressMessageItem = useOnPressMessageItem({
searchContext
});
callback = useCallback(({ channelId, messageId }, a1) => {
trackMessageItemPress({
searchContext,
channelId,
messageId,
index: a1
});
onPressMessageItem(channelId, messageId);
}, [onPressMessageItem, searchContext]);
ref = useRef({});
SEARCH_PINNED_MESSAGES_LINE_CLAMP2 = SEARCH_FILTERS_BY_TAB[tab] === SearchFilter.Pins ? SEARCH_PINNED_MESSAGES_LINE_CLAMP : SEARCH_MESSAGES_DEFAULT_LINE_CLAMP;
memo = useMemo(() => new MessageSearchResultParser(stateFromStores, SEARCH_PINNED_MESSAGES_LINE_CLAMP2), [SEARCH_PINNED_MESSAGES_LINE_CLAMP2, stateFromStores]);
const searchMessagesLoadingState = useSearchMessagesLoadingState({
searchContext,
tab,
placeholderHeight: MESSAGE_PLACEHOLDER_ITEM_SIZE,
numColumns: 1
});
placeholderCount = searchMessagesLoadingState.placeholderCount;
const { isFirstPageLoading, isNextPageLoading } = searchMessagesLoadingState;
return <BaseMessagesScreen data={useMemo(() => {
const r4 = [];
let c28076_0 = r4;
if (searchMessages != null) {
searchMessages.forEach((searchMessage, c30893_0) => {
c28076_0.push({
type: SearchListItemTypes.MESSAGE,
props: {
message: memo.parse(searchMessage),
onPress: (a0) => callback(a0, c30893_0),
lineClamp: SEARCH_PINNED_MESSAGES_LINE_CLAMP2,
messageSizeCacheRef: ref
}
});
});
}
const adjustedPlaceholderCount = getAdjustedPlaceholderCount({
numColumns: 1,
numResults: r4.length,
placeholderCount
});
let r0 = 0;
while (r0 < adjustedPlaceholderCount) {
r4.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r0}`
});
r0 = r0 + 1;
}
return r4;
}, [callback, SEARCH_PINNED_MESSAGES_LINE_CLAMP2, searchMessages, memo, placeholderCount])} searchContext={searchContext} tab={tab} isFocused={isFocused} contentContainerStyle={useContentContainerStyles().messagesContentContainer} ItemSeparatorComponent={MessageVerticalSeparator} isFirstPageLoading={isFirstPageLoading} isNextPageLoading={isNextPageLoading} />;
});
export default r30;
@@ -0,0 +1,124 @@
// Metro module 15551 (f15552).
import * as Module19 from "react";
import { useEffect, useCallback, useRef, useMemo } from "react";
import ChannelPinsStore, { FetchState } from "../../../../../../../stores/ChannelPinsStore";
import SearchMessageStore from "../../../../../SearchMessageStore";
import SearchQueryStore from "../../../../stores/SearchQueryStore";
import { MESSAGE_PLACEHOLDER_ITEM_SIZE, SEARCH_PINNED_MESSAGES_LINE_CLAMP, SearchListItemTypes } from "../../../../../SearchConstants";
import { SearchResultContentEntityTypes } from "../../../../tracking/TrackingConstants";
import { SearchTypes } from "../../../../../../../Constants";
import { useStateFromStores, useStateFromStoresObject } from "../../../../../../../_bundle/Module589";
import { useFullscreenPlaceholderCount } from "../../../../hooks/usePlaceholderStyles";
import ChannelPinActionCreators from "../../../../../../../actions/ChannelPinActionCreators";
import { useOnPressMessageItem } from "../../../../hooks/useOnPressSearchItem";
import Tracking from "../../../../tracking/Tracking";
import { useContentContainerStyles } from "../../hooks/useContentContainerStyles";
import SearchList from "../../../list/SearchList";
import { MessageVerticalSeparator } from "../../../list/rows/Separators";
import MessagesScreen from "./MessagesScreen";
const InitialPinsScreen = function InitialPinsScreen(props) {
let fullscreenPlaceholderCount, items, showLoading, onPressMessageItem, callback, ref;
const { searchContext, isFocused } = props;
fullscreenPlaceholderCount = void 0;
items = void 0;
showLoading = void 0;
onPressMessageItem = void 0;
callback = void 0;
ref = void 0;
const stateFromStores = useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(searchContext), [searchContext]);
fullscreenPlaceholderCount = useFullscreenPlaceholderCount({
placeholderHeight: MESSAGE_PLACEHOLDER_ITEM_SIZE,
numColumns: 1
});
useEffect(() => {
let r2 = stateFromStores;
if (stateFromStores) {
r2 = isFocused;
}
if (r2) {
ChannelPinActionCreators.fetchPins(searchContext.channelId);
}
}, [isFocused, stateFromStores, searchContext.channelId]);
const stateFromStoresObject = useStateFromStoresObject([ChannelPinsStore], () => {
const pins = ChannelPinsStore.getPins(searchContext.channelId);
return {
items: pins?.items,
showLoading: pins == null || pins.state === FetchState.LOADING
};
});
items = stateFromStoresObject.items;
showLoading = stateFromStoresObject.showLoading;
onPressMessageItem = useOnPressMessageItem({
searchContext
});
callback = useCallback(({ channelId, messageId }, a1) => {
const message = SearchMessageStore.getMessage(messageId);
Tracking.trackSearchResultClicked({
searchContext,
channelId,
messageId,
userId: message == null ? void 0 : message.author?.id,
index: a1,
entityType: SearchResultContentEntityTypes.MESSAGE
});
onPressMessageItem(channelId, messageId);
}, [onPressMessageItem, searchContext]);
ref = useRef({});
const memo = useMemo(() => {
const r4 = [];
let c28079_0 = r4;
if (items != null) {
items.forEach(({ message }, c30894_0) => {
c28079_0.push({
type: SearchListItemTypes.MESSAGE,
props: {
message,
onPress: (a0) => callback({
channelId: a0.channelId,
messageId: a0.messageId
}, c30894_0),
lineClamp: SEARCH_PINNED_MESSAGES_LINE_CLAMP,
messageSizeCacheRef: ref
}
});
});
}
if (showLoading) {
let r0 = 0;
while (r0 < fullscreenPlaceholderCount) {
r4.push({
type: SearchListItemTypes.MESSAGE_PLACEHOLDER,
key: `message-placeholder-${r0}`
});
r0 = r0 + 1;
}
}
return r4;
}, [fullscreenPlaceholderCount, callback, showLoading, items]);
return <SearchList contentContainerStyle={useContentContainerStyles().messagesContentContainer} data={memo} onEndReached={() => {
ChannelPinActionCreators.fetchPins(searchContext.channelId, {
before: items == null ? void 0 : items.at(-1)?.pinnedAt
});
}} ItemSeparatorComponent={MessageVerticalSeparator} />;
};
const r41 = Module19.memo(function PinsScreen(props) {
let r27, isFocused2, tab;
let searchContext2;
L6: {
L5: {
searchContext2 = props.searchContext;
tab = props.tab;
isFocused2 = props.isFocused;
if (useStateFromStores([SearchQueryStore], () => SearchQueryStore.isInitialSearchQuery(searchContext2), [searchContext2])) {
if (searchContext2.type !== SearchTypes.CHANNEL && searchContext2.type !== SearchTypes.GUILD_CHANNEL && searchContext2.type !== SearchTypes.THREAD) {
break L5;
}
r27 = <InitialPinsScreen searchContext={searchContext2} tab={tab} isFocused={isFocused2} />;
break L6;
}
}
r27 = <MessagesScreen searchContext={searchContext2} tab={tab} isFocused={isFocused2} />;
}
return r27;
});
export default r41;
@@ -0,0 +1,77 @@
// Metro module 15531 (f15532).
import { useEffect } from "react";
import SearchPlatformUtils from "../../../../SearchPlatformUtils";
import useInitialValue from "../../../../../../../hooks/useInitialValue";
function $mk96811($env) {
return (a0) => {
$env[0].pending.add(a0);
};
}
function $mk96812($env) {
return (a0) => {
$env[0].pending.delete(a0);
};
}
function $mk96813($env) {
return (a0) => $env[0].pending.has(a0);
}
function $mk96814($env) {
return (a0, a1) => {
const r2 = $env[0];
if (r2.has(a1)) {
const r8 = $env.$parent;
if ((0, r8[0])(r8[1][1]).fetchNextMessages(a0, a1)) {
r2.remove(a1);
}
}
};
}
function $mk96815($env) {
return () => {
$env[0].pending = new Set();
};
}
let env11060 = {};
class SearchFetchPendingManager {
constructor() {
let env22121;
const r1 = env22121 = {
$parent: env11060
};
env22121[0] = this;
this.pending = new Set();
this.add = $mk96811(r1);
this.remove = $mk96812(r1);
this.has = $mk96813(r1);
this.flush = $mk96814(r1);
this.reset = $mk96815(r1);
}
}
export function useSearchFetchPendingManager(a0) {
let c22122_1;
let c22122_0 = a0;
const initialValue = useInitialValue(() => {
let env28072;
const r9 = {
__proto__: SearchFetchPendingManager.prototype
};
const r10 = env28072 = {
$parent: env11060
};
env28072[0] = r9;
r9.pending = new Set();
r9.add = $mk96811(r10);
r9.remove = $mk96812(r10);
r9.has = $mk96813(r10);
r9.flush = $mk96814(r10);
r9.reset = $mk96815(r10);
return r9;
});
c22122_1 = initialValue;
useEffect(() => SearchPlatformUtils.subscribeTextInputValue(c22122_0, (a0, a1) => {
if (a1 !== a0) {
c22122_1.reset();
}
}), [a0, initialValue]);
return initialValue;
}
@@ -0,0 +1,40 @@
// Metro module 15532 (f15533).
import { useMemo, useEffect } from "react";
import LocaleStore from "../../../../../../user_settings/LocaleStore";
import * as _SearchConstants from "../../../../../SearchConstants";
import { SearchTabs } from "../../../../../SearchConstants";
import { createStyles } from "../../../../../../../design/components/Styles/native/createStyles";
import Tracking from "../../../../tracking/Tracking";
import { Card } from "../../../../../../../design/components/Card/native/Card.native";
import { Text } from "../../../../../../../design/components/Text/native/Text";
import { intl, t } from "../../../../../../../intl/index.native";
const { SEARCH_LIST_HORIZONTAL_PADDING, SEARCH_ROW_TAP_STATE_PADDING } = _SearchConstants;
const useStyles = createStyles({
header: {
marginBottom: 16
},
headerMessages: {
marginHorizontal: SEARCH_LIST_HORIZONTAL_PADDING,
marginTop: SEARCH_ROW_TAP_STATE_PADDING
}
});
export default function HistoricalIndexingHeader(props) {
const { searchContext, documentsIndexed, tab } = props;
const styles = useStyles();
const memo = useMemo(() => Number(documentsIndexed).toLocaleString(LocaleStore.locale), [documentsIndexed]);
const memo2 = useMemo(() => tab !== SearchTabs.MESSAGES ? tab === SearchTabs.PINS ? styles.headerMessages : void 0 : styles.headerMessages, [styles.headerMessages, tab]);
useEffect(() => {
Tracking.trackSearchIndexing({
searchContext,
isHistoricalIndexing: true,
documentsIndexed
});
}, [documentsIndexed, searchContext]);
return <Card variant="primary" border="subtle" style={[styles.header, memo2]}>
<Text variant="heading-sm/normal" color="interactive-text-default">
{intl.format(t["4Y3O+O"], {
count: memo
})}
</Text>
</Card>;
};
@@ -0,0 +1,14 @@
// Metro module 15533 (f15534).
import { useEffect } from "react";
import Tracking from "../../../../tracking/Tracking";
import { getIndexingErrorText } from "../../../../../SearchUtils";
import ErrorScreen from "../ErrorScreen";
export default function SearchIndexingScreen(props) {
const searchContext = props.searchContext;
useEffect(() => {
Tracking.trackSearchIndexing({
searchContext
});
}, [searchContext]);
return <ErrorScreen text={getIndexingErrorText(searchContext)} />;
};
@@ -0,0 +1,19 @@
// Metro module 15504 (f15505).
import { useMemo } from "react";
import { usePlaceholderAnimatedStyle } from "../../../../hooks/usePlaceholderStyles";
import { useFontScale } from "../../../../../../screen/native/useFontScale";
import ReanimatedRexport from "../../../../../../reanimated/ReanimatedRexport";
import { SearchListCardContainer } from "../../../list/SearchListCard";
export default function FileOrLinkGridPlaceholderItem(props) {
const { imageStyle, containerStyle } = props;
const placeholderAnimatedStyle = usePlaceholderAnimatedStyle(true);
const fontScale = useFontScale();
const width = imageStyle.width;
const height = imageStyle.height + 108 * fontScale;
return <ReanimatedRexport.View style={[containerStyle, placeholderAnimatedStyle]} pointerEvents="none">
<SearchListCardContainer containerStyle={useMemo(() => ({
width,
height
}), [width, height])} />
</ReanimatedRexport.View>;
};
@@ -0,0 +1,53 @@
// Metro module 15511 (f15512).
import { View } from "react-native";
import { SEARCH_ROW_TAP_STATE_PADDING } from "../../../../../SearchConstants";
import { createStyles } from "../../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../../_bundle/Module712";
import { usePlaceholderAnimatedStyle } from "../../../../hooks/usePlaceholderStyles";
import ReanimatedRexport from "../../../../../../reanimated/ReanimatedRexport";
const useStyles = createStyles({
itemContainer: {
flexDirection: "row",
paddingHorizontal: 16,
overflow: "hidden",
height: 64,
paddingVertical: SEARCH_ROW_TAP_STATE_PADDING,
alignItems: "center"
},
avatar: {
height: 48,
width: 48,
borderRadius: Module712.radii.xl,
marginRight: 16,
backgroundColor: Module712.colors.BORDER_SUBTLE
},
innerContainer: {
justifyContent: "center",
flex: 1
},
upperText: {
width: "50%",
borderRadius: Module712.radii.md,
height: 16,
marginBottom: 8,
backgroundColor: Module712.colors.BORDER_SUBTLE
},
lowerText: {
justifyContent: "center",
width: "100%",
borderRadius: Module712.radii.md,
height: 16,
backgroundColor: Module712.colors.BORDER_SUBTLE
}
});
export default function FormRowPlaceholderItem(props) {
const style = props.style;
const styles = useStyles();
return <ReanimatedRexport.View style={[usePlaceholderAnimatedStyle(true), styles.itemContainer, style]} pointerEvents="none">
<View style={styles.avatar} />
<View style={styles.innerContainer}>
<View style={styles.upperText} />
<View style={styles.lowerText} />
</View>
</ReanimatedRexport.View>;
};
@@ -0,0 +1,20 @@
// Metro module 15486 (f15487).
import { memo } from "react";
import { View } from "react-native";
import { createStyles } from "../../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../../_bundle/Module712";
const useStyles = createStyles({
imageContainer: {
flex: 1,
borderRadius: Module712.radii.xs,
overflow: "hidden",
backgroundColor: Module712.colors.BORDER_SUBTLE
}
});
const r37 = memo(function({ width, height, style }) {
return <View style={[{
width,
height
}, useStyles().imageContainer, style]} />;
});
export default r37;
@@ -0,0 +1,89 @@
// Metro module 15485 (f15486).
import { useMemo, Fragment } from "react";
import { View } from "react-native";
import * as _SearchConstants from "../../../../../SearchConstants";
import { MEDIA_ITEM_GAP_WIDTH, MEDIA_NUM_COLUMNS } from "../../../../../SearchConstants";
import { createStyles } from "../../../../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../../../../_bundle/Module712";
import { usePlaceholderAnimatedStyle } from "../../../../hooks/usePlaceholderStyles";
import ReanimatedRexport from "../../../../../../reanimated/ReanimatedRexport";
import GridItemPlaceholder from "./GridItemPlaceholder";
import { range, chunk } from "../../../../../../../_bundle/Module12";
import { Text } from "../../../../../../../design/components/Text/native/Text";
import { intl, t } from "../../../../../../../intl/index.native";
import { getMediaGridItemStyles } from "../../../../SearchPlatformUtils";
import { MediaVerticalSeparator } from "../../../list/rows/Separators";
const { SEARCH_LIST_SECTION_TOP_PADDING, SEARCH_LIST_HORIZONTAL_PADDING } = _SearchConstants;
const useStyles = createStyles({
container: {
zIndex: 1,
position: "absolute",
width: "100%"
},
recentsContainer: {
position: "relative",
paddingHorizontal: SEARCH_LIST_HORIZONTAL_PADDING
},
row: {
flexDirection: "row"
},
section: {
flex: 1,
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
textTransform: "none",
paddingTop: SEARCH_LIST_SECTION_TOP_PADDING,
paddingBottom: 8
},
sectionItem: {
borderRadius: Module712.radii.xs,
backgroundColor: Module712.colors.BORDER_SUBTLE
},
sectionText: {
opacity: 0
}
});
export default function MediaGridPlaceholderItem(props) {
const { size: size2, containerStyle } = props;
return <ReanimatedRexport.View style={[containerStyle, usePlaceholderAnimatedStyle(true)]} pointerEvents="none">
<GridItemPlaceholder height={size2} width={size2} style={containerStyle} />
</ReanimatedRexport.View>;
};
export function RecentsMediaGridPlaceholder(props) {
let memo2;
const { visible, size, numRows } = props;
memo2 = void 0;
const styles = useStyles();
const memo = useMemo(() => range(0, numRows * MEDIA_NUM_COLUMNS), [numRows]);
memo2 = useMemo(() => chunk(memo, MEDIA_NUM_COLUMNS), [memo]);
return <ReanimatedRexport.View style={[styles.container, styles.recentsContainer, usePlaceholderAnimatedStyle(visible)]} pointerEvents="none">
<View style={styles.section}>
<View style={styles.sectionItem}>
<Text style={styles.sectionText} maxFontSizeMultiplier={2} accessibilityRole="header" variant="text-sm/semibold" color="interactive-text-default">
{intl.string(t.LBYpDH)}
</Text>
</View>
<View style={styles.sectionItem}>
<Text variant="text-sm/semibold" color="text-brand" style={styles.sectionText}>
{intl.string(t.LFTAUp)}
</Text>
</View>
</View>
{memo2.map((item, index) => {
let c28057_0 = index;
return <Fragment key={index}>
<View style={styles.row}>
{item.map((item, index) => <GridItemPlaceholder key={index} height={size} width={size} style={getMediaGridItemStyles({
itemIndex: c28057_0 * MEDIA_NUM_COLUMNS + index,
numItems: memo.length,
numColumns: MEDIA_NUM_COLUMNS,
spacing: MEDIA_ITEM_GAP_WIDTH
})} />)}
</View>
{index < memo2.length - 1 && <MediaVerticalSeparator />}
</Fragment>;
})}
</ReanimatedRexport.View>;
}
@@ -0,0 +1,11 @@
// Metro module 15517 (f15518).
import { createStyles } from "../../../../../../../design/components/Styles/native/createStyles";
import FormRowPlaceholder from "./FormRowPlaceholder";
const useStyles = createStyles({
container: {
paddingHorizontal: 0
}
});
export default function MemberRowPlaceholderItem() {
return <FormRowPlaceholder style={useStyles().container} />;
};
@@ -0,0 +1,4 @@
// Metro module 15534 (f15535).
export function getAdjustedPlaceholderCount({ numColumns, numResults, placeholderCount }) {
return placeholderCount !== 0 ? placeholderCount + (numColumns - numResults % numColumns) : 0;
}
@@ -0,0 +1,34 @@
// Metro module 15555 (f15556).
import { useCallback, useEffect } from "react";
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME } from "../SearchPlatformConstants";
import { getGuildIdFromSearchContext } from "../../SearchUtils";
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
import { debounce } from "../../../../_bundle/Module12";
import SearchPlatformUtils from "../SearchPlatformUtils";
export function useAutoSearchGuildChannelTab(a0, a1) {
const searchContext = a0;
const callback = useCallback((a0) => {
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
if (guildIdFromSearchContext != null) {
SearchPlatformActionCreators.searchGuildChannelTab({
searchContext,
searchQueryString: a0,
guildId: guildIdFromSearchContext
});
}
}, [a0]);
useEffect(() => {
if (!a1) {
callback("");
}
}, [a1, callback]);
useEffect(() => {
if (a1) {
return void 0;
}
return SearchPlatformUtils.subscribeTextInputValue(searchContext, debounce(callback, SEARCH_TEXT_INPUT_DEBOUNCE_TIME), true);
}, [a0, a1, callback]);
useEffect(() => () => {
SearchPlatformActionCreators.cleanupGuildChannelTab(searchContext);
}, [a0]);
}
@@ -0,0 +1,36 @@
// Metro module 15556 (f15557).
import { useEffect } from "react";
import SearchQueryStore from "../stores/SearchQueryStore";
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME } from "../SearchPlatformConstants";
import { SearchTypes } from "../../../../Constants";
import { debounce } from "../../../../_bundle/Module12";
import { getGuildIdFromSearchContext } from "../../SearchUtils";
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
import SearchPlatformUtils from "../SearchPlatformUtils";
export function useAutoSearchMembersTab(a0, a1) {
const searchContext = a0;
useEffect(() => {
if (a1) {
return void 0;
}
return SearchPlatformUtils.subscribeTextInputValue(searchContext, debounce((a0) => {
if (!SearchQueryStore.isAutocompleteVisible(searchContext)) {
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
if (guildIdFromSearchContext != null) {
const channelIds = SearchQueryStore.getChannelIds(searchContext);
const channelId = channelIds.size !== 0 ? channelIds.size === 1 ? Array.from(channelIds)[0] : null : null;
SearchPlatformActionCreators.searchGuildMemberTab({
searchContext,
searchQueryString: a0,
guildId: guildIdFromSearchContext,
channelId,
threadId: searchContext.type === SearchTypes.THREAD ? channelId : null
});
}
}
}, SEARCH_TEXT_INPUT_DEBOUNCE_TIME));
}, [a1, a0]);
useEffect(() => () => {
SearchPlatformActionCreators.cleanupGuildMemberTab(searchContext);
}, [a0]);
}
@@ -0,0 +1,30 @@
// Metro module 15557 (f15558).
import { useEffect } from "react";
import SearchQueryStore from "../stores/SearchQueryStore";
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME } from "../SearchPlatformConstants";
import { fetchUserAffinitiesV2 } from "../../../user_affinities/UserAffinitiesActionCreators";
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
import { debounce } from "../../../../_bundle/Module12";
import SearchPlatformUtils from "../SearchPlatformUtils";
export function useAutoSearchPeopleTab(a0, a1) {
let c22182_0 = a0;
useEffect(() => {
if (!a1) {
fetchUserAffinitiesV2();
SearchPlatformActionCreators.searchPeopleTab(c22182_0, "");
}
}, [a1, a0]);
useEffect(() => {
if (a1) {
return void 0;
}
return SearchPlatformUtils.subscribeTextInputValue(c22182_0, debounce((a0) => {
if (!SearchQueryStore.isAutocompleteVisible(c22182_0)) {
SearchPlatformActionCreators.searchPeopleTab(c22182_0, a0);
}
}, SEARCH_TEXT_INPUT_DEBOUNCE_TIME));
}, [a0, a1]);
useEffect(() => () => {
SearchPlatformActionCreators.cleanupPeopleTab(c22182_0);
}, [a0]);
}
@@ -0,0 +1,47 @@
// Metro module 15558 (f15559).
import { useRef, useEffect } from "react";
import { SearchTabs } from "../../SearchConstants";
import Tracking from "../tracking/Tracking";
export function useAutoTrackSearchTabCountsViewedAnalytics({ searchContext, visibleTabCounts, visibleTabs }) {
const ref = useRef(visibleTabs);
useEffect(() => {
ref.current = visibleTabs;
}, [visibleTabs]);
useEffect(() => {
if (visibleTabCounts != null) {
const searchResultTotalCount = Object.keys(visibleTabCounts).reduce((acc, item) => {
let r4 = visibleTabCounts == null ? null : ref.current.includes(item) ? visibleTabCounts[item] : null;
if (r4 == null) {
r4 = 0;
}
return acc + r4;
}, 0);
if (searchResultTotalCount > 0) {
const MEMBERS = SearchTabs.MEMBERS;
const numMemberTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(MEMBERS) ? visibleTabCounts[MEMBERS] : null;
const GUILD_CHANNELS = SearchTabs.GUILD_CHANNELS;
const numChannelTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(GUILD_CHANNELS) ? visibleTabCounts[GUILD_CHANNELS] : null;
const PEOPLE = SearchTabs.PEOPLE;
const numPeopleTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(PEOPLE) ? visibleTabCounts[PEOPLE] : null;
const MESSAGES = SearchTabs.MESSAGES;
const numMessageTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(MESSAGES) ? visibleTabCounts[MESSAGES] : null;
const MEDIA = SearchTabs.MEDIA;
const numMediaTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(MEDIA) ? visibleTabCounts[MEDIA] : null;
const FILES = SearchTabs.FILES;
const numFileTabReturnedResults = visibleTabCounts == null ? null : ref.current.includes(FILES) ? visibleTabCounts[FILES] : null;
const LINKS = SearchTabs.LINKS;
Tracking.trackSearchResultReturned({
searchContext,
searchResultTotalCount,
numMemberTabReturnedResults,
numChannelTabReturnedResults,
numPeopleTabReturnedResults,
numMessageTabReturnedResults,
numMediaTabReturnedResults,
numFileTabReturnedResults,
numLinkTabReturnedResults: visibleTabCounts == null ? null : ref.current.includes(LINKS) ? visibleTabCounts[LINKS] : null
});
}
}
}, [searchContext, visibleTabCounts]);
}
@@ -0,0 +1,11 @@
// Metro module 15536 (f15537).
import { useMemo } from "react";
import { FILES_OR_LINKS_GAP_WIDTH, FILES_OR_LINKS_NUM_COLUMNS, FILE_OR_LINK_IMAGE_RATIO, SEARCH_LIST_HORIZONTAL_PADDING } from "../../SearchConstants";
export function useFileOrLinkImageDimensions(a0) {
const width = (a0 - 2 * SEARCH_LIST_HORIZONTAL_PADDING - (FILES_OR_LINKS_NUM_COLUMNS - 1) * FILES_OR_LINKS_GAP_WIDTH) / FILES_OR_LINKS_NUM_COLUMNS - 2;
const height = width * FILE_OR_LINK_IMAGE_RATIO;
return useMemo(() => ({
width,
height
}), [height, width]);
}
@@ -0,0 +1,428 @@
// Metro module 15480 (f15481).
import { useCallback, useContext } from "react";
import ChannelStore from "../../../../stores/ChannelStore";
import SearchQueryStore from "../stores/SearchQueryStore";
import { SearchHistoryItemTypes, SearchMediaTypes, SearchQueryTagTypes } from "../../SearchConstants";
import { SearchNavigatorScreens } from "../components/navigator/SearchNavigatorConstants";
import { SearchFilterAddLocations } from "../tracking/TrackingConstants";
import { SearchTypes, ME, Routes } from "../../../../Constants";
import { StaticChannelRoute } from "../../../channel/ChannelConstants";
import SearchPlatformUtils, { delayUntilNavigationComplete, performKeyboardAwareNavigation } from "../SearchPlatformUtils";
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
import URLUtils from "../../../../utils/URLUtils";
import { presentFailedToast } from "../../../toast/native/ToastUtils";
import { intl, t } from "../../../../intl/index.native";
import { handleClick } from "../../../../utils/MaskedLinkUtils";
import Linking from "../../../../lib/native/Linking";
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
import { SwipeForMemberListContext } from "../../../main_tabs_v2/native/channel/SwipeForMemberListWrapper";
import MessagePreviewActionCreators from "../../../../actions/native/MessagePreviewActionCreators";
import { openMediaModal } from "../../../media_viewer/native/components/openMediaModal";
import ChannelActionCreators from "../../../../actions/ChannelActionCreators";
import { transitionToChannel } from "../../../routing/transitionToChannel";
import "../../../../_bundle/asyncRequire";
import { maybeOpenAgeGateForVoiceChannel } from "../../../age_gate/AgeGateUtils";
import { maybeOpenSpoilerGateForVoiceChannel } from "../../../spoiler_channels/maybeOpenSpoilerGateForVoiceChannel.native";
import { getChannelRoleSubscriptionStatus } from "../../../guild_role_subscriptions/useChannelRoleSubscriptionStatus";
import { shouldShowMembershipVerificationGate } from "../../../guild_member_verification/hooks/useShowMemberVerificationGate";
import { transitionTo } from "../../../routing/router_utils";
import Tracking from "../tracking/Tracking";
function $mk96657($env) {
return () => {
const r1 = $env;
const r2 = $env.$parent;
return (0, r2[1])(r2[2][10]).addSearchHistoryItem(r1[0], r1[1]);
};
}
function $mk96658($env) {
return () => {
const r5 = $env;
const r1 = $env.$parent;
(0, r1[0])(r1[2][19]).ComponentDispatch.dispatch(r1[13].HIDE_CHANNEL_DETAILS, {
channelId: r5[0].id,
screenIndex: r5[1].screenIndex
});
};
}
function $mk118936($env) {
return () => (0, handleVoiceOrStageChannelConnectPress)($env[0]);
}
let env11014 = {};
export async function handleVoiceOrStageChannelConnectPress(c28040_0) {
let c30882_0 = c28040_0;
if (c28040_0.isGuildStageVoice()) {
(0, (await import("../../../stage_channels/StageChannelModalActionCreators")).connectAndOpen)(c30882_0);
} else {
(0, (await import("../../../../utils/native/PrivateChannelCallUtils")).openGuildVoiceModal)(c30882_0, "Channel List");
}
}
export function useOnPressSearchLink(a0) {
let c22057_0 = a0;
return useCallback((a0, c28041_0) => {
let c28041_1;
let env28042;
const r3 = env11014;
const tags = SearchQueryStore.getTags(c22057_0);
const r18 = {
type: SearchHistoryItemTypes.TEXT,
text: SearchQueryStore.getTextInputValue(c22057_0),
tags
};
const r19 = env28042 = {
$parent: r3
};
env28042[0] = c22057_0;
env28042[1] = r18;
const type = c22057_0.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r19));
}
const r38 = URLUtils.safeParseWithQuery(a0);
if (r38 != null && (r38.protocol != null && r38.hostname != null)) {
const href = URLUtils.format(r38);
c28041_1 = href;
handleClick({
href,
onConfirm: () => Linking.openURL(c28041_1),
trusted: () => c28041_0
});
} else {
presentFailedToast(intl.string(t.XiqzAp));
}
}, [a0]);
}
export function useOnPressMessageItem({ searchContext }) {
const navigation = useNavigation();
const context = useContext(SwipeForMemberListContext);
return useCallback((a0, a1) => {
const r3 = env11014;
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
let env28044;
const tags = SearchQueryStore.getTags(searchContext);
const r16 = {
type: SearchHistoryItemTypes.TEXT,
text: SearchQueryStore.getTextInputValue(searchContext),
tags
};
const r17 = env28044 = {
$parent: r3
};
env28044[0] = searchContext;
env28044[1] = r16;
const type = searchContext.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r17));
}
MessagePreviewActionCreators.fetchMessages(a0, a1);
performKeyboardAwareNavigation(() => {
let env30883;
const r5 = env30883 = {
$parent: env11014
};
env30883[0] = channel;
env30883[1] = context;
let guildId = channel.getGuildId();
if (guildId == null) {
guildId = ME;
}
const r6 = {
channelId: channel.id,
guildId,
searchContext
};
if (context != null) {
navigation.navigate("sidebar", {
screen: SearchNavigatorScreens.SEARCH_CHAT_PREVIEW,
params: {
...r6,
onBeforeJumpToMessage: $mk96658(r5)
}
});
} else {
navigation.navigate(SearchNavigatorScreens.SEARCH_CHAT_PREVIEW, r6);
}
});
}
}, [navigation, searchContext, context]);
}
export function useOnPressMediaItem({ searchContext: searchContext2, allMediaResults, onEndReached, onEndReachedThreshold }) {
const navigation2 = useNavigation();
const context2 = useContext(SwipeForMemberListContext);
return useCallback((a0, a1) => {
let channel2, c28045_2, initialIndex, c28045_4;
let env28046;
const r4 = env11014;
const tags = SearchQueryStore.getTags(searchContext2);
const r14 = {
type: SearchHistoryItemTypes.TEXT,
text: SearchQueryStore.getTextInputValue(searchContext2),
tags
};
const r15 = env28046 = {
$parent: r4
};
env28046[0] = searchContext2;
env28046[1] = r14;
const type = searchContext2.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r15));
}
const type2 = a0.type;
if (SearchMediaTypes.AUDIO === type2) {
channel2 = ChannelStore.getChannel(a0.channelId);
if (channel2 == null) {
return void 0;
}
MessagePreviewActionCreators.fetchMessages(a0.channelId, a0.messageId);
performKeyboardAwareNavigation(() => {
let env30884;
const r5 = env30884 = {
$parent: env11014
};
env30884[0] = channel2;
env30884[1] = context2;
let guildId = channel2.getGuildId();
if (guildId == null) {
guildId = ME;
}
const r6 = {
channelId: channel2.id,
guildId,
searchContext: searchContext2
};
if (context2 != null) {
navigation2.navigate("sidebar", {
screen: SearchNavigatorScreens.SEARCH_CHAT_PREVIEW,
params: {
...r6,
onBeforeJumpToMessage: $mk96658(r5)
}
});
} else {
navigation2.navigate(SearchNavigatorScreens.SEARCH_CHAT_PREVIEW, r6);
}
});
return void 0;
}
if (!(SearchMediaTypes.ATTACHMENT !== type2 && (SearchMediaTypes.EMBED !== type2 && SearchMediaTypes.COMPONENT !== type2))) {
c28045_2 = 0;
initialIndex = 0;
const initialSources = [];
c28045_4 = initialSources;
allMediaResults.forEach((allMediaResult) => {
if (!(allMediaResult.type !== SearchMediaTypes.ATTACHMENT && allMediaResult.type !== SearchMediaTypes.EMBED && allMediaResult.type !== SearchMediaTypes.COMPONENT)) {
c28045_4.push(allMediaResult.sources);
const messageId = allMediaResult.messageId;
if (messageId === a0.messageId && allMediaResult.mediaIndex === a0.mediaIndex) {
initialIndex = c28045_2;
}
c28045_2 = c28045_2 + 1;
}
});
openMediaModal({
initialSources,
initialIndex,
onEndReached,
onEndReachedThreshold,
analyticsSource: "Search",
originViewOrOriginLayout: a1
});
}
}, [searchContext2, navigation2, context2, allMediaResults, onEndReached, onEndReachedThreshold]);
}
export function useOnPressGroupDMItem({ searchContext: searchContext3 }) {
const navigation3 = useNavigation();
return useCallback((a0) => {
let env28048;
const r3 = env11014;
const r6 = {
type: SearchHistoryItemTypes.GROUP_DM,
channelId: a0
};
const r10 = env28048 = {
$parent: r3
};
env28048[0] = searchContext3;
env28048[1] = r6;
const type = searchContext3.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r10));
}
const parent = navigation3.getParent();
if (parent != null) {
parent.goBack();
}
ChannelActionCreators.preload(ME, a0);
performKeyboardAwareNavigation(() => {
transitionToChannel(a0);
});
}, [navigation3, searchContext3]);
}
export function useOnPressDMItem({ searchContext: searchContext4 }) {
const navigation4 = useNavigation();
return useCallback((a0, a1) => {
let env28050;
const r4 = env11014;
const r7 = {
type: SearchHistoryItemTypes.DM,
userId: a0
};
const r11 = env28050 = {
$parent: r4
};
env28050[0] = searchContext4;
env28050[1] = r7;
const type = searchContext4.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r11));
}
const parent = navigation4.getParent();
if (parent != null) {
parent.goBack();
}
ChannelActionCreators.preload(ME, a1);
performKeyboardAwareNavigation(() => {
transitionToChannel(a1);
});
return a1;
}, [navigation4, searchContext4]);
}
export function useOnPressGuildTextChannel({ searchContext: searchContext5 }) {
return useCallback((a0) => {
const r4 = env11014;
const channel3 = ChannelStore.getChannel(a0);
if (channel3 == null) {
return null;
}
let env28052;
const r7 = {
type: SearchHistoryItemTypes.GUILD_TEXT_CHANNEL,
channelId: channel3.id
};
const r15 = env28052 = {
$parent: r4
};
env28052[0] = searchContext5;
env28052[1] = r7;
const type = searchContext5.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r15));
}
ChannelActionCreators.preload(channel3.guild_id, channel3.id);
performKeyboardAwareNavigation(() => transitionToChannel(channel3.id));
}, [searchContext5]);
}
export function useOnPressGuildVoiceChannel({ searchContext: searchContext6 }) {
let callback;
callback = void 0;
const navigation5 = useNavigation();
let c22064_0 = async (c31764_0) => {
let r12, r84, r87;
let c31764_1;
L22: {
L21: {
L16: {
let env32072;
const r14 = env32072 = {
$parent: env11014
};
c31764_1 = r14;
env32072[0] = c31764_0;
env32072[1] = void 0;
if (maybeOpenAgeGateForVoiceChannel(c31764_0.id)) {
break L22;
}
if (maybeOpenSpoilerGateForVoiceChannel(c31764_0.id)) {
break L22;
}
const needSubscriptionToAccess = getChannelRoleSubscriptionStatus(c31764_0.id).needSubscriptionToAccess;
const guildId = c31764_0.getGuildId();
env32072[1] = guildId;
if (guildId != null && shouldShowMembershipVerificationGate(guildId)) {
r12 = (0, (await import("../../../guild_member_verification/MemberVerificationModalActionCreators")).openMemberVerificationModal)(env32072[1], $mk118936(c31764_1));
break L16;
}
if (needSubscriptionToAccess) {
r84 = transitionTo(Routes.CHANNEL(c31764_0.guild_id, StaticChannelRoute.ROLE_SUBSCRIPTIONS));
} else {
handleVoiceOrStageChannelConnectPress(c31764_0);
r84 = void 0;
}
r87 = r84;
break L21;
}
return r12;
}
return r87;
}
};
callback = useCallback(function() {
return c22064_0.apply(this, arguments);
}, []);
return useCallback((a0) => {
const r3 = env11014;
const channel4 = ChannelStore.getChannel(a0);
if (channel4 == null) {
return null;
}
let env28054;
const r7 = {
type: SearchHistoryItemTypes.GUILD_VOICE_CHANNEL,
channelId: channel4.id
};
const r14 = env28054 = {
$parent: r3
};
env28054[0] = searchContext6;
env28054[1] = r7;
const type = searchContext6.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r14));
}
const parent = navigation5.getParent();
if (parent != null) {
parent.goBack();
}
performKeyboardAwareNavigation(() => callback(channel4));
}, [navigation5, callback, searchContext6]);
}
export function useOnPressSearchHistoryText({ searchContext: searchContext7 }) {
return useCallback((a0, a1) => {
let env28056;
let c28055_0 = a0;
const r3 = env11014;
const r8 = {
type: SearchHistoryItemTypes.TEXT,
text: a0,
tags: a1
};
const r12 = env28056 = {
$parent: r3
};
env28056[0] = searchContext7;
env28056[1] = r8;
const type = searchContext7.type;
if (!(SearchTypes.DMS !== type && SearchTypes.GUILD !== type)) {
delayUntilNavigationComplete($mk96657(r12));
}
SearchPlatformActionCreators.updateSearchQuery(searchContext7, (a0) => {
if (a1 != null) {
a0.setTags(a1);
}
a0.setTextInputValue(c28055_0);
});
SearchPlatformUtils.fetchInitialMessages(searchContext7);
if (a1 != null) {
a1.forEach((item) => {
if (item.type === SearchQueryTagTypes.COMPLETE) {
Tracking.trackSearchFilterAdd({
searchContext: searchContext7,
searchTokenType: item.searchTokenType,
location: SearchFilterAddLocations.SEARCH_HISTORY
});
}
});
}
}, [searchContext7]);
}
@@ -0,0 +1,59 @@
// Metro module 15484 (f15485).
import AccessibilityStore from "../../../a11y/AccessibilityStore";
import { FADE_LAYOUT_ANIMATION_DURATION } from "../../SearchConstants";
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
import { useStateFromStores } from "../../../../_bundle/Module589";
import * as _ReanimatedRexport from "../../../reanimated/ReanimatedRexport";
import { useAnimatedStyle } from "../../../reanimated/ReanimatedRexport";
import * as _timing from "../../../../design/animation/reanimated/timing/timing";
import * as _native from "../../../../design/void/native";
const __initData = {
code: "function usePlaceholderStylesTsx1(){const{useReducedMotion,visible,withRepeat,withSequence,withTiming,STANDARD_EASING,FADE_LAYOUT_ANIMATION_DURATION}=this.__closure;if(useReducedMotion){return{opacity:visible?1:0};}if(visible){return{opacity:withRepeat(withSequence(withTiming(0.5,{duration:0}),withTiming(1,{duration:1300,easing:STANDARD_EASING}),withTiming(0.5,{duration:1300,easing:STANDARD_EASING})),-1)};}return{opacity:withTiming(0,{duration:FADE_LAYOUT_ANIMATION_DURATION})};}"
};
export function useFullscreenPlaceholderCount({ placeholderHeight, numColumns }) {
return Math.ceil(useWindowDimensions_native({
ignoreKeyboard: true
}).height / placeholderHeight) * numColumns;
}
export function usePlaceholderAnimatedStyle(a0) {
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
const A = function A() {
let r21;
const r4 = {
opacity: null
};
if (stateFromStores) {
r4.opacity = a0 ? 1 : 0;
r21 = r4;
} else if (a0) {
r4.opacity = _ReanimatedRexport.withRepeat(_ReanimatedRexport.withSequence(_timing.withTiming(0.5, {
duration: 0
}), _timing.withTiming(1, {
duration: 1300,
easing: _native.STANDARD_EASING
}), _timing.withTiming(0.5, {
duration: 1300,
easing: _native.STANDARD_EASING
})), -1);
r21 = r4;
} else {
r4.opacity = _timing.withTiming(0, {
duration: FADE_LAYOUT_ANIMATION_DURATION
});
r21 = r4;
}
return r21;
};
A.__closure = {
useReducedMotion: stateFromStores,
visible: a0,
withRepeat: _ReanimatedRexport.withRepeat,
withSequence: _ReanimatedRexport.withSequence,
withTiming: _timing.withTiming,
STANDARD_EASING: _native.STANDARD_EASING,
FADE_LAYOUT_ANIMATION_DURATION
};
A.__workletHash = 9750536800906;
A.__initData = __initData;
return useAnimatedStyle(A);
}
@@ -0,0 +1,76 @@
// Metro module 10100 (f10101).
import { useMemo } from "react";
import ChannelStore from "../../../../stores/ChannelStore";
import { SearchTypes } from "../../../../Constants";
import Module38 from "../../../../_bundle/Module38";
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
export function useGuildSearchContext(a0) {
const guildId = a0;
return useMemo(() => ({
type: SearchTypes.GUILD,
guildId
}), [a0]);
}
export function useGuildChannelSearchContext(a0, a1) {
const guildId2 = a0;
const channelId = a1;
return useMemo(() => ({
type: SearchTypes.GUILD_CHANNEL,
guildId: guildId2,
channelId
}), [a0, a1]);
}
export function getChannelDetailsSearchContext(a0, a1, a2) {
let r9;
if (a2) {
Module38(a1 != null, "[useChannelDetailsSearchContext] Thread must have a guild id");
r9 = {
type: SearchTypes.THREAD,
guildId: a1,
channelId: a0
};
} else {
r9 = a1 == null ? {
type: SearchTypes.CHANNEL,
channelId: a0
} : {
type: SearchTypes.GUILD_CHANNEL,
guildId: a1,
channelId: a0
};
}
return r9;
}
export function useChannelDetailsSearchContext(a0, a1) {
const channelId2 = a0;
const guildId3 = a1;
const stateFromStores = useStateFromStores([ChannelStore], () => {
const channel = ChannelStore.getChannel(channelId2);
let r8 = channel == null ? void 0 : channel.isThread();
if (r8 == null) {
r8 = false;
}
return r8;
});
return useMemo(() => {
let r10;
if (stateFromStores) {
Module38(guildId3 != null, "[useChannelDetailsSearchContext] Thread must have a guild id");
r10 = {
type: SearchTypes.THREAD,
guildId: guildId3,
channelId: channelId2
};
} else {
r10 = guildId3 == null ? {
type: SearchTypes.CHANNEL,
channelId: channelId2
} : {
type: SearchTypes.GUILD_CHANNEL,
guildId: guildId3,
channelId: channelId2
};
}
return r10;
}, [a0, a1, stateFromStores]);
}
@@ -0,0 +1,5 @@
// Metro module 15693 (f15694).
import useSafeAreaInsets_native from "../../../safe_area/useSafeAreaInsets.native";
export default function useSearchLayoutInsetTop() {
return useSafeAreaInsets_native().top + 8;
};
@@ -0,0 +1,5 @@
// Metro module 15483 (f15484).
import { MEDIA_ITEM_GAP_WIDTH, MEDIA_NUM_COLUMNS, SEARCH_LIST_HORIZONTAL_PADDING } from "../../SearchConstants";
export default function useSearchMediaSize(a0) {
return Math.floor((a0 - 2 * SEARCH_LIST_HORIZONTAL_PADDING - MEDIA_ITEM_GAP_WIDTH * (MEDIA_NUM_COLUMNS - 1)) / MEDIA_NUM_COLUMNS);
};
@@ -0,0 +1,17 @@
// Metro module 15508 (f15509).
import { useMemo } from "react";
import SnowflakeUtils from "../../../../utils/SnowflakeUtils";
import { getRelativeTimestamp } from "../../../notification_center/NotificationCenterUtils";
export function useSearchMessageTimestamp(a0, a1) {
return useMemo(() => {
let id = a0.id;
if (id == null) {
id = a1.id;
}
const r12 = SnowflakeUtils.extractTimestamp(id);
return {
timestamp: getRelativeTimestamp(r12, true),
timestampAccessibilityLabel: getRelativeTimestamp(r12, false)
};
}, [a0, a1]);
}
@@ -0,0 +1,60 @@
// Metro module 15521 (f15522).
import { useRef, useCallback } from "react";
import SearchMessageStore from "../../SearchMessageStore";
import SearchQueryStore from "../stores/SearchQueryStore";
import { SEARCH_MESSAGE_TAB_SENTINEL } from "../../SearchConstants";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { getSearchTabFetchId } from "../../SearchUtils";
import { intl, t } from "../../../../intl/index.native";
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
import Module8346 from "../../../../_bundle/Module8346";
export function useMessageSearchErrorScreen({ searchContext, tab, hasListItems }) {
let content, ref;
content = void 0;
ref = void 0;
const stateFromStores = useStateFromStores([SearchQueryStore, SearchMessageStore], () => SearchMessageStore.getError(getSearchTabFetchId(searchContext, tab, SearchQueryStore.getSearchResultsQuery(searchContext))));
let r19 = stateFromStores == null ? void 0 : stateFromStores.getAnyErrorMessage();
if (r19 == null) {
r19 = intl.string(t.uvDZBZ);
}
content = r19;
ref = useRef(null);
return {
hasError: stateFromStores != null,
errorText: content,
isErrorFullscreen: stateFromStores != null && !hasListItems,
isErrorToast: stateFromStores != null && hasListItems,
showErrorToast: useCallback(() => {
if (stateFromStores !== ref.current) {
ToastActionCreators.open({
key: "SEARCH_ERROR_TOAST",
icon: Module8346,
content
});
ref.current = stateFromStores;
}
}, [stateFromStores, content])
};
}
export function useMessageTabCountsErrorText({ searchContext: searchContext2 }) {
return useStateFromStores([SearchQueryStore, SearchMessageStore], () => {
const searchTabFetchId = getSearchTabFetchId(searchContext2, SEARCH_MESSAGE_TAB_SENTINEL, SearchQueryStore.getSearchResultsQuery(searchContext2));
if (SearchMessageStore.getIsInitialFetchComplete(searchTabFetchId)) {
if (SearchMessageStore.getTotalCount(searchTabFetchId) != null) {
return null;
}
const error = SearchMessageStore.getError(searchTabFetchId);
const r2 = error == null;
let r23 = null;
if (!r2) {
let r25 = error.getAnyErrorMessage();
if (r25 == null) {
r25 = intl.string(t.uvDZBZ);
}
r23 = r25;
}
return r23;
}
return null;
});
}
@@ -0,0 +1,13 @@
// Metro module 15546 (f15547).
export class CachedSearchResultParser {
resultsCache = new Map();
parse = (a0) => {
const r7 = this.resultsCache.get(a0.id);
if (r7 != null) {
return r7;
}
const searchResults = this.getSearchResults(a0);
this.resultsCache.set(a0.id, searchResults);
return searchResults;
};
}
@@ -0,0 +1,61 @@
// Metro module 15545 (f15546).
import MessageRecord from "../../../../records/MessageRecord";
import { CachedSearchResultParser } from "./CachedSearchResultParser";
import { getQueryContentString, getSearchQueryFromTokens, tokenizeQuery } from "../../SearchUtils";
import { analyze, shouldHighlight } from "../../../../lib/search/EnglishAnalyzer";
import { chain } from "../../../../_bundle/Module12";
class SearchResultMessageParser extends CachedSearchResultParser {
constructor(a0, a1) {
super();
const _this = this;
this.truncateMessage = function truncateMessage(a0, a1, r10 = 1) {
if (a0 == null) {
return null;
}
const r15 = a0.replace(/(\r\n|\n|\r)/gm, " ");
let c28077_0 = new Set(analyze(a1));
const r31 = r15.split(/(\W+)/g).find((item) => shouldHighlight(item, c28077_0));
if (r31 == null) {
return null;
}
const r41 = r15.search(new RegExp("\\b" + r31 + "\\b"));
if (r41 === -1) {
return null;
}
const r49 = Math.max(0, r41 - (30 * r10 - r31.length));
return `${r49 > 0 ? "..." : ""}${r15.substring(r49)}`;
};
this.getSearchResults = (a0) => {
if (_this.tokenizedQueryContent != null && _this.tokenizedQueryContent !== "") {
const content = _this.truncateMessage(a0.content, _this.tokenizedQueryContent, _this.lineClamp);
if (content != null) {
const messageRecord2 = new MessageRecord(a0);
messageRecord2.content = content;
return messageRecord2;
}
const content2 = chain(a0.embeds).map((item) => {
let r8 = _this.truncateMessage(item.rawTitle, _this.tokenizedQueryContent, _this.lineClamp);
if (r8 == null) {
r8 = _this.truncateMessage(item.rawDescription, _this.tokenizedQueryContent, _this.lineClamp);
}
return r8;
}).find((item) => item != null).value();
if (content2 != null) {
const messageRecord = new MessageRecord(a0);
messageRecord.content = content2;
return messageRecord;
}
return a0;
}
return a0;
};
const queryContentString = getQueryContentString(getSearchQueryFromTokens(tokenizeQuery(a0)));
let tokenizedQueryContent = queryContentString == null ? void 0 : queryContentString.trim();
if (tokenizedQueryContent == null) {
tokenizedQueryContent = "";
}
this.tokenizedQueryContent = tokenizedQueryContent;
this.lineClamp = a1;
}
}
export default SearchResultMessageParser;
@@ -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;
Loaded 100 of 33051 files, more files were not shown because too many files have changed in this diff. Show more