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

+7
View File
@@ -0,0 +1,7 @@
// Metro module 6176 (f6177).
import { AutocompleterResultTypes } from "../autocompleter/index";
let c3917_0 = Array.from([AutocompleterResultTypes.USER, AutocompleterResultTypes.TEXT_CHANNEL, AutocompleterResultTypes.VOICE_CHANNEL, AutocompleterResultTypes.GROUP_DM]);
export { c3917_0 as ALLOWED_TYPES };
export function isAllowedType(a0) {
return c3917_0.includes(a0.type);
}
+217
View File
@@ -0,0 +1,217 @@
// Metro module 6158 (f6159).
import QuickSwitcherStore from "../quickswitcher/QuickSwitcherStore";
import ChannelStore from "../../stores/ChannelStore";
import PermissionStore from "../../stores/PermissionStore";
import UserStore from "../../stores/UserStore";
import { isAllowedType } from "./ShareConstants";
import { ChannelTypes, Permissions } from "../../Constants";
import ChannelActionCreators from "../../actions/ChannelActionCreators";
import { AutocompleterResultTypes, createHeaderResult } from "../autocompleter/index";
import createAutocompleterResultForChannelId from "../autocompleter/createAutocompleterResultForChannelId";
import { intl, t } from "../../intl/index.native";
import { isNotNullish } from "../../utils/GlobalUtils";
import { isEqual } from "../../_bundle/Module12";
import { HermesBuiltin } from "../../_hermes/prelude";
function $mk77849($env) {
return (a0) => {
const r3 = $env.$parent;
const r5 = r3[0];
const r2 = r3[2];
let r8 = r5(r2[11]).isNotNullish(a0);
if (r8) {
let r14 = a0.type === r5(r2[8]).AutocompleterResultTypes.HEADER;
if (!r14) {
let r16 = (0, r3[8])(a0);
if (r16) {
const r17 = $env;
r16 = (0, r17[1])(a0, r17[0]);
}
r14 = r16;
}
r8 = r14;
}
return r8;
};
}
let canShareToChannel, mergeAndDedupeResultsWithHeaders;
let env3900 = {};
export function getChannelIdFromDestinationId(a0) {
if (a0.type === "channel") {
return a0.id;
}
const dMFromUserId = ChannelStore.getDMFromUserId(a0.id);
return dMFromUserId ?? void 0;
}
canShareToChannel = function canShareToChannel(a0, a1) {
return a0.type === AutocompleterResultTypes.USER ? a1 ? a1 : ChannelStore.getDMChannelFromUserId(a0.record.id) != null : a0.type === AutocompleterResultTypes.GROUP_DM || a0.record.type !== ChannelTypes.GUILD_FORUM && a0.record.type !== ChannelTypes.GUILD_MEDIA && (PermissionStore.can(Permissions.VIEW_CHANNEL, a0.record) && PermissionStore.can(Permissions.SEND_MESSAGES, a0.record));
};
mergeAndDedupeResultsWithHeaders = function mergeAndDedupeResultsWithHeaders(a0, a1) {
let r8 = void 0;
const set = new Set();
if (a1 != null) {
for (const item of a1) {
set.add(item);
}
}
const r36 = [];
for (const item2 of a0) {
if (item2 != null) {
if (item2.type === AutocompleterResultTypes.HEADER) {
r8 = item2;
} else {
const id = item2.record.id;
if (!set.has(id)) {
set.add(id);
if (r8 != null) {
r36.push(r8);
r8 = void 0;
}
r36.push(item2);
}
}
}
}
return r36;
};
export default function formatResults(a0) {
let r50;
const { results, hasQuery, queryMode, frequentChannels, targetDestination, selectedDestinations, pinnedDestinations, originDestination } = a0;
let channelFilter = a0.channelFilter;
const includeMissingDMs = a0.includeMissingDMs;
if (hasQuery) {
let env15535;
const r92 = env15535 = {
$parent: env3900
};
env15535[0] = includeMissingDMs;
if (channelFilter === void 0) {
channelFilter = canShareToChannel;
}
env15535[1] = channelFilter;
return mergeAndDedupeResultsWithHeaders(results.filter($mk77849(r92)));
}
const r14 = pinnedDestinations != null && pinnedDestinations.length > 0 ? pinnedDestinations.map((pinnedDestination) => {
let r12;
if (pinnedDestination.type === "user") {
const user = UserStore.getUser(pinnedDestination.id);
r12 = user != null ? {
type: AutocompleterResultTypes.USER,
record: user,
score: 0
} : null;
} else {
r12 = createAutocompleterResultForChannelId(pinnedDestination.id);
}
return r12;
}) : [];
const channelHistory = QuickSwitcherStore.getChannelHistory();
const r33 = channelHistory.length > 0 ? channelHistory.map((item) => createAutocompleterResultForChannelId(item)) : [];
const r37 = frequentChannels.length > 0 ? frequentChannels.map((frequentChannel) => createAutocompleterResultForChannelId(frequentChannel.id)) : [];
const r40 = [,];
const r2 = HermesBuiltin.arraySpread(r40, r14, 0);
const r3 = targetDestination != null;
let r41 = null;
if (r3) {
if (targetDestination.type === "user") {
const user = UserStore.getUser(targetDestination.id);
r50 = user != null ? {
type: AutocompleterResultTypes.USER,
record: user,
score: 0
} : null;
} else {
r50 = createAutocompleterResultForChannelId(targetDestination.id);
}
r41 = r50;
}
let env15534;
r40[r2] = r41;
HermesBuiltin.arraySpread(r40, r37, HermesBuiltin.arraySpread(r40, r33, r2 + 1));
const r69 = env15534 = {
$parent: env3900
};
env15534[1] = void 0;
env15534[0] = includeMissingDMs;
env15534[1] = channelFilter === void 0 ? canShareToChannel : channelFilter;
const r74 = r40.filter($mk77849(r69));
const r79 = (selectedDestinations == null ? void 0 : selectedDestinations.find((selectedDestination) => isEqual(selectedDestination, originDestination))) != null;
const r81 = originDestination != null && !r79 ? [originDestination.id] : [];
return queryMode != null ? mergeAndDedupeResultsWithHeaders(r74.filter((item) => item.type === queryMode), r81) : mergeAndDedupeResultsWithHeaders(r74, r81).slice(0, 15);
};
export function getDestinationIdFromChannelId(a0) {
const channel = ChannelStore.getChannel(a0);
return channel?.type === ChannelTypes.DM ? {
type: "user",
id: channel.recipients[0]
} : {
type: "channel",
id: a0
};
}
export function destinationKey(a0) {
return `${a0.type}-${a0.id}`;
}
export async function getOrResolveChannelIdFromDestinationId(c25727_0) {
let channelIdFromDestinationId, orEnsurePrivateChannel;
let c25727_4 = 0;
L15: {
L14: {
try {
channelIdFromDestinationId = getChannelIdFromDestinationId(c25727_0);
if (channelIdFromDestinationId != null) {
break L15;
}
if (c25727_0.type === "user") {
c25727_4 = 1;
orEnsurePrivateChannel = await ChannelActionCreators.getOrEnsurePrivateChannel(c25727_0.id);
c25727_4 = 0;
break L14;
}
} catch ($e) {
let r8 = $e;
if (c25727_4 !== 0) {
while (true) {
try {
c25727_4 = 0;
} catch ($e) {
r8 = $e;
if (c25727_4 === 0) {
break;
}
continue;
}
return void 0;
}
}
throw r8;
}
return void 0;
}
return orEnsurePrivateChannel;
}
return channelIdFromDestinationId;
}
export function formatResultsWithHeaders({ results, selectedResult, hasNonEmptyQuery, queryMode: queryMode2, selectedChannelId, frequentChannels }) {
let r61;
const r7 = selectedResult != null ? [selectedResult.record.id] : [];
const headerResult = createHeaderResult(intl.string(t.qm9dSj));
if (hasNonEmptyQuery) {
return [headerResult, ...mergeAndDedupeResultsWithHeaders(results.filter(isAllowedType), r7)];
}
const r47 = frequentChannels.map((frequentChannel) => createAutocompleterResultForChannelId(frequentChannel.id)).filter(isNotNullish).filter(isAllowedType);
if (queryMode2 != null) {
r61 = [headerResult, ...r47.filter((item) => item.type === queryMode2)];
} else {
r61 = [createHeaderResult(intl.string(t["80lOZ1"])), , ,];
const r3 = selectedChannelId == null;
let r62 = null;
if (!r3) {
const autocompleterResultForChannelId = createAutocompleterResultForChannelId(selectedChannelId);
r62 = autocompleterResultForChannelId == null ? null : isAllowedType(autocompleterResultForChannelId) ? autocompleterResultForChannelId.type === AutocompleterResultTypes.USER || PermissionStore.can(Permissions.VIEW_CHANNEL, autocompleterResultForChannelId.record) ? autocompleterResultForChannelId : null : null;
}
r61[1] = r62;
r61[2] = headerResult;
HermesBuiltin.arraySpread(r61, r47, 3);
}
return mergeAndDedupeResultsWithHeaders(r61, r7);
}
+83
View File
@@ -0,0 +1,83 @@
// Metro module 16764 (f16765).
import { useState, useEffect } from "react";
import { BackHandler, NativeModules } from "react-native";
import "../../../stores/AnalyticsTrackingStore";
import "../../../stores/native/ShareStore";
import AuthenticationStore from "../../../stores/AuthenticationStore";
import { AnalyticEvents } from "../../../Constants";
import { MultiAccountSwitchLocation } from "../../multi_account/Constants";
import { useStateFromStores } from "../../../_bundle/Module589";
import AuthenticationActionCreators from "../../../actions/AuthenticationActionCreators";
import { isAndroid } from "../../../utils/PlatformUtils";
import AccessibilityManager from "../../a11y/native/AccessibilityManager";
import { switchAccount } from "../../multi_account/MultiAccountActionCreators";
import { trackAppUIViewed } from "../../tti_analytics/native/TTIAnalyticsUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import useMountEffect from "../../../hooks/useMountEffect";
import AppContainer from "../../../components_native/AppContainer";
import ShareScreen from "./ShareScreen";
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
import Module8197 from "../../../_bundle/Module8197";
import { SceneLoadingIndicator } from "../../../design/components/Navigator/native/SceneLoadingIndicator.native";
import { ActionSheetContainer } from "../../../components_native/MainShared";
import ToastContainer from "../../toast/native/ToastContainer";
import { AlertModalContainer } from "../../../design/components/AlertModal/native/AlertModal.native";
const appEntryKey = "share";
export default function AppShare(props) {
let c23404_0 = props;
const targetUserId = props.targetUserId;
let [state2, setState] = useState(false);
const state = state2;
const [state3, setState2] = useState(targetUserId == null || AuthenticationStore.getId() === targetUserId);
useEffect(() => {
if (!state) {
AccessibilityManager.init();
setState(true);
}
}, [state]);
useEffect(() => {
if (targetUserId != null && AuthenticationStore.getId() !== targetUserId) {
setTimeout(() => {
switchAccount(targetUserId, false, MultiAccountSwitchLocation.SHARE_EXTENSION).then(() => {
setState2(true);
});
}, 18);
}
}, [targetUserId]);
if (state) {
state2 = state3;
}
const stateFromStores = useStateFromStores([AuthenticationStore], () => AuthenticationStore.isAuthenticated());
useEffect(() => {
if (stateFromStores) {
AuthenticationActionCreators.startSession(AuthenticationStore.getToken());
if (isAndroid()) {
NativeModules.NativePermissionManager.requestNotificationAuthorization();
}
}
}, [stateFromStores]);
useEffect(() => {
const EXTERNAL_SHARE_OPENED = AnalyticEvents.EXTERNAL_SHARE_OPENED;
AnalyticsUtils.track(EXTERNAL_SHARE_OPENED, {
has_content: c23404_0.text != null && c23404_0.text.length > 0,
has_attachment: c23404_0.attachments.length > 0
});
}, [props.attachments.length, props.text]);
useMountEffect(() => {
trackAppUIViewed("share", {
share_num_attachments: c23404_0.attachments.length,
share_attachment_mimetypes: c23404_0.attachments.map(({ mimeType }) => {
if (mimeType == null) {
mimeType = "unknown";
}
return mimeType;
})
});
});
return <AppContainer appEntryKey={appEntryKey}>
{state2 ? <ShareScreen appEntryKey={appEntryKey} sharedContent={props} onClose={isMetaQuest() ? Module8197.close : BackHandler.exitApp} /> : <SceneLoadingIndicator />}
<ActionSheetContainer appEntryKey={appEntryKey} />
<ToastContainer />
<AlertModalContainer />
</AppContainer>;
};
@@ -0,0 +1,102 @@
// Metro module 9929 (f9930).
import { View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import GuildStore from "../../../stores/GuildStore";
import PresenceStore from "../../../stores/PresenceStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import UserStore from "../../../stores/UserStore";
import { StatusTypes } from "../../../_bundle/Module505";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useChannelName from "../../channel/useChannelName";
import GroupDMAvatar from "../../group_dm/native/GroupDMAvatar";
import { AvatarSizes, Avatar } from "../../../design/void/native";
import { Text } from "../../../design/components/Text/native/Text";
import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589";
import UserUtils from "../../../utils/UserUtils";
import { GuildIconWithChannelType, GuildIconWithChannelTypeSizes } from "../../guild/native/GuildIconWithChannelType";
import { AlertModal, AlertActionButton } from "../../../design/components/AlertModal/native/AlertModal.native";
import { AlertActions } from "../../../design/components/AlertModal/native/AlertModal.native";
import { intl, t } from "../../../intl/index.native";
let useStyles, FailedUserRow, FailedChannelRow, FailedDestinationRow;
const FailedGroupDMRow = function FailedGroupDMRow(props) {
const channel2 = props.channel;
const styles = useStyles();
return <View style={styles.row}>
<GroupDMAvatar size={AvatarSizes.REFRESH_MEDIUM_32} channel={channel2} />
<Text style={styles.label} variant="text-md/medium" lineClamp={1} ellipsizeMode="tail">
{useChannelName(channel2)}
</Text>
</View>;
};
FailedUserRow = function FailedUserRow(props) {
const user = props.user;
const styles = useStyles();
let r11 = useStateFromStores([RelationshipStore], () => RelationshipStore.getNickname(user.id));
const stateFromStoresObject = useStateFromStoresObject([PresenceStore], () => ({
isMobileOnline: PresenceStore.isMobileOnline(user.id),
status: PresenceStore.getStatus(user.id),
isVROnline: PresenceStore.isVROnline(user.id)
}));
const { isMobileOnline, isVROnline, status } = stateFromStoresObject;
const r2 = user != null;
let r32 = null;
if (r2) {
const r47 = [<Avatar user={user} guildId={void 0} status={StatusTypes.OFFLINE !== status ? status : null} isMobileOnline={isMobileOnline} isVROnline={isVROnline} size={AvatarSizes.XSMALL} avatarDecoration={user.avatarDecoration} autoStatusCutout />, ,];
if (r11 == null) {
r11 = UserUtils.getName(user);
}
r47[1] = <Text style={styles.label} variant="text-md/medium" lineClamp={1} ellipsizeMode="tail">{r11}</Text>;
r32 = <View style={styles.row}>{r47}</View>;
}
return r32;
};
FailedChannelRow = function FailedChannelRow(props) {
const channel = props.channel;
const styles = useStyles();
return <View style={styles.row}>
<GuildIconWithChannelType aria-label="" guild={useStateFromStores([GuildStore], () => GuildStore.getGuild(channel?.guild_id))} channel={channel} size={GuildIconWithChannelTypeSizes.SMALL_32} />
<Text style={styles.label} variant="text-md/medium" lineClamp={1} ellipsizeMode="tail">
{useChannelName(channel)}
</Text>
</View>;
};
FailedDestinationRow = function FailedDestinationRow(props) {
const destination = props.destination;
const stateFromStoresObject = useStateFromStoresObject([ChannelStore, UserStore], () => ({
channel: destination.type === "channel" ? ChannelStore.getChannel(destination.id) : null,
user: destination.type === "user" ? UserStore.getUser(destination.id) : null
}));
const { channel: channel2, user: user2 } = stateFromStoresObject;
return (channel2 == null ? void 0 : channel2.isGroupDM()) ? <FailedGroupDMRow channel={channel2} /> : user2 != null ? <FailedUserRow user={user2} /> : channel2 != null ? <FailedChannelRow channel={channel2} /> : null;
};
useStyles = createStyles({
container: {
borderWidth: 1,
borderColor: Module712.colors.BORDER_STRONG,
borderRadius: Module712.radii.lg,
paddingVertical: Module712.space.PX_8
},
row: {
display: "flex",
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_12,
height: 40,
marginHorizontal: Module712.space.PX_16
},
label: {
flexShrink: 1
}
});
export default function DestinationFailedAlertModal(props) {
const { title, content, failedDestinations, onRetry } = props;
return <AlertModal title={title} content={content} extraContent={<View style={useStyles().container}>
{failedDestinations.map((failedDestination, index) => <FailedDestinationRow key={index} destination={failedDestination} />)}
</View>} actions={<AlertActions>
{onRetry != null ? <>
<AlertActionButton key="confirm" variant="primary" onPress={onRetry} text={intl.string(t["5911Lb"])} />
<AlertActionButton key="cancel" variant="secondary" text={intl.string(t.WAI6xu)} />
</> : <AlertActionButton key="confirm" variant="primary" text={intl.string(t.BddRzS)} />}
</AlertActions>} />;
};
@@ -0,0 +1,277 @@
// Metro module 9905 (f9906).
import { useRef, useState, useEffect, useCallback, useMemo } from "react";
import { Keyboard, View } from "react-native";
import { NOOP } from "../../../Constants";
import { UserRowModes } from "../../main_tabs_v2/native/shared_components/user_list/UserRowConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useShareSearchResults } from "../useShareSearchResults";
import { runAfterInteractions } from "../../../utils/native/RunAfterInteractionsUtils";
import { destinationKey } from "../formatResults";
import { AutocompleterResultTypes } from "../../autocompleter/index";
import { getRelationshipType } from "../../main_tabs_v2/UserSearchUtils";
import { assertNever } from "../../../utils/GlobalUtils";
import useScaledRowHeight from "../../main_tabs_v2/native/shared_components/user_list/useScaledRowHeight";
import { useScaledTextLineHeight } from "../../screen/native/useScaledTextLineHeight.android";
import roundToNearestPixel from "../../voice_panel/native/utils/roundToNearestPixel";
import { UsersFastList } from "../../main_tabs_v2/native/shared_components/user_list/UsersFastList";
import NoResults from "../../main_tabs_v2/native/shared_components/user_list/NoResults";
import { intl, t } from "../../../intl/index.native";
import ThemedGradient from "../../client_themes/native/ThemedGradient";
import { SearchField } from "../../../design/components/TextField/native/SearchField.native";
const useStyles = createStyles({
searchBarContainer: {
paddingHorizontal: Module712.space.PX_16,
paddingBottom: Module712.space.PX_8,
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND
},
noResults: {
flex: 1,
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND
}
});
export default function SearchableDestinationList(props) {
let r163, r164;
let callback, memo, memo2, callback2, callback3, callback4, callback5, ref4, c17548_23, scaledTextLineHeight;
let initialSelectedDestinations = props.initialSelectedDestinations;
const { disabledDestinations, originDestination, channelFilter, getRowIsUnavailable, onSelectedDestinationChange, onSearchTextChange, rowMode = UserRowModes.NONE } = props;
const NONE = rowMode;
const { insetStart = Module712.space.PX_8, insetEnd = Module712.space.PX_12 } = props;
let autoFocusSearch = props.autoFocusSearch;
if (autoFocusSearch === void 0) {
autoFocusSearch = false;
}
const { hideSearchOnDefaultNoResults = false, defaultNoResultsFound, disableGradient, disableStickySections, disableSelection, disableLongPress } = props;
callback = void 0;
memo = void 0;
memo2 = void 0;
callback2 = void 0;
callback3 = void 0;
callback4 = void 0;
callback5 = void 0;
ref4 = void 0;
c17548_23 = void 0;
scaledTextLineHeight = void 0;
const styles = useStyles();
const ref = useRef(null);
if (initialSelectedDestinations == null) {
initialSelectedDestinations = [];
}
const [state, setState] = useState(initialSelectedDestinations);
const shareSearchResults = useShareSearchResults({
selectedDestinations: state,
originDestination,
channelFilter,
includeMissingDMs: true
});
const { results, updateSearchText } = shareSearchResults;
const ref2 = useRef("");
const [state2, setState2] = useState(false);
const ref3 = useRef(null);
useEffect(() => () => {
const current = ref3.current;
if (current != null) {
current.cancel();
}
}, []);
callback = useCallback(function(a0, r4 = false) {
if (a0 !== ref2.current) {
ref2.current = a0;
if (r4) {
const current = ref.current;
if (current != null) {
current.setText(a0);
}
}
updateSearchText(a0);
if (onSearchTextChange != null) {
onSearchTextChange(a0);
}
setState2(a0.trim().length > 0);
ref3.current = runAfterInteractions(() => {
const current = ref4.current;
if (current != null) {
current.scrollToTop(false);
}
});
}
}, [onSearchTextChange, updateSearchText]);
useEffect(() => {
onSelectedDestinationChange(state);
setTimeout(() => {
Keyboard.dismiss();
}, 0);
setTimeout(() => {
callback("", true);
}, 50);
}, [state, onSelectedDestinationChange, callback]);
const memo3 = useMemo(() => [results.length], [results.length]);
const callback6 = useCallback(() => ({
type: "section",
props: {
hideTitle: true
}
}), []);
memo = useMemo(() => {
let r8 = disabledDestinations == null ? void 0 : disabledDestinations.map(destinationKey);
if (r8 == null) {
r8 = [];
}
return r8;
}, [disabledDestinations]);
memo2 = useMemo(() => {
let r8 = state == null ? void 0 : state.map(destinationKey);
if (r8 == null) {
r8 = [];
}
return r8;
}, [state]);
callback2 = useCallback((c26560_0) => {
setState((prevState) => {
let r9;
const r5 = prevState.findIndex((item) => item.id === c26560_0.id);
if (r5 === -1) {
if (disableSelection) {
return prevState;
}
r9 = [c26560_0, ...prevState];
} else {
r9 = [...prevState];
r9.splice(r5, 1);
}
return r9;
});
}, [disableSelection]);
callback3 = useCallback((a0) => callback2({
type: "user",
id: a0.id
}), [callback2]);
callback4 = useCallback((a0) => callback2({
type: "channel",
id: a0.id
}), [callback2]);
callback5 = useCallback((a0, a1) => {
const r7 = results[a1];
const { type, record } = r7;
const r0 = results.length - 1;
if (type !== AutocompleterResultTypes.HEADER) {
const r16 = type === AutocompleterResultTypes.USER ? destinationKey({
type: "user",
id: record.id
}) : destinationKey({
type: "channel",
id: record.id
});
const r37 = getRowIsUnavailable == null ? void 0 : getRowIsUnavailable(record);
const selected = memo2.includes(r16);
const r43 = memo.includes(r16);
let disabled = disableSelection;
if (disableSelection) {
disabled = !selected;
}
if (!disabled) {
disabled = r43;
}
if (!disabled) {
disabled = r37 != null;
}
const mode = r37 != null ? UserRowModes.NONE : NONE;
const subLabel = r37 != null ? r37.label : void 0;
const r50 = r37 != null;
let subLabelLineClamp = void 0;
if (r50) {
let lineClamp = r37.lineClamp;
if (lineClamp == null) {
lineClamp = 1;
}
subLabelLineClamp = lineClamp;
}
const r45 = {
disabled,
selected,
mode,
subLabel,
subLabelLineClamp,
start: a1 === 0,
end: a1 === r0
};
if (AutocompleterResultTypes.USER === type) {
return {
type: "user",
props: {
...r45,
user: record,
type: getRelationshipType(record.id),
onPress: callback3,
...disableLongPress ? {
onLongPress: NOOP
} : void 0
}
};
}
if (AutocompleterResultTypes.GROUP_DM === type) {
return {
type: "gdm",
props: {
...r45,
channel: record,
onPress: callback4,
...disableLongPress ? {
onLongPress: NOOP
} : void 0
}
};
}
if (AutocompleterResultTypes.TEXT_CHANNEL !== type && AutocompleterResultTypes.VOICE_CHANNEL !== type) {
return assertNever(type);
}
return {
type: "channel",
props: {
...r45,
channel: record,
onPress: callback4,
...disableLongPress ? {
onLongPress: NOOP
} : void 0
}
};
}
}, [results, getRowIsUnavailable, memo2, memo, disableSelection, disableLongPress, NONE, callback3, callback4]);
ref4 = useRef(null);
const scaledRowHeight = useScaledRowHeight();
c17548_23 = scaledRowHeight;
scaledTextLineHeight = useScaledTextLineHeight("text-xs/medium");
const callback7 = useCallback((a0, a1) => {
const r9 = callback5(a0, a1);
const r8 = r9?.type !== "user" && r9?.type !== "gdm" ? r9?.type === "channel" ? r9.props.subLabelLineClamp : void 0 : r9.props.subLabelLineClamp;
return r8 != null && r8 > 1 ? roundToNearestPixel(c17548_23 + (r8 - 1) * scaledTextLineHeight) : c17548_23;
}, [callback5, scaledRowHeight, scaledTextLineHeight]);
const r128 = memo3.some((item) => item > 0);
const r148 = r128 ? <UsersFastList ref={ref4} sections={memo3} getItemProps={callback5} getSectionProps={callback6} getItemSize={getRowIsUnavailable != null ? callback7 : void 0} insetStart={insetStart} insetEnd={insetEnd} disableStickySections={disableStickySections} /> : <View {...!state2 && defaultNoResultsFound != null ? {
style: [styles.noResults],
children: defaultNoResultsFound
} : {
style: styles.noResults,
children: <NoResults title={intl.string(t.V6nAfF)} />
}} />;
const r159 = disableGradient ? !disableGradient : <ThemedGradient absolute />;
L29: {
r163 = [r159, , ,];
if (hideSearchOnDefaultNoResults && !r128) {
r164 = null;
if (!state2) {
break L29;
}
}
if (autoFocusSearch) {
autoFocusSearch = r128;
}
r164 = <View style={styles.searchBarContainer}>
<SearchField ref={ref} size="md" onChange={callback} autoFocus={autoFocusSearch} accessibilityLabel={intl.string(t.CaEER6)} />
</View>;
}
r163[1] = r164;
r163[2] = r148;
return <>{r163}</>;
};
@@ -0,0 +1,28 @@
// Metro module 9904 (f9905).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Header } from "../../../_bundle/Module5150";
import { GenericHeaderTitle } from "../../main_tabs_v2/native/shared_components/HeaderShared";
import { getHeaderCloseButton } from "../../../design/components/Navigator/native/NavigatorHeader.native";
import { isIOS } from "../../../utils/PlatformUtils";
import { getIsWindowLarge } from "../../screen/native/useIsWindowLarge";
const useStyles = createStyles({
container: {
paddingHorizontal: Module712.space.PX_16,
paddingVertical: Module712.space.PX_8,
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND
},
header: {
borderBottomWidth: 0,
shadowColor: "transparent",
backgroundColor: "transparent"
}
});
export default function SearchableDestinationListHeader(props) {
const { title, subtitle, subtitleColor, headerRight, onClose } = props;
const styles = useStyles();
return <View style={styles.container}>
<Header headerStyle={styles.header} title={title} headerTitle={(a0) => <GenericHeaderTitle title={a0.children} subtitle={subtitle} subtitleColor={subtitleColor} variant="redesign/heading-18/bold" />} headerTitleAlign="center" headerLeft={getHeaderCloseButton(onClose)} headerRight={headerRight} headerStatusBarHeight={isIOS() ? getIsWindowLarge() ? void 0 : 0 : void 0} />
</View>;
};
+136
View File
@@ -0,0 +1,136 @@
// Metro module 13041 (f13042).
import { useCallback, useMemo } from "react";
import { View } from "react-native";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedScrollHandler } from "../../reanimated/ReanimatedRexport";
import Module4611 from "../../../_bundle/Module4611";
import { STANDARD_EASING } from "../../../design/void/native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import * as _timing from "../../../design/animation/reanimated/timing/timing";
import { hexWithOpacity } from "../../../utils/ColorUtils";
import { intl, t } from "../../../intl/index.native";
import AttachmentPreview from "../../media/native/AttachmentPreview";
import * as _UploadUtils from "../../../utils/native/UploadUtils";
const AnimatedComponent = ReanimatedRexport.createAnimatedComponent(Module4611);
const GRADIENT_EASING_CONFIG = {
duration: 300,
easing: STANDARD_EASING
};
const useStyles = createStyles({
containerRevamp: {
marginHorizontal: -Module712.space.PX_16
},
attachmentPreviewContentContainer: {
flexDirection: "row",
gap: Module712.space.PX_8
},
attachmentPreviewContentContainerRevamp: {
paddingHorizontal: Module712.space.PX_16
},
attachmentPreview: {
height: 60,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
overflow: "hidden",
borderRadius: Module712.radii.sm
},
leftGradient: {
width: 50,
position: "absolute",
left: 0,
top: 0,
bottom: 0,
zIndex: 100
},
rightGradient: {
width: 50,
position: "absolute",
right: 0,
top: 0,
bottom: 0,
zIndex: 100
},
gradient: {
color: Module712.colors.BACKGROUND_SURFACE_HIGH
}
});
const __initData = {
code: "function ShareAttachmentsTsx1(){const{withTiming,contentOffset,GRADIENT_EASING_CONFIG}=this.__closure;return{opacity:withTiming(contentOffset.get()<=0?0:1,GRADIENT_EASING_CONFIG)};}"
};
const __initData2 = {
code: "function ShareAttachmentsTsx2(){const{withTiming,contentOffset,layoutWidth,contentWidth,GRADIENT_EASING_CONFIG}=this.__closure;return{opacity:withTiming(contentOffset.get()+layoutWidth.get()>=contentWidth.get()?0:1,GRADIENT_EASING_CONFIG)};}"
};
const __initData3 = {
code: "function ShareAttachmentsTsx3(event){const{contentOffset,contentWidth,layoutWidth}=this.__closure;contentOffset.set(event.contentOffset.x);contentWidth.set(event.contentSize.width);layoutWidth.set(event.layoutMeasurement.width);}"
};
export default function ShareAttachments(props) {
const { attachments, isRevamp = false } = props;
const styles = useStyles();
const sharedValue = useSharedValue(0);
const sharedValue2 = useSharedValue(0);
const sharedValue3 = useSharedValue(0);
const y = () => ({
opacity: _timing.withTiming(sharedValue.get() <= 0 ? 0 : 1, GRADIENT_EASING_CONFIG)
});
y.__closure = {
withTiming: _timing.withTiming,
contentOffset: sharedValue,
GRADIENT_EASING_CONFIG
};
y.__workletHash = 3302668154466;
y.__initData = __initData;
const animatedStyle = useAnimatedStyle(y);
const S = () => ({
opacity: _timing.withTiming(sharedValue.get() + sharedValue3.get() >= sharedValue2.get() ? 0 : 1, GRADIENT_EASING_CONFIG)
});
S.__closure = {
withTiming: _timing.withTiming,
contentOffset: sharedValue,
layoutWidth: sharedValue3,
contentWidth: sharedValue2,
GRADIENT_EASING_CONFIG
};
S.__workletHash = 13996707009656;
S.__initData = __initData2;
const animatedStyle2 = useAnimatedStyle(S);
const v = function v(a0) {
sharedValue.set(a0.contentOffset.x);
sharedValue2.set(a0.contentSize.width);
sharedValue3.set(a0.layoutMeasurement.width);
};
v.__closure = {
contentOffset: sharedValue,
contentWidth: sharedValue2,
layoutWidth: sharedValue3
};
v.__workletHash = 12660577105859;
v.__initData = __initData3;
const animatedScrollHandler = useAnimatedScrollHandler(v);
const callback = useCallback((a0) => {
sharedValue3.set(a0.nativeEvent.layout.width);
}, [sharedValue3]);
const callback2 = useCallback((a0) => {
sharedValue2.set(a0);
}, [sharedValue2]);
const memo = useMemo(() => hexWithOpacity(styles.gradient.color, 0), [styles.gradient.color]);
return attachments.length !== 0 ? <View style={isRevamp ? styles.containerRevamp : void 0}>
<AnimatedComponent start={{
x: 0,
y: 0
}} end={{
x: 1,
y: 0
}} colors={[styles.gradient.color, memo]} style={[styles.leftGradient, animatedStyle]} pointerEvents="box-none" />
<AnimatedComponent start={{
x: 0,
y: 0
}} end={{
x: 1,
y: 0
}} colors={[memo, styles.gradient.color]} style={[styles.rightGradient, animatedStyle2]} pointerEvents="box-none" />
<ReanimatedRexport.ScrollView contentContainerStyle={[styles.attachmentPreviewContentContainer, isRevamp ? styles.attachmentPreviewContentContainerRevamp : void 0]} horizontal onScroll={animatedScrollHandler} onLayout={callback} onContentSizeChange={callback2} scrollEventThrottle={16} showsHorizontalScrollIndicator={false} accessibilityRole="list" accessibilityLabel={intl.string(t.RhtzFe)}>
{attachments.map((attachment, index) => <View key={index} style={styles.attachmentPreview}>
<AttachmentPreview uri={attachment.uri} width={60} height={60} isImage={_UploadUtils.isImage(attachment.uri, attachment.mimeType)} isVideo={_UploadUtils.isVideo(attachment.uri, attachment.mimeType)} fileName={attachment.name} showPlayOnVideoPreview />
</View>)}
</ReanimatedRexport.ScrollView>
</View> : null;
};
+73
View File
@@ -0,0 +1,73 @@
// Metro module 9925 (f9926).
import { useState, useCallback } from "react";
import { View } from "react-native";
import { Fonts } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isAndroid } from "../../../utils/PlatformUtils";
import useMessageMaxLength from "../../messages/useMessageMaxLength";
import FormInput from "../../../design/void/Form/native/FormInput";
import { intl, t } from "../../../intl/index.native";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { ReactionIcon } from "../../../design/components/Icon/native/redesign/generated/ReactionIcon";
const useStyles = createStyles({
container: {
flex: 1,
flexDirection: "row",
backgroundColor: Module712.colors.SHARE_CHAT_INPUT_BACKGROUND,
borderRadius: Module712.modules.mobile.CHAT_INPUT_BORDER_RADIUS,
borderWidth: Module712.modules.mobile.CHAT_INPUT_PILL_BORDER_WIDTH,
borderColor: Module712.colors.MOBILE_CHATINPUT_BORDER_DEFAULT,
paddingHorizontal: Module712.space.PX_12
},
chatInput: {
flex: 1,
paddingVertical: 0,
paddingHorizontal: Module712.space.PX_4,
maxHeight: 80
},
chatText: {
fontSize: 16,
lineHeight: 20,
fontFamily: Fonts.PRIMARY_NORMAL,
color: Module712.colors.TEXT_STRONG,
paddingTop: Module712.space.PX_8 + (isAndroid() ? 0 : 2),
paddingBottom: Module712.space.PX_8
},
inputPlaceholder: {
color: Module712.colors.TEXT_MUTED
},
emojiButton: {
paddingTop: Module712.space.PX_8,
paddingBottom: Module712.space.PX_8,
alignSelf: "flex-end"
},
focused: {
borderColor: Module712.colors.MOBILE_CHATINPUT_BORDER_ACTIVE
}
});
export default function ShareChatInput(props) {
const { text, inputRef, onChange, onSelectionChange, onFocus, onBlur, onPressEmoji, onSend, disabled = false } = props;
const styles = useStyles();
const messageMaxLength = useMessageMaxLength();
let [state, setState] = useState(false);
const callback = useCallback(() => {
setState(true);
onFocus();
}, [onFocus]);
const callback2 = useCallback(() => {
setState(false);
onBlur();
}, [onBlur]);
const style = [styles.container, ,];
if (state) {
state = styles.focused;
}
style[1] = state;
return <View style={style}>
<FormInput ref={inputRef} maxLength={messageMaxLength} placeholder={intl.string(t.ZroO3G)} placeholderTextColor={styles.inputPlaceholder.color} accessibilityLabel={intl.string(t["/+MXmw"])} onSubmitEditing={onSend} onSelectionChange={onSelectionChange} style={styles.chatInput} value={text} onChange={onChange} onFocus={callback} onBlur={callback2} multiline showBorder={false} showTopContainer={false} textAlignVertical="center" inputTextStyle={styles.chatText} editable={!disabled} />
<PressableOpacity accessibilityLabel={intl.string(t.iZ7Mz9)} accessibilityRole="button" onPress={onPressEmoji} style={styles.emojiButton} disabled={disabled}>
<ReactionIcon size="md" />
</PressableOpacity>
</View>;
};
+125
View File
@@ -0,0 +1,125 @@
// Metro module 13042 (f13043).
import { useMemo } from "react";
import { Image as Image2, View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { ActivityIndicator } from "../../../design/components/ActivityIndicator/native/ActivityIndicator.native";
import { Text } from "../../../design/components/Text/native/Text";
const useStyles = createStyles({
container: {
flexDirection: "row",
height: 80,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
borderColor: Module712.colors.BORDER_STRONG,
borderWidth: 1,
borderRadius: Module712.radii.sm,
overflow: "hidden"
},
containerRevamp: {
borderWidth: 0
},
thumbnail: {
width: 80
},
contentContainer: {
flex: 1,
flexDirection: "column",
justifyContent: "center",
paddingLeft: 12,
paddingRight: 24
},
authorView: {
flexDirection: "row",
alignItems: "center",
marginBottom: 3
},
authorThumbnail: {
height: 16,
width: 16,
borderRadius: Module712.radii.sm,
marginRight: 4
},
loadingSpinner: {
flex: 1
}
});
export default function ShareEmbed(props) {
let r36;
let embed, isLoadingEmbed, styles, memo;
L9: {
embed = props.embed;
isLoadingEmbed = props.isLoadingEmbed;
const isRevamp = props.isRevamp;
styles = void 0;
memo = void 0;
styles = useStyles();
const memo5 = useMemo(() => {
if (embed != null) {
let uri = embed.thumbnail?.url;
if (uri == null) {
uri = embed.image?.url;
}
if (uri != null) {
return {
uri
};
}
}
}, [embed]);
let r24 = useMemo(() => isLoadingEmbed ? <ActivityIndicator style={styles.loadingSpinner} /> : null, [isLoadingEmbed, styles]);
const memo4 = useMemo(() => {
const author = embed?.author;
if (author == null) {
return null;
}
let proxy_icon_url = author.proxy_icon_url;
if (proxy_icon_url == null) {
proxy_icon_url = author.icon_url;
}
return <View style={styles.authorView}>
{proxy_icon_url != null && <Image2 style={styles.authorThumbnail} source={{
uri: proxy_icon_url
}} resizeMode="cover" />}
<Text variant="text-xs/semibold" color="mobile-text-heading-primary" ellipsizeMode="tail" lineClamp={1}>{author.name}</Text>
</View>;
}, [embed, styles]);
memo = useMemo(() => {
const title = embed?.title;
return title != null ? <Text style={{
marginVertical: 1
}} variant="text-xs/semibold" color="mobile-text-heading-primary" lineClamp={1} ellipsizeMode="tail">{title}</Text> : null;
}, [embed]);
const memo3 = useMemo(() => {
const description = embed?.description;
return memo == null ? description != null ? <Text style={{
marginVertical: 1
}} variant="text-xs/medium" color="text-default" lineClamp={1} ellipsizeMode="tail">{description}</Text> : null : null;
}, [embed, memo]);
const memo2 = useMemo(() => {
const url = embed?.url;
return url != null ? <Text style={{
marginVertical: 1
}} variant="text-xs/medium" color="text-link" lineClamp={1} ellipsizeMode="tail">{url}</Text> : null;
}, [embed]);
if (embed == null) {
r36 = null;
if (!isLoadingEmbed) {
break L9;
}
}
const style = [styles.container, isRevamp ? styles.containerRevamp : void 0];
if (!isLoadingEmbed) {
r24 = <>
{memo5 != null && <Image2 style={styles.thumbnail} source={memo5} resizeMode="cover" />}
<View style={styles.contentContainer}>
{memo4}
{memo}
{memo3}
{memo2}
</View>
</>;
}
r36 = <View style={style}>{r24}</View>;
}
return r36;
};
@@ -0,0 +1,73 @@
// Metro module 9917 (f9918).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import ReanimatedRexport, { useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
import * as _spring from "../../../design/animation/reanimated/spring/spring";
import * as _springPresets from "../../../design/animation/reanimated/spring/springPresets";
import { Text } from "../../../design/components/Text/native/Text";
const useStyles = createStyles({
footer: {
display: "flex",
flexDirection: "column",
flexShrink: 0,
paddingHorizontal: Module712.space.PX_16,
paddingVertical: Module712.space.PX_12,
gap: Module712.space.PX_12,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGHEST,
borderTopWidth: 1,
borderTopColor: Module712.colors.BORDER_SUBTLE
},
footerSeparator: {
marginHorizontal: -Module712.space.PX_16,
borderBottomWidth: 1,
borderBottomColor: Module712.colors.BORDER_SUBTLE
},
warningWrapper: {
display: "flex",
flexDirection: "column",
gap: 8
},
chatRow: {
display: "flex",
flexDirection: "row",
gap: Module712.space.PX_12,
alignItems: "flex-end"
}
});
const __initData = {
code: "function ShareFooterLayoutTsx1(){const{withSpring,footerPaddingBottom,ON_PRESS_SPRING}=this.__closure;return{paddingBottom:withSpring(footerPaddingBottom,ON_PRESS_SPRING,'respect-motion-settings')};}"
};
export default function ShareFooterLayout(props) {
const { preview, chatInput, sendButton, warningText, avoidKeyboard } = props;
const styles = useStyles();
const footerPaddingBottom = styles.footer.paddingVertical + useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: avoidKeyboard,
includeCustomKeyboardHeight: false
}).insets.bottom;
let c17553_0 = footerPaddingBottom;
const f = () => ({
paddingBottom: _spring.withSpring(c17553_0, _springPresets.ON_PRESS_SPRING, "respect-motion-settings")
});
f.__closure = {
withSpring: _spring.withSpring,
footerPaddingBottom,
ON_PRESS_SPRING: _springPresets.ON_PRESS_SPRING
};
f.__workletHash = 2871405301293;
f.__initData = __initData;
return <ReanimatedRexport.View style={[styles.footer, useAnimatedStyle(f)]}>
{preview != null ? <>
{preview}
<View style={styles.footerSeparator} />
</> : null}
<View style={styles.warningWrapper}>
<View style={styles.chatRow}>
{chatInput}
{sendButton}
</View>
{warningText != null && <Text variant="text-sm/normal" color="text-feedback-warning">{warningText}</Text>}
</View>
</ReanimatedRexport.View>;
};
+336
View File
@@ -0,0 +1,336 @@
// Metro module 13038 (f13039).
import _asyncToGenerator from "../../../_bundle/_asyncToGenerator";
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useState, useMemo, useCallback, useRef, lazy } from "react";
import { View } from "react-native";
import { ChannelRecordBase, isGuildChannelType } from "../../../records/ChannelRecord";
import "../../../stores/ChannelStore";
import PermissionStore from "../../../stores/PermissionStore";
import { Permissions, MAX_UPLOAD_COUNT } from "../../../Constants";
import { MAX_DESTINATION_COUNT } from "../../forwarding/ForwardConstants";
import { UserRowModes } from "../../main_tabs_v2/native/shared_components/user_list/UserRowConstants";
import { jsx } from "react/jsx-runtime";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isIOS, isAndroid } from "../../../utils/PlatformUtils";
import { intl, t } from "../../../intl/index.native";
import { getOrResolveChannelIdFromDestinationId } from "../formatResults";
import { isNotNullish } from "../../../utils/GlobalUtils";
import { showInformationToast } from "./ShareUtils";
import allSettled from "../../../_bundle/allSettled";
import MessageManager from "../../messages/MessageManager";
import { transitionToChannel } from "../../routing/transitionToChannel";
import Module8197 from "../../../_bundle/Module8197";
import { openAlert } from "../../../design/components/AlertModal/native/useAlertStore.native";
import ShareAttachments from "./ShareAttachments";
import ShareEmbed from "./ShareEmbed";
import { GenericHeaderTitle } from "../../main_tabs_v2/native/shared_components/HeaderShared";
function $mk116471($env) {
return function() {
let env31677 = {
$parent: $env
};
env31677[0] = (0, _asyncToGenerator)(function*(c32038_0) {
let c32038_2;
L12: {
let env32140;
c32038_2 = env31677;
const r9 = env32140 = {};
env32140[0] = void 0;
const r25 = env31677.$parent.$parent.$parent;
const channel = r25[9].getChannel(c32038_0);
env32140[0] = channel;
if (channel == null) {
break L12;
}
yield (0, r25[0])(r25[2][18]).sendShareMessage({
attachments: env31677.$parent[1],
channel,
comment: env31677.$parent.$parent[8]
});
const r54 = c32038_2;
const r55 = r54.$parent.$parent.$parent;
const r60 = (0, r55[1])(r55[2][20]);
const SHARE_MESSAGE_SENT = r55[11].SHARE_MESSAGE_SENT;
const r71 = r54.$parent;
r60.track(SHARE_MESSAGE_SENT, {
guild_id: env32140[0].guild_id,
channel_id: env32140[0].id,
channel_type: env32140[0].type,
num_attachments: r71[1].length,
attachment_mimetypes: r71[2]
});
return void 0;
}
return false;
});
return function() {
return env31677[0].apply(this, arguments);
};
};
}
function $mk116473($env) {
return (a0, a1) => $env[3][a1].status === "rejected";
}
function $mk116474($env) {
return () => import("./DestinationFailedAlertModal");
}
let useStyles;
let env8997 = {};
const getAttachmentsRestriction = function getAttachmentsRestriction(a0) {
if (a0 instanceof ChannelRecordBase && (0, isGuildChannelType)(a0.type)) {
return PermissionStore.can(Permissions.ATTACH_FILES, a0) ? void 0 : {
label: intl.string(t.P7yvbm)
};
}
};
useStyles = createStyles({
container: {
flex: 1,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWER
},
headerContainer: {
paddingHorizontal: isIOS() ? Module712.space.PX_16 : 0,
paddingVertical: isIOS() ? Module712.space.PX_8 : 0
}
});
export default function ShareScreen(props) {
let r24, r53, sendLabel;
let env20351 = {
$parent: env8997
};
const { appEntryKey, sharedContent } = props;
env20351[0] = sharedContent;
const onClose = props.onClose;
env20351[1] = onClose;
env20351[2] = void 0;
env20351[3] = void 0;
env20351[4] = void 0;
env20351[5] = void 0;
env20351[6] = void 0;
env20351[7] = void 0;
env20351[8] = void 0;
env20351[9] = void 0;
env20351[10] = void 0;
const styles = useStyles();
const r39 = _slicedToArray(useState(useMemo(() => {
const r4 = env20351[0];
const r6 = [];
if (r4.targetUserId != null) {
r6.push({
type: "user",
id: r4.targetUserId
});
}
if (r4.targetChannelId != null) {
r6.push({
type: "channel",
id: r4.targetChannelId
});
}
return r6;
}, [sharedContent])), 2);
const initialSelectedDestinations = r39[0];
env20351[2] = initialSelectedDestinations;
env20351[3] = r39[1];
const length = initialSelectedDestinations.length;
env20351[4] = length;
const disabled = sharedContent.attachments.length > MAX_UPLOAD_COUNT;
env20351[5] = disabled;
const callback = useCallback((a0) => {
(0, env20351[3])(a0);
}, []);
const r48 = _slicedToArray(useState(false), 2);
const isSending = r48[0];
env20351[6] = r48[1];
env20351[7] = useRef(isSending);
if (length <= 1) {
sendLabel = intl.string(t.TXNS7S);
r53 = dependencyMap;
r24 = require;
} else {
r53 = dependencyMap;
sendLabel = require(r53[14]).intl.formatToPlainString(require(r53[14]).t.jWtYUm, {
count: length
});
r24 = require;
}
let text = sharedContent.text;
if (text == null) {
text = "";
}
const r74 = _slicedToArray(useState(text), 2);
const text2 = r74[0];
env20351[8] = text2;
const setText = r74[1];
const r78 = importDefault(r53[15])(text2);
const embed = r78.embed;
env20351[9] = embed;
const isLoading = r78.isLoading;
env20351[10] = isLoading;
const callback2 = useCallback(async () => {
let c27402_0, c27402_1, c27402_2;
let c27402_3 = 0;
const r12 = env20351;
L25: {
L24: {
L23: {
try {
let env30607;
c27402_1 = r12;
const r42 = env30607 = {
$parent: r12
};
c27402_0 = r42;
env30607[0] = void 0;
env30607[1] = void 0;
env30607[2] = void 0;
env30607[3] = void 0;
env30607[4] = void 0;
env30607[5] = void 0;
env30607[6] = void 0;
if (env20351[7].current) {
break L25;
}
env20351[7].current = true;
(0, env20351[6])(true);
c27402_3 = 1;
env30607[0] = (await Promise.all(env20351[2].map(getOrResolveChannelIdFromDestinationId))).filter(isNotNullish);
if (env30607[0].length === 0) {
showInformationToast(intl.string(t.wFcUiF));
c27402_3 = 0;
(0, env20351[6])(false);
env20351[7].current = false;
break L24;
}
const r114 = c27402_0;
env30607[1] = env20351[0].attachments;
env30607[2] = env30607[1].map(({ mimeType }) => {
if (mimeType == null) {
mimeType = "unknown";
}
return mimeType;
});
env30607[3] = await allSettled(env30607[0].map($mk116471(r114)()));
const r157 = env30607[3].every((item) => item.status === "fulfilled");
const r158 = c27402_0;
if (r157) {
env30607[4] = env30607[0][0];
await MessageManager.fetchMessages({
channelId: env30607[4]
});
transitionToChannel(env30607[4], {
navigationReplace: true,
openTextInVoiceIfVoiceChannel: true
});
if (isAndroid()) {
Module8197.launchApp();
}
(0, env20351[1])();
c27402_3 = 0;
(0, env20351[6])(false);
env20351[7].current = false;
break L23;
}
env30607[5] = env20351[2].filter($mk116473(r158));
env30607[6] = lazy($mk116474(env20351.$parent));
openAlert("share-failed-alert-modal", (0, jsx)(env30607[6], {
title: intl.string(t.dA1gbw),
content: intl.formatToPlainString(t.thm88D, {
count: env30607[5].length
}),
failedDestinations: env30607[5]
}));
c27402_3 = 0;
(0, env20351[6])(false);
env20351[7].current = false;
} catch ($e) {
const r40 = $e;
let r7 = r40;
c27402_2 = r40;
if (c27402_3 !== 0) {
while (true) {
try {
const r281 = c27402_2;
c27402_3 = 0;
(0, env20351[6])(false);
env20351[7].current = false;
throw r281;
} catch (r278) {
r7 = r278;
c27402_2 = r278;
if (c27402_3 === 0) {
break;
}
}
}
}
throw r7;
}
return void 0;
}
return void 0;
}
return void 0;
}
}, [onClose, initialSelectedDestinations, sharedContent.attachments, text2]);
const memo = useMemo(() => {
let r15;
L5: {
const r4 = env20351[9];
if (r4 == null) {
const length = env20351[0].attachments.length;
r15 = null;
if (length === 0) {
break L5;
}
}
r15 = <>
{[<ShareAttachments attachments={env20351[0].attachments} isRevamp />, <ShareEmbed embed={r4?.embed} isLoadingEmbed={env20351[10]} isRevamp />]}
</>;
}
return r15;
}, [embed, isLoading, sharedContent.attachments]);
return <View style={styles.container}>
<View style={styles.headerContainer}>
{jsx(r24(r53[29]).Header, {
title: r24(r53[14]).intl.string(r24(r53[14]).t["MR7/kg"]),
headerTitle: (a0) => (0, jsx)(GenericHeaderTitle, {
title: a0.children,
subtitle: env20351[5] ? intl.formatToPlainString(t["qqyp/e"], {
limit: MAX_UPLOAD_COUNT
}) : env20351[4] >= MAX_DESTINATION_COUNT ? intl.formatToPlainString(t["3Fbkir"], {
count: MAX_DESTINATION_COUNT
}) : void 0,
subtitleColor: "text-feedback-warning",
variant: "redesign/heading-18/bold"
}),
headerTitleAlign: "center",
headerLeft: r24(r53[31]).isMetaQuest() ? void 0 : r24(r53[32]).getHeaderCloseButton(onClose),
headerStatusBarHeight: r24(r53[13]).isIOS() ? 0 : void 0
})}
</View>
{jsx(importDefault(r53[33]), {
rowMode: UserRowModes.TOGGLE,
initialSelectedDestinations,
onSelectedDestinationChange: callback,
getRowIsUnavailable: sharedContent.attachments.length > 0 ? getAttachmentsRestriction : void 0,
insetEnd: 0,
disableGradient: true,
disableStickySections: true,
disableSelection: length >= MAX_DESTINATION_COUNT || disabled,
disableLongPress: r24(r53[13]).isAndroid()
})}
{jsx(importDefault(r53[34]), {
text: text2,
setText,
preview: memo,
sendLabel,
canSend: length > 0 && !disabled,
isSending,
onSend: callback2,
disabled,
appEntryKey
})}
</View>;
};
@@ -0,0 +1,2 @@
// Metro module 12989 (f12990).
export const SHARE_SCREEN_MODAL_KEY = "share_screen_modal";
@@ -0,0 +1,11 @@
// Metro module 13043 (f13044).
import { useShareChatInputActions } from "./useShareChatInputActions";
import ShareFooterLayout from "./ShareFooterLayout";
import { Button } from "../../../design/components/Button/native/Button.native";
import ShareChatInput from "./ShareChatInput";
export default function ShareScreenFooter(props) {
const { text, setText, preview, sendLabel, canSend, isSending, onSend, appEntryKey, disabled = false } = props;
const shareChatInputActions = useShareChatInputActions(setText, void 0, appEntryKey);
const { textInputRef, isInputFocused } = shareChatInputActions;
return <ShareFooterLayout preview={preview} sendButton={<Button variant="primary" size="md" text={sendLabel} disabled={canSend ? disabled : !canSend} onPress={isSending ? void 0 : onSend} loading={isSending} />} chatInput={<ShareChatInput inputRef={textInputRef} text={text} onChange={setText} onSelectionChange={shareChatInputActions.handleSelectionChange} onFocus={shareChatInputActions.handleMessageFocus} onBlur={shareChatInputActions.handleMessageBlur} onPressEmoji={shareChatInputActions.handlePressEmoji} onSend={onSend} disabled={disabled} />} avoidKeyboard={isInputFocused} />;
};
+158
View File
@@ -0,0 +1,158 @@
// Metro module 13037 (f13038).
import { useState, useEffect, useMemo } from "react";
import ChannelStore from "../../../stores/ChannelStore";
import { SHARE_SCREEN_MODAL_KEY } from "./ShareScreenConstants";
import Logger from "../../debug/Logger";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import Module8197 from "../../../_bundle/Module8197";
import { useStateFromStores } from "../../../_bundle/Module589";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
import { ChannelTypes } from "../../../_bundle/Module692";
import ShareScreen from "./ShareScreen";
let c8996_9;
const onClose = function onClose() {
ModalActionCreators.popWithKey(SHARE_SCREEN_MODAL_KEY);
};
c8996_9 = new Logger("ShareScreenModal");
export default function ShareScreenModal(props) {
let stateFromStores, setState2, state2;
const { text, channelId, shareId, attachmentManifest } = props;
stateFromStores = void 0;
setState2 = void 0;
state2 = void 0;
const [state, setState] = useState(null);
useEffect(() => {
let _fetchAttachments2 = function _fetchAttachments() {
const r9 = async () => {
let c31675_2;
let c31675_3 = 0;
let c32036_0, c32036_1;
L14: {
L13: {
try {
c32036_0 = void 0;
if (shareId === void 0) {
break L14;
}
if (attachmentManifest !== void 0) {
c31675_3 = 1;
c32036_0 = await Module8197.sharedAttachments(shareId, attachmentManifest);
(0, setState)(c32036_0);
c31675_3 = 0;
break L13;
}
break L14;
} catch ($e) {
const r25 = $e;
let r7 = r25;
c31675_2 = r25;
if (c31675_3 !== 0) {
while (true) {
try {
const r66 = c31675_2;
c31675_3 = 0;
c32036_1 = r66;
c8996_9.error("Error fetching attachments:", c32036_1);
break L13;
} catch (r62) {
r7 = r62;
c31675_2 = r62;
if (c31675_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
return void 0;
}
};
_fetchAttachments2 = r9;
return r9.apply(this, arguments);
};
(function fetchAttachments() {
return _fetchAttachments2.apply(this, arguments);
})();
}, [shareId, attachmentManifest]);
stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId));
let state3;
[state3, setState2] = useState(null);
useEffect(() => {
let _fetchChannel2 = function _fetchChannel() {
const r9 = async () => {
let c31676_2;
let c31676_3 = 0;
let c32037_0, c32037_1;
L14: {
L13: {
try {
c32037_0 = void 0;
if (channelId == null) {
break L14;
}
if (stateFromStores == null) {
c31676_3 = 1;
c32037_0 = await ChannelActionCreators.fetchChannel(channelId);
(0, setState2)(c32037_0);
c31676_3 = 0;
break L13;
}
break L14;
} catch ($e) {
const r25 = $e;
let r7 = r25;
c31676_2 = r25;
if (c31676_3 !== 0) {
while (true) {
try {
const r68 = c31676_2;
c31676_3 = 0;
c32037_1 = r68;
c8996_9.error("Error fetching channel:", c32037_1);
break L13;
} catch (r64) {
r7 = r64;
c31676_2 = r64;
if (c31676_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
return void 0;
}
};
_fetchChannel2 = r9;
return r9.apply(this, arguments);
};
(function fetchChannel() {
return _fetchChannel2.apply(this, arguments);
})();
}, [channelId, stateFromStores]);
state2 = stateFromStores == null ? state3 : stateFromStores;
return <ShareScreen sharedContent={useMemo(() => {
let attachments = state;
if (state == null) {
attachments = [];
}
const r3 = {
text,
attachments
};
if (state2 != null) {
if (state2.type !== ChannelTypes.DM) {
r3.targetChannelId = channelId;
} else if ((state2 ? "recipients" in state2 : state2) && Array.isArray(state2.recipients)) {
r3.targetUserId = state2.recipients[0];
} else if ((state2 ? "recipient" in state2 : state2) && "id" in state2.recipient) {
r3.targetUserId = state2.recipient?.id;
}
}
return r3;
}, [text, state, channelId, state2])} onClose={onClose} />;
};
+88
View File
@@ -0,0 +1,88 @@
// Metro module 13040 (f13041).
import { DraftType } from "../../../stores/DraftStore";
import { MessageSendLocation } from "../../messages/MessageConstants";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import Module9311 from "../../../_bundle/Module9311";
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
import DraftActionCreators from "../../../actions/DraftActionCreators";
import { UploadPlatform } from "../../../lib/uploader/Upload";
import { CloudUpload } from "../../../lib/uploader/CloudUpload";
import MessageParser from "../../messages/MessageParser";
import { Future } from "../../../_bundle/Module5700";
import MessageActionCreators from "../../../actions/MessageActionCreators";
function $mk116476($env) {
return (a0) => new CloudUpload({
uri: a0.uri,
originalUri: a0.uri,
mimeType: a0.mimeType,
filename: a0.name,
platform: UploadPlatform.REACT_NATIVE,
width: a0.width,
height: a0.height
}, $env[1].id);
}
function $mk116477($env) {
return () => {
const r1 = $env;
r1[6].reject(void 0);
const uploads = r1[4];
const channelId = r1[3];
const r4 = r1[2];
UploadAttachmentActionCreators.setUploads({
channelId,
uploads,
draftType: DraftType.ChannelMessage,
resetState: true
});
DraftActionCreators.saveDraft(channelId, r4, DraftType.ChannelMessage);
};
}
let env8999 = {};
export function showInformationToast(a0) {
ToastActionCreators.open({
key: `INFORMATION_TOAST-${a0}`,
content: a0,
icon: Module9311
});
}
export async function sendShareMessage(c27404_0) {
let env30608;
const r30 = env8999;
let c27404_3 = r30;
const r31 = env30608 = {
$parent: r30
};
let c27404_2 = r31;
env30608[0] = void 0;
env30608[1] = void 0;
env30608[2] = void 0;
env30608[0] = c27404_0.attachments;
env30608[1] = c27404_0.channel;
env30608[2] = c27404_0.comment;
env30608[3] = void 0;
env30608[4] = void 0;
env30608[5] = void 0;
env30608[6] = void 0;
await void 0;
env30608[3] = env30608[1].id;
env30608[4] = env30608[0].map($mk116476(c27404_2));
const r59 = env30608[1];
const r60 = env30608[2];
let c27404_1 = r60;
if (r60 == null) {
c27404_1 = "";
}
env30608[5] = MessageParser.parse(r59, c27404_1);
if (env30608[4].length > 0) {
UploadAttachmentActionCreators.clearAll(env30608[3], DraftType.ChannelMessage);
}
env30608[6] = new Future();
await MessageActionCreators.sendMessage(env30608[1].id, env30608[5], false, {
location: MessageSendLocation.SHARE_MODAL,
doNotNotifyOnError: true,
attachmentsToUpload: env30608[4],
onAttachmentUploadError: $mk116477(c27404_2)
});
env30608[6].resolve(void 0);
return env30608[6].promise;
}
@@ -0,0 +1,13 @@
// Metro module 9894 (f9895).
import { dismissKeyboard } from "../../../utils/native/ChatInputUtils";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import { isIOS } from "../../../utils/PlatformUtils";
import { getIsWindowLarge } from "../../screen/native/useIsWindowLarge";
export default function showSearchableDestinationListModal(a0, a1, a2) {
dismissKeyboard();
return ModalActionCreators.pushLazy(a0, a1, a2, isIOS() ? getIsWindowLarge() ? void 0 : {
presentation: "modal"
} : {
presentation: "modal"
});
};
@@ -0,0 +1,73 @@
// Metro module 9916 (f9917).
import { useRef, useState, useCallback } from "react";
import { EmojiIntention } from "../../emojis/EmojiConstants";
import { openEmojiPickerActionSheet } from "../../emoji_picker/native/openEmojiPickerActionSheet";
export function useShareChatInputActions(a0, a1, a2) {
let callback, callback2;
let c17552_0 = a0;
const channel = a1;
const appEntryKey = a2;
const ref = useRef(null);
const ref2 = useRef({
start: 0,
end: 0
});
const [isInputFocused, setState] = useState(false);
const callback3 = useCallback((a0) => {
ref2.current = {
...a0.nativeEvent.selection
};
}, []);
const callback4 = useCallback(() => {
setState(true);
}, []);
const callback5 = useCallback(() => {
setState(false);
}, []);
callback = useCallback((a0) => {
let surrogates = "";
if (a0.id == null && a0.surrogates != null) {
surrogates = a0.surrogates;
} else {
surrogates = `:${a0.uniqueName != null && a0.uniqueName !== "" ? a0.uniqueName : a0.name}: `;
}
c17552_0((a0) => a0.slice(0, ref2.current.start) + surrogates + a0.slice(ref2.current.end));
const current = ref.current;
if (current != null) {
current.focus();
}
}, [a0]);
callback2 = useCallback(() => {
const current = ref.current;
if (current != null) {
current.focus();
}
}, []);
return {
textInputRef: ref,
isInputFocused,
handleSelectionChange: callback3,
handleMessageFocus: callback4,
handleMessageBlur: callback5,
handlePressEmoji: useCallback(() => {
const current = ref.current;
if (current != null) {
current.blur();
}
let guildId = channel == null ? void 0 : channel.getGuildId();
if (guildId == null) {
guildId = void 0;
}
openEmojiPickerActionSheet({
onPressEmoji: callback,
onClose: callback2,
pickerIntention: EmojiIntention.CHAT,
autoFocus: false,
startExpanded: false,
channel,
appEntryKey,
guildId
});
}, [callback2, callback, a1, a2])
};
}
+45
View File
@@ -0,0 +1,45 @@
// Metro module 9910 (f9911).
import { useState, useEffect, useCallback } from "react";
import useInitialValue from "../../hooks/useInitialValue";
import Module6163 from "../autocompleter/index";
export default function useAutocompleter({ searchOptions }) {
let c17550_2;
c17550_2 = void 0;
const [state, setState] = useState({
results: [],
query: ""
});
const initialValue = useInitialValue(() => {
const module6163 = new Module6163((a0, a1) => {
setState({
results: a0,
query: a1
});
});
module6163.setLimit(20);
module6163.search("");
return module6163;
});
c17550_2 = initialValue;
useEffect(() => () => c17550_2.destroy(), [initialValue]);
useEffect(() => {
if (searchOptions != null && searchOptions !== c17550_2.options) {
c17550_2.setOptions(searchOptions);
}
}, [initialValue, searchOptions]);
return {
search: useCallback(({ query, resultTypes: resultTypes2 }) => {
let r12 = c17550_2.resultTypes != null;
if (r12) {
const resultTypes = c17550_2.resultTypes;
r12 = resultTypes2.length === resultTypes.size && resultTypes2.every((item) => resultTypes.has(item));
}
if (!r12) {
c17550_2.setResultTypes(resultTypes2);
c17550_2.setLimit(resultTypes2.length === 1 ? 50 : 20);
}
c17550_2.search(query.trim() !== "" ? query : "");
}, [initialValue]),
...state
};
};
+153
View File
@@ -0,0 +1,153 @@
// Metro module 13039 (f13040).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { useState, useRef, useEffect } from "react";
import URLUtils from "../../utils/URLUtils";
import { unfurlEmbedUrl } from "../media_channel/MediaChannelActionCreators";
import { batchUpdates } from "../../_bundle/Module705";
function $mk118901($env) {
return () => {
const r2 = $env;
(0, r2[3])(true);
(0, r2[2])(false);
};
}
let env8998 = {};
export default function useFetchShareEmbed(a0) {
let env20352 = {
$parent: env8998
};
env20352[0] = a0;
const r12 = _slicedToArray(useState(void 0), 2);
const embed = r12[0];
env20352[1] = r12[1];
const r16 = _slicedToArray(useState(false), 2);
const isLoading = r16[0];
env20352[2] = r16[1];
const r21 = _slicedToArray(useState(false), 2);
const hasTriedResolving = r21[0];
env20352[3] = r21[1];
env20352[4] = useRef(true);
env20352[5] = useRef(void 0);
useEffect(() => {
let c27403_0, c27403_1;
let _unfurl2 = function _unfurl() {
const r9 = async () => {
let c31678_0, c31678_1, c31678_2;
let c31678_3 = 0;
const r11 = void 0;
const r10 = env20352;
L17: {
L16: {
try {
let env32039;
c31678_1 = r11;
const r27 = env32039 = {
$parent: r10
};
c31678_0 = r27;
env32039[0] = void 0;
if (c27403_0 != null) {
c31678_3 = 2;
(0, env20352[2])(true);
env32039[0] = await unfurlEmbedUrl([c27403_0]);
if (env32039[0].embeds.length === 0) {
(0, env20352[1])(void 0);
c31678_3 = 0;
batchUpdates($mk118901(env20352));
break L17;
}
(0, env20352[1])({
embed: env32039[0].embeds[0],
url: c27403_0
});
c31678_3 = 1;
c31678_3 = 0;
batchUpdates($mk118901(env20352));
break L16;
}
} catch ($e) {
const r25 = $e;
let r7 = r25;
c31678_2 = r25;
let r26 = c31678_3;
if (r26 !== 0) {
while (true) {
if (r26 === 1) {
try {
const r124 = c31678_2;
c31678_3 = 0;
batchUpdates($mk118901(env20352));
throw r124;
} catch (r121) {
r7 = r121;
c31678_2 = r121;
r26 = c31678_3;
if (r26 === 0) {
break;
}
}
} else {
try {
c31678_3 = 1;
(0, env20352[1])(void 0);
c31678_3 = 0;
batchUpdates($mk118901(env20352));
break L16;
} catch (r102) {
r7 = r102;
c31678_2 = r102;
r26 = c31678_3;
if (r26 === 0) {
break;
}
}
}
}
}
throw r7;
}
return void 0;
}
return void 0;
}
};
_unfurl2 = r9;
return r9.apply(this, arguments);
};
const r8 = env20352[0];
if (r8 != null && r8 !== "") {
const r16 = r8.match(URLUtils.URL_REGEX);
const current = r16 == null ? void 0 : r16.at(0);
c27403_0 = current;
const r19 = env20352[5];
if (current !== r19.current) {
r19.current = current;
if (current == null) {
(0, env20352[1])(void 0);
env20352[4].current = false;
return void 0;
}
const unfurl = function unfurl() {
return _unfurl2.apply(this, arguments);
};
const r22 = env20352[4];
if (r22.current) {
r22.current = false;
unfurl();
}
c27403_1 = setTimeout(unfurl, 1000);
return () => {
clearTimeout(c27403_1);
};
}
return void 0;
}
env20352[4].current = false;
(0, env20352[1])(void 0);
}, [a0]);
return {
embed,
isLoading,
hasTriedResolving
};
};
+123
View File
@@ -0,0 +1,123 @@
// Metro module 9906 (f9907).
import { useMemo, useState, useCallback, useRef, useEffect, useLayoutEffect } from "react";
import GatewayConnectionStore from "../gateway/GatewayConnectionStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import FrecencyStore from "../../stores/FrecencyStore";
import { ALLOWED_TYPES } from "./ShareConstants";
import { getQuickSwitcherOptions } from "../quickswitcher/QuickSwitcherActionCreators";
import { useStateFromStores } from "../../_bundle/Module589";
import useAutocompleter from "./useAutocompleter";
import { useFrecencySettings } from "../user_settings/FrecencyUserSettingsHooks";
import formatResults from "./formatResults";
export function makeAutocompleterSearchParams(a0) {
const quickSwitcherOptions = getQuickSwitcherOptions(a0);
const { query: query2, queryMode: queryMode2 } = quickSwitcherOptions;
let resultTypes = ALLOWED_TYPES;
const r14 = queryMode2 != null && ALLOWED_TYPES.includes(queryMode2);
let queryMode3 = null;
if (r14) {
const r16 = [queryMode2];
queryMode3 = queryMode2;
resultTypes = r16;
}
return {
query: query2,
queryMode: queryMode3,
resultTypes
};
}
export function useShareSearchResults({ targetDestination, selectedDestinations, originDestination, channelFilter, includeMissingDMs: includeMissingDMs2 = false }) {
let search, query, results, state, setState, queryMode, ref, ref2, current, stateFromStores2, stateFromStores3, hasQuery;
const includeMissingDMs = includeMissingDMs2;
search = void 0;
query = void 0;
results = void 0;
state = void 0;
setState = void 0;
queryMode = void 0;
ref = void 0;
ref2 = void 0;
current = void 0;
stateFromStores2 = void 0;
stateFromStores3 = void 0;
hasQuery = void 0;
const stateFromStores = useStateFromStores([AuthenticationStore], () => AuthenticationStore.getId());
const autocompleter = useAutocompleter(useMemo(() => ({
searchOptions: {
blacklist: new Set([`user:${stateFromStores}`]),
frecencyBoosters: true,
userFilters: null
}
}), [stateFromStores]));
search = autocompleter.search;
query = autocompleter.query;
results = autocompleter.results;
const quickSwitcherOptions = getQuickSwitcherOptions("");
const { query: query2, queryMode: queryMode2 } = quickSwitcherOptions;
let resultTypes = ALLOWED_TYPES;
const r43 = queryMode2 != null && ALLOWED_TYPES.includes(queryMode2);
let queryMode3 = null;
if (r43) {
const r45 = [queryMode2];
queryMode3 = queryMode2;
resultTypes = r45;
}
[state, setState] = useState({
query: query2,
queryMode: queryMode3,
resultTypes
});
const callback = useCallback((a0) => {
const quickSwitcherOptions = getQuickSwitcherOptions(a0);
const { query: query2, queryMode: queryMode2 } = quickSwitcherOptions;
let resultTypes = ALLOWED_TYPES;
const r16 = queryMode2 != null && ALLOWED_TYPES.includes(queryMode2);
let queryMode3 = null;
if (r16) {
const r18 = [queryMode2];
queryMode3 = queryMode2;
resultTypes = r18;
}
return setState({
query: query2,
queryMode: queryMode3,
resultTypes
});
}, [setState]);
queryMode = state.queryMode;
ref = useRef(null);
ref2 = useRef(selectedDestinations);
current = query === ref.current ? ref2.current : selectedDestinations;
useEffect(() => {
if (query !== ref.current) {
ref2.current = selectedDestinations;
}
ref.current = query;
}, [query, selectedDestinations]);
useLayoutEffect(() => {
search({
query: state.query,
resultTypes: state.resultTypes
});
}, [search, state]);
useFrecencySettings();
stateFromStores2 = useStateFromStores([FrecencyStore], () => FrecencyStore.getFrequentlyWithoutFetchingLatest());
stateFromStores3 = useStateFromStores([GatewayConnectionStore], () => GatewayConnectionStore.isConnected());
hasQuery = query !== "";
return {
results: useMemo(() => formatResults({
results,
hasQuery,
queryMode,
targetDestination,
frequentChannels: stateFromStores2,
selectedDestinations,
pinnedDestinations: current,
originDestination,
channelFilter,
includeMissingDMs,
isConnected: stateFromStores3
}), [results, hasQuery, queryMode, targetDestination, stateFromStores2, selectedDestinations, current, originDestination, channelFilter, includeMissingDMs, stateFromStores3]),
updateSearchText: callback
};
}