368 lines
13 KiB
TypeScript
368 lines
13 KiB
TypeScript
// Metro module 15372 (f15373).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import _asyncToGenerator from "../../../_bundle/_asyncToGenerator";
|
|
import { useRef, useEffect, useState, useCallback, useMemo } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import "../../../stores/DraftStore";
|
|
import "../../../stores/UploadAttachmentStore";
|
|
import { AbortCodes } from "../../../Constants";
|
|
import { UserRowModes } from "../../main_tabs_v2/native/shared_components/user_list/UserRowConstants";
|
|
import { MessageSendLocation } from "../../messages/MessageConstants";
|
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { SHARE_EVENT_DETAILS_LINK } from "../../guild_scheduled_events/utils/ShareEventUtils";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { sendMessageWithEmbed } from "../../content_inventory/reactionUtils";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
|
|
import useColorThemeBackground from "../../client_themes/native/useColorThemeBackground";
|
|
import { useClientThemesOverride } from "../../client_themes/native/ClientThemesOverrides";
|
|
import validateOptions from "../../../_bundle/validateOptions";
|
|
import ThemedGradient from "../../client_themes/native/ThemedGradient";
|
|
import { OverlayOpacity } from "../../client_themes/native/ClientThemesUtils";
|
|
import { ThemeContextProvider } from "../../../_bundle/Module3901";
|
|
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
|
|
import { useShareChatInputActions } from "../../share/native/useShareChatInputActions";
|
|
import ShareChatInput from "../../share/native/ShareChatInput";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { getOrResolveChannelIdFromDestinationId } from "../../share/formatResults";
|
|
import { isNotNullish } from "../../../utils/GlobalUtils";
|
|
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
|
|
import { isAndroid, isIOS } from "../../../utils/PlatformUtils";
|
|
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 SearchableDestinationList from "../../share/native/SearchableDestinationList";
|
|
function $mk118475($env) {
|
|
return (a0) => ChannelStore.getChannel(a0);
|
|
}
|
|
function $mk118476($env) {
|
|
return function() {
|
|
let env32068 = {
|
|
$parent: $env
|
|
};
|
|
env32068[0] = (0, _asyncToGenerator)(function*(c32144_0) {
|
|
L20: {
|
|
const r15 = env32068.$parent.$parent.$parent;
|
|
let env32177 = {
|
|
$parent: r15
|
|
};
|
|
env32177[0] = c32144_0;
|
|
const r16 = env32068.$parent[0];
|
|
const r18 = r16 != null && r16.trim().length > 0 ? `${r16}
|
|
|
|
${env32068.$parent.$parent[1]}` : env32068.$parent.$parent[1];
|
|
const r45 = r15[1];
|
|
const r46 = r15[2];
|
|
const r51 = r45(r46[31]).parse(c32144_0, r18);
|
|
const r20 = env32068.$parent.$parent;
|
|
const r52 = r20[3];
|
|
if (r52 == null) {
|
|
const r54 = r20[2] != null && r20[7] != null;
|
|
let attachmentsToUpload = void 0;
|
|
if (r54) {
|
|
const r19 = r45(r46[32]);
|
|
const uri = r20[7];
|
|
const r21 = r15[0];
|
|
const r71 = {
|
|
channelId: c32144_0.id,
|
|
file: {
|
|
uri,
|
|
originalUri: uri,
|
|
id: r21(r46[33]).v4(),
|
|
platform: r21(r46[34]).UploadPlatform.REACT_NATIVE
|
|
},
|
|
draftType: null
|
|
};
|
|
const r81 = r15[8];
|
|
r71.draftType = r81.ChannelMessage;
|
|
r19.addFile(r71);
|
|
attachmentsToUpload = r15[9].getUploads(c32144_0.id, r81.ChannelMessage);
|
|
r45(r46[32]).clearAll(c32144_0.id, r81.ChannelMessage);
|
|
}
|
|
yield r45(r46[35]).sendMessage(c32144_0.id, r51, false, {
|
|
location: r15[12].ICYMI,
|
|
attachmentsToUpload,
|
|
onAttachmentUploadError: (a0, a1, a2) => {
|
|
const r1 = env32177.$parent;
|
|
(0, r1[0])(r1[2][36]).handleUploadMessageAttachmentsErrors({
|
|
file: a0,
|
|
guildId: env32177[0].getGuildId(),
|
|
analyticsLocations: [],
|
|
code: a1,
|
|
reason: a2
|
|
});
|
|
}
|
|
});
|
|
break L20;
|
|
}
|
|
r52(c32144_0);
|
|
return void 0;
|
|
}
|
|
});
|
|
return function(a0) {
|
|
return env32068[0].apply(this, arguments);
|
|
};
|
|
};
|
|
}
|
|
let GravityShareFooter, ICYMIShareModal, useStyles;
|
|
let env10924 = {};
|
|
const Screenshot = function Screenshot(props) {
|
|
const { render, setUri } = props;
|
|
const styles = useStyles();
|
|
const ref = useRef(null);
|
|
useEffect(() => {
|
|
setTimeout(() => {
|
|
const current = ref.current;
|
|
const r2 = current == null;
|
|
let r7 = void 0;
|
|
if (!r2) {
|
|
const capture = current.capture;
|
|
r7 = capture == null ? void 0 : capture.call(current).then((result) => {
|
|
setUri(result);
|
|
});
|
|
}
|
|
return r7;
|
|
}, 500);
|
|
}, [setUri]);
|
|
return <View style={{
|
|
position: "absolute",
|
|
top: -1000,
|
|
overflow: "hidden"
|
|
}}>
|
|
<View style={[styles.preview, {
|
|
width: useWindowDimensions_native().width
|
|
}]}>
|
|
{jsx(validateOptions, {
|
|
ref,
|
|
options: {
|
|
fileName: "icymi_content",
|
|
format: "png",
|
|
quality: 1
|
|
},
|
|
children: (0, jsxs)(View, {
|
|
style: styles.base,
|
|
children: [<ThemedGradient absolute wide tall mix mixAmount={{
|
|
dark: OverlayOpacity.LEVEL_7,
|
|
light: OverlayOpacity.LEVEL_8
|
|
}} />, <ThemeContextProvider gradient={useColorThemeBackground()}>
|
|
<View style={[styles.contentContainer, useClientThemesOverride()]}>
|
|
{render()}
|
|
</View>
|
|
</ThemeContextProvider>]
|
|
})
|
|
})}
|
|
</View>
|
|
</View>;
|
|
};
|
|
GravityShareFooter = function GravityShareFooter(props) {
|
|
const { count, isSending, onSend } = props;
|
|
const styles = useStyles();
|
|
let c21931_1 = styles;
|
|
const [state, onChange] = useState("");
|
|
const insets = useSafeAreaInsetsKeyboardAware_native({
|
|
includeKeyboardHeight: true
|
|
}).insets;
|
|
const shareChatInputActions = useShareChatInputActions(onChange);
|
|
const { textInputRef, handleSelectionChange, handleMessageFocus, handleMessageBlur, handlePressEmoji } = shareChatInputActions;
|
|
const callback = useCallback(() => {
|
|
onSend(state);
|
|
}, [state, onSend]);
|
|
const text = count <= 1 ? intl.string(t.TXNS7S) : intl.formatToPlainString(t.jWtYUm, {
|
|
count
|
|
});
|
|
const memo = useMemo(() => [c21931_1.footer, {
|
|
paddingBottom: c21931_1.footer.paddingVertical + insets.bottom
|
|
}], [styles.footer, insets.bottom]);
|
|
const disabled = count === 0;
|
|
return disabled ? null : <View style={memo}>
|
|
<ShareChatInput inputRef={textInputRef} text={state} onChange={onChange} onSelectionChange={handleSelectionChange} onFocus={handleMessageFocus} onBlur={handleMessageBlur} onPressEmoji={handlePressEmoji} onSend={callback} disabled={isSending} />
|
|
<Button variant="primary" size="md" text={text} disabled={disabled} onPress={isSending ? void 0 : callback} loading={isSending} />
|
|
</View>;
|
|
};
|
|
ICYMIShareModal = function ICYMIShareModal(props) {
|
|
let env21932 = {
|
|
$parent: env10924
|
|
};
|
|
const title = props.title;
|
|
env21932[0] = title;
|
|
const originDestinationId = props.originDestinationId;
|
|
env21932[1] = props.linkText;
|
|
const render = props.render;
|
|
env21932[2] = render;
|
|
env21932[3] = props.forwardToChannel;
|
|
env21932[4] = props.onShare;
|
|
env21932[5] = void 0;
|
|
env21932[6] = void 0;
|
|
env21932[7] = void 0;
|
|
env21932[9] = void 0;
|
|
env21932[10] = void 0;
|
|
env21932[8] = function _handleSendForwards() {
|
|
const r9 = async (c30869_0) => {
|
|
let c30869_1, c30869_2;
|
|
L16: {
|
|
let env31757;
|
|
const r8 = env21932;
|
|
c30869_2 = r8;
|
|
const r10 = env31757 = {
|
|
$parent: r8
|
|
};
|
|
c30869_1 = r10;
|
|
env31757[0] = c30869_0;
|
|
(0, env21932[6])(true);
|
|
if (env21932[2] == null || env21932[7] != null) {
|
|
const r49 = await Promise.all(env21932[5].map(getOrResolveChannelIdFromDestinationId));
|
|
const r57 = c30869_1;
|
|
r49.map($mk118475(env21932.$parent)).filter(isNotNullish).forEach($mk118476(r57)());
|
|
ModalActionCreators.pop();
|
|
if (env21932[4] == null) {
|
|
break L16;
|
|
}
|
|
(0, env21932[4])();
|
|
break L16;
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
env21932[8] = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const r6 = _slicedToArray(useState([]), 2);
|
|
const r33 = r6[0];
|
|
env21932[5] = r33;
|
|
const onSelectedDestinationChange = r6[1];
|
|
const length = r33.length;
|
|
const r36 = _slicedToArray(useState(false), 2);
|
|
const isSending = r36[0];
|
|
env21932[6] = r36[1];
|
|
const r41 = _slicedToArray(useState(null), 2);
|
|
env21932[7] = r41[0];
|
|
const setUri2 = r41[1];
|
|
const callback = useCallback(() => {
|
|
ModalActionCreators.pop();
|
|
}, []);
|
|
const styles = useStyles();
|
|
const safeAreaInsets_native = useSafeAreaInsets_native();
|
|
env21932[9] = safeAreaInsets_native;
|
|
const height = useWindowDimensions_native().height;
|
|
env21932[10] = height;
|
|
return <View style={useMemo(() => ({
|
|
height: isAndroid() ? env21932[10] + env21932[9].bottom : "100%"
|
|
}), [safeAreaInsets_native.bottom, height])}>
|
|
<View style={styles.headerContainer}>
|
|
<Header title={title} headerTitle={() => (0, jsx)(GenericHeaderTitle, {
|
|
title: env21932[0]
|
|
})} headerTitleAlign="center" headerStatusBarHeight={isIOS() ? 0 : void 0} headerLeft={getHeaderCloseButton(callback)} />
|
|
</View>
|
|
{render != null && <Screenshot render={render} setUri={setUri2} />}
|
|
<SearchableDestinationList rowMode={UserRowModes.TOGGLE} onSelectedDestinationChange={onSelectedDestinationChange} originDestination={originDestinationId} insetEnd={safeAreaInsets_native.bottom + Module712.space.PX_8 + Module712.space.PX_96} disableGradient disableStickySections />
|
|
<GravityShareFooter count={length} isSending={isSending} onSend={function handleSendForwards(event) {
|
|
return env21932[8].apply(this, arguments);
|
|
}} />
|
|
</View>;
|
|
};
|
|
useStyles = createStyles({
|
|
headerContainer: {
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingTop: Module712.space.PX_8
|
|
},
|
|
preview: {
|
|
borderRadius: Module712.radii.md,
|
|
overflow: "hidden",
|
|
borderWidth: 1,
|
|
borderColor: Module712.colors.BORDER_STRONG
|
|
},
|
|
base: {
|
|
position: "relative"
|
|
},
|
|
contentContainer: {
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
|
|
},
|
|
footer: {
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
alignItems: "flex-end",
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingVertical: Module712.space.PX_12,
|
|
gap: Module712.space.PX_12,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
|
|
borderTopWidth: 1,
|
|
borderTopColor: Module712.colors.BORDER_SUBTLE
|
|
}
|
|
});
|
|
export default ICYMIShareModal;
|
|
export function GuildEventShareModal({ event }) {
|
|
const linkText = SHARE_EVENT_DETAILS_LINK({
|
|
guildId: event.guild_id,
|
|
guildEventId: event.id
|
|
});
|
|
return <ICYMIShareModal title={intl.string(t["7TVSLK"])} originDestinationId={event.channel_id != null ? {
|
|
type: "channel",
|
|
id: event.channel_id
|
|
} : void 0} linkText={linkText} />;
|
|
}
|
|
export function GameShareModal(a0) {
|
|
let env21933 = {
|
|
$parent: env10924
|
|
};
|
|
env21933[0] = a0.content;
|
|
const r18 = {
|
|
title: intl.string(t["59CWHK"]),
|
|
linkText: "",
|
|
forwardToChannel: null
|
|
};
|
|
let c21934_0 = async (channel) => {
|
|
let c30870_3;
|
|
let c30870_4 = 0;
|
|
let c31758_0, c31758_1;
|
|
L10: {
|
|
try {
|
|
c31758_0 = void 0;
|
|
c30870_4 = 1;
|
|
await sendMessageWithEmbed({
|
|
channel,
|
|
content: "",
|
|
entry: env21933[0],
|
|
whenReady: false,
|
|
doNotNotifyOnError: true,
|
|
location: MessageSendLocation.ICYMI
|
|
});
|
|
c30870_4 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r7 = r28;
|
|
c30870_3 = r28;
|
|
if (c30870_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r64 = c30870_3;
|
|
c30870_4 = 0;
|
|
c31758_1 = r64;
|
|
c31758_0 = c31758_1.body != null && c31758_1.body.code === AbortCodes.CONTENT_INVENTORY_ENTRY_INVALID_PERMISSION;
|
|
ToastActionCreators.open({
|
|
key: "FORWARD_CONTENT_INVENTORY_ENTRY_ERROR",
|
|
content: c31758_0 ? intl.string(t.BC5vfD) : intl.string(t.F8FvUy)
|
|
});
|
|
break L10;
|
|
} catch (r61) {
|
|
r7 = r61;
|
|
c30870_3 = r61;
|
|
if (c30870_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
};
|
|
r18.forwardToChannel = function() {
|
|
return c21934_0.apply(this, arguments);
|
|
};
|
|
return <ICYMIShareModal {...r18} />;
|
|
}
|