Files
discord-decomp/sources/modules/media_uploads/native/UploadPreviewActionSheet.tsx
T
2026-07-27 16:20:00 +03:00

362 lines
21 KiB
TypeScript

/* Metro module 11094; source: modules/media_uploads/native/UploadPreviewActionSheet.tsx; dependencies: [57, 31, 27, 4645, 6276, 33, 4501, 697, 44, 4650, 1478, 1585, 4594, 4080, 4673, 11095, 3857, 7684, 4660, 11133, 11134, 6275, 6277, 4572, 4573, 477, 9543, 8509, 6231, 6238, 11135, 11137, 1244, 8950, 11139, 7879, 6697, 11141, 4578, 4071, 2] */
function _fun84935(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#84935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:6, offset: 0x01f5d433, size: 442 bytes, params: 8, frame: 22
var object2;
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(57) /* metro dependency 57 */;
const env0_4 = importAll(31) /* metro dependency 31 */;
let value = require(27) /* metro dependency 27 */;
const env0_5 = value.Image;
const env0_6 = value.View;
const env0_7 = (require(4645) /* metro dependency 4645: DraftStore */).DraftType;
const env0_8 = (require(6276) /* metro dependency 6276: ActionSheetConstants */).ACTION_SHEET_MAX_WIDTH;
value = require(33) /* metro dependency 33 */;
const env0_9 = value.jsx;
const env0_10 = value.jsxs;
value = require(4501) /* metro dependency 4501: createStyles */;
const createStyles = value.createStyles;
object2 = {};
object2.contentContainer = {padding: 16};
const object4 = {};
const BACKGROUND_SURFACE_HIGH = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_SURFACE_HIGH;
object4.backgroundColor = BACKGROUND_SURFACE_HIGH;
const PX_8 = (importDefault(697) /* metro dependency 697: native */).space.PX_8;
object4.padding = PX_8;
let md = (importDefault(697) /* metro dependency 697: native */).radii.md;
object4.borderRadius = md;
object4.width = '100%';
object2.imageWrap = object4;
md = (importDefault(697) /* metro dependency 697: native */).radii.md;
const PX_4 = (importDefault(697) /* metro dependency 697: native */).space.PX_4;
object2.imageContainer = {'overflow': 'hidden', 'alignSelf': 'center', borderRadius: md - PX_4};
const env0_11 = Reflect.apply(createStyles, value, [object2]);
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/media_uploads/native/UploadPreviewActionSheet.tsx');
exports.default = UploadPreviewActionSheet;
}
function UploadPreviewActionSheet({onAdd, onEdit, onRemove, channelId, onClose, disableAddDescription, disableSpoiler, upload}) { // fn#84936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:529, offset: 0x01f5d5ed, size: 2198 bytes, params: 2, frame: 47
var r4;
var r23;
var r21;
var r15;
var r10;
var value18;
var space;
var value19;
const TableRowGroup = (require(6231) /* metro dependency 6231: TableRowGroupNative */).TableRowGroup;
const TableRow = (require(6238) /* metro dependency 6238: TableRowNative */).TableRow;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
var items4;
const TableCheckboxRow = (require(8950) /* metro dependency 8950: TableCheckboxRowNative */).TableCheckboxRow;
const Button = (require(4578) /* metro dependency 4578: ButtonNative */).Button;
const env0_3 = channelId;
disableAddDescription = !(disableAddDescription === undefined) && disableAddDescription;
const styles = useStyles();
const id = upload.id;
const isVideo = upload.isVideo;
const isImage = upload.isImage;
const isThumbnail = upload.isThumbnail;
const r28 = isThumbnail !== undefined && isThumbnail;
const item = upload.item;
const spoiler = upload.spoiler;
const defaultImport = importDefault(44) /* metro dependency 44 */;
const platform = item.platform;
const UploadPlatform = (require(4650) /* metro dependency 4650: Upload */).UploadPlatform;
const REACT_NATIVE = UploadPlatform.REACT_NATIVE;
defaultImport(platform === REACT_NATIVE, 'Upload must be a React Native upload item.');
const width = (importDefault(1478) /* metro dependency 1478: useWindowDimensionsNative */)().width;
const bottom = (importDefault(1585) /* metro dependency 1585: useSafeAreaInsetsNative */)().bottom;
(importDefault(4594) /* metro dependency 4594: useMountEffect */)(function() {
return _fun84938;
});
const binding = onClose;
const value5 = binding.useMemo(_fun84939, [width, item, styles]);
const value6 = binding.useCallback(_fun84940, [onRemove, id]);
const value7 = binding.useCallback(_fun84941, [onAdd]);
const value8 = binding.useCallback(_fun84942, [onEdit, item]);
const value9 = binding.useMemo(_fun84945, [isVideo, item]);
const r20 = isImage && !disableAddDescription;
const r24 = !r28 && !disableSpoiler;
const value13 = (importDefault(11133) /* metro dependency 11133: useCanSetThumbnail */)(channelId, upload);
const value14 = (importDefault(11134) /* metro dependency 11134: useSetMediaPostThumbnail */)(channelId, upload);
const [property, env0_11] = env0_3(onClose.useState(undefined), 2);
if (property != null) {
value18 = property + bottom;
space = (importDefault(697) /* metro dependency 697: native */).space;
value19 = value18 + space.PX_32;
space = (importDefault(697) /* metro dependency 697: native */).space;
r4 = value19 + space.PX_16;
} else {
r4 = undefined;
}
const r22 = isImage && onEdit != null;
const BottomSheet = (require(6275) /* metro dependency 6275: BottomSheetNative */).BottomSheet;
const BottomSheetScrollView = (require(6277) /* metro dependency 6277 */).BottomSheetScrollView;
const object = {};
const PX_16 = (importDefault(697) /* metro dependency 697: native */).space.PX_16;
object.padding = PX_16;
object.paddingBottom = bottom;
const Stack = (require(4572) /* metro dependency 4572: StackNative */).Stack;
const object2 = {spacing: 16, onLayout: onLayout_84946};
const Text = (require(4573) /* metro dependency 4573: Text */).Text;
const items5 = [<Text variant="text-md/semibold">{item.filename}</Text>];
const items2 = [styles.imageContainer];
items2[1] = {width: value5.width, height: value5.height};
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
const items3 = [platformUtilsModule.isIOS() && isVideo && item.uri.startsWith('file://') ? ((VideoComponent) => <VideoComponent style={{width: value5.width,
height: value5.height}} source={{uri: item.uri}} muted paused preventsDisplaySleepDuringVideoPlayback={false} />)((require(9543) /* metro dependency 9543: Video */).VideoComponent) : <Image style={{width: value5.width,
height: value5.height}} source={item} />];
items3[1] = value9 != null && value9 !== '' && ((Caption) => <Caption label={value9} />)((require(8509) /* metro dependency 8509: Caption */).Caption);
items5[1] = <View style={styles.imageWrap}><View style={items2}>{items3}</View></View>;
if (r20) {
if (r20) {
r23 = <TableRow icon={((ImageFileIcon) => <ImageFileIcon />)((require(11135) /* metro dependency 11135: ImageFileIcon */).ImageFileIcon)} onPress={onPress_84947} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['5S2AK+'])} arrow />;
} else {
r23 = null;
}
items4 = [r23];
if (r24) {
r23 = <TableCheckboxRow icon={((SpoilerIcon) => <SpoilerIcon />)((require(11139) /* metro dependency 11139: SpoilerIcon */).SpoilerIcon)} onPress={function() {
importDefault(dependencyMap[13]).hideActionSheet();
var defaultImport2 = importDefault(dependencyMap[35]);
var channelIdBinding = channelId;
var idBinding = id;
var ChannelMessage = DraftType.ChannelMessage;
defaultImport2.update(channelIdBinding, idBinding, ChannelMessage, {spoiler: !spoiler});
}} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['gsI+xC'])} checked={spoiler} />;
} else {
r23 = null;
}
items4[1] = r23;
if (value13) {
r21 = <TableCheckboxRow icon={((ImageIcon) => <ImageIcon />)((require(6697) /* metro dependency 6697: ImageIcon */).ImageIcon)} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.ews2pj)} onPress={value14} checked={r28} />;
} else {
r21 = value13;
}
items4[2] = r21;
if (r22) {
r21 = <TableRow icon={((PencilSparkleIcon) => <PencilSparkleIcon />)((require(11141) /* metro dependency 11141: PencilSparkleIcon */).PencilSparkleIcon)} onPress={value8} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.b0y3DL)} arrow />;
} else {
r21 = null;
}
items4[3] = r21;
r15 = <TableRowGroup hasIcons>{items4}</TableRowGroup>;
} else if (r24) {
if (r20) {
r23 = <TableRow icon={((ImageFileIcon) => <ImageFileIcon />)((require(11135) /* metro dependency 11135: ImageFileIcon */).ImageFileIcon)} onPress={onPress_84947} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['5S2AK+'])} arrow />;
} else {
r23 = null;
}
items4 = [r23];
if (r24) {
r23 = <TableCheckboxRow icon={((SpoilerIcon) => <SpoilerIcon />)((require(11139) /* metro dependency 11139: SpoilerIcon */).SpoilerIcon)} onPress={onPress_84948} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['gsI+xC'])} checked={spoiler} />;
} else {
r23 = null;
}
items4[1] = r23;
if (value13) {
r21 = <TableCheckboxRow icon={((ImageIcon) => <ImageIcon />)((require(6697) /* metro dependency 6697: ImageIcon */).ImageIcon)} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.ews2pj)} onPress={value14} checked={r28} />;
} else {
r21 = value13;
}
items4[2] = r21;
if (r22) {
r21 = <TableRow icon={((PencilSparkleIcon) => <PencilSparkleIcon />)((require(11141) /* metro dependency 11141: PencilSparkleIcon */).PencilSparkleIcon)} onPress={value8} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.b0y3DL)} arrow />;
} else {
r21 = null;
}
items4[3] = r21;
r15 = <TableRowGroup hasIcons>{items4}</TableRowGroup>;
} else if (value13) {
if (r20) {
r23 = <TableRow icon={((ImageFileIcon) => <ImageFileIcon />)((require(11135) /* metro dependency 11135: ImageFileIcon */).ImageFileIcon)} onPress={onPress_84947} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['5S2AK+'])} arrow />;
} else {
r23 = null;
}
items4 = [r23];
if (r24) {
r23 = <TableCheckboxRow icon={((SpoilerIcon) => <SpoilerIcon />)((require(11139) /* metro dependency 11139: SpoilerIcon */).SpoilerIcon)} onPress={onPress_84948} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['gsI+xC'])} checked={spoiler} />;
} else {
r23 = null;
}
items4[1] = r23;
if (value13) {
r21 = <TableCheckboxRow icon={((ImageIcon) => <ImageIcon />)((require(6697) /* metro dependency 6697: ImageIcon */).ImageIcon)} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.ews2pj)} onPress={value14} checked={r28} />;
} else {
r21 = value13;
}
items4[2] = r21;
if (r22) {
r21 = <TableRow icon={((PencilSparkleIcon) => <PencilSparkleIcon />)((require(11141) /* metro dependency 11141: PencilSparkleIcon */).PencilSparkleIcon)} onPress={value8} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.b0y3DL)} arrow />;
} else {
r21 = null;
}
items4[3] = r21;
r15 = <TableRowGroup hasIcons>{items4}</TableRowGroup>;
} else if (r22) {
if (r20) {
r23 = <TableRow icon={((ImageFileIcon) => <ImageFileIcon />)((require(11135) /* metro dependency 11135: ImageFileIcon */).ImageFileIcon)} onPress={onPress_84947} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['5S2AK+'])} arrow />;
} else {
r23 = null;
}
items4 = [r23];
if (r24) {
r23 = <TableCheckboxRow icon={((SpoilerIcon) => <SpoilerIcon />)((require(11139) /* metro dependency 11139: SpoilerIcon */).SpoilerIcon)} onPress={onPress_84948} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['gsI+xC'])} checked={spoiler} />;
} else {
r23 = null;
}
items4[1] = r23;
if (value13) {
r21 = <TableCheckboxRow icon={((ImageIcon) => <ImageIcon />)((require(6697) /* metro dependency 6697: ImageIcon */).ImageIcon)} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.ews2pj)} onPress={value14} checked={r28} />;
} else {
r21 = value13;
}
items4[2] = r21;
if (r22) {
r21 = <TableRow icon={((PencilSparkleIcon) => <PencilSparkleIcon />)((require(11141) /* metro dependency 11141: PencilSparkleIcon */).PencilSparkleIcon)} onPress={value8} label={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.b0y3DL)} arrow />;
} else {
r21 = null;
}
items4[3] = r21;
r15 = <TableRowGroup hasIcons>{items4}</TableRowGroup>;
} else {
r15 = null;
}
items5[2] = r15;
if (onRemove != null) {
r10 = <Button icon={((TrashIcon) => <TrashIcon size="sm" color="control-primary-text-default" />)((require(4071) /* metro dependency 4071: TrashIcon */).TrashIcon)} text={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['40jBO/'])} onPress={value6} variant="destructive" />;
} else if (onAdd != null) {
r10 = <Button icon={((ImageFileIcon) => <ImageFileIcon size="sm" color="control-primary-text-default" />)((require(11135) /* metro dependency 11135: ImageFileIcon */).ImageFileIcon)} text={intl.string((require(1244) /* metro dependency 1244: indexNative */).t.s7oPyG)} onPress={value7} />;
} else {
r10 = null;
}
items5[3] = r10;
return (
<BottomSheet scrollable startHeight={r4}>
<BottomSheetScrollView contentContainerStyle={object}>
<Stack {...object2}>
{items5}
</Stack>
</BottomSheetScrollView>
</BottomSheet>
);
}
function _fun84937() { // fn#84937, offset: 0x01f5de83, size: 11 bytes, params: 1, frame: 1
return function() {
if (onClose != null) {
onClose();
}
};
}
function _fun84939() { // fn#84939, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:961, offset: 0x01f5dea9, size: 189 bytes, params: 1, frame: 17
const height = item.height;
const width2 = item.width;
let Math = global.Math;
let value = Math.min(width,
ACTION_SHEET_MAX_WIDTH) - 2 * styles.contentContainer.padding - 2 * styles.imageWrap.padding;
if (height != null) {
if (width2 != null) {
if (height === 0) {
return {'width': 300, 'height': 300};
}
if (width2 === 0) {
return {'width': 300, 'height': 300};
}
Math = global.Math;
value /= Math.max(width2, height);
return {width: width2 * value, height: height * value};
}
}
return {width: value, height: value};
}
function _fun84940() { // fn#84940, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1228, offset: 0x01f5df66, size: 63 bytes, params: 1, frame: 12
const value = environment.__proto__;
(importDefault(4080) /* metro dependency 4080: ActionSheetActionCreators */).hideActionSheet();
if (onRemove != null) {
onRemove(id);
}
}
function _fun84941() { // fn#84941, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1300, offset: 0x01f5dfa5, size: 58 bytes, params: 1, frame: 12
const value = environment.__proto__;
(importDefault(4080) /* metro dependency 4080: ActionSheetActionCreators */).hideActionSheet();
if (onAdd != null) {
onAdd();
}
}
function _fun84942() { // fn#84942, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1369, offset: 0x01f5dfdf, size: 168 bytes, params: 1, frame: 18
var environment;
let value = environment.__proto__;
value = undefined;
(importDefault(4080) /* metro dependency 4080: ActionSheetActionCreators */).hideActionSheet();
const uri = item.uri;
const width = item.width;
const height = item.height;
const defaultImport2 = importDefault(4673) /* metro dependency 4673: ImagePicker */;
defaultImport2.launchCropper({uri: uri, freeStyleCropEnabled: true, width: width === 0 ? value : width,
height: height === 0 ? value : height}).then(_fun84943).catch(_fun84944);
return value;
}
function _fun84945() { // fn#84945, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1751, offset: 0x01f5e131, size: 80 bytes, params: 1, frame: 16
let value = environment.__proto__;
value = require(4660) /* metro dependency 4660: UploadUtils */;
const getCaptionLabel = value.getCaptionLabel;
const uploadUtilsModule = require(4660) /* metro dependency 4660: UploadUtils */;
const getType = uploadUtilsModule.getType;
return Reflect.apply(getCaptionLabel, value, [Reflect.apply(getType, uploadUtilsModule, [item.uri]), isVideo, item]);
}
function UploadPreviewActionSheetOnLayout({nativeEvent}) { // fn#84946, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:2201, owner: UploadPreviewActionSheet.onLayout, offset: 0x01f5e181, size: 36 bytes, params: 2, frame: 11
env0_11(nativeEvent.layout.height);
}
function UploadPreviewActionSheetOnPress() { // fn#84947, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:2844, owner: UploadPreviewActionSheet.onPress, offset: 0x01f5e1a5, size: 67 bytes, params: 1, frame: 13
const value = environment.__proto__;
return (importDefault(11137) /* metro dependency 11137: AddImageDescriptionModalActionCreators */).open({source: item,
channelId: channelId, id: id});
}
function UploadPreviewActionSheetOnPress_84948() { // fn#84948, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:3027, owner: UploadPreviewActionSheet.onPress, offset: 0x01f5e1e8, size: 100 bytes, params: 1, frame: 19
(importDefault(4080) /* metro dependency 4080: ActionSheetActionCreators */).hideActionSheet();
const defaultImport2 = importDefault(7879) /* metro dependency 7879: UploadAttachmentActionCreators */;
const update = defaultImport2.update;
const channelIdBinding = channelId;
const idBinding = id;
const ChannelMessage = DraftType.ChannelMessage;
Reflect.apply(update, defaultImport2, [channelIdBinding, idBinding, ChannelMessage, {spoiler: !spoiler}]);
}
function _fun84943(a0) { // fn#84943, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1539, offset: 0x01f5e087, size: 65 bytes, params: 2, frame: 13
let value = environment.__proto__;
let onEditBinding = onEdit;
if (onEditBinding != null) {
onEditBinding = onEdit;
value = environment.__proto__.__proto__;
value = require(11095) /* metro dependency 11095: MediaKeyboardUtils */;
onEditBinding(value.cropResultToUploadItem(a0));
}
}
function _fun84944(a0) { // fn#84944, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11280:1600, offset: 0x01f5e0c8, size: 105 bytes, params: 2, frame: 16
var value;
var defaultImport;
var open;
var object2;
if (a0.code !== 'E_PICKER_CANCELLED') {
value = environment.__proto__.__proto__;
defaultImport = importDefault(3857) /* metro dependency 3857: ToastActionCreators */;
open = defaultImport.open;
object2 = {key: 'CROP_ERROR'};
object2.IconComponent = (require(7684) /* metro dependency 7684: CircleErrorIcon */).CircleErrorIcon;
object2.content = a0.message;
Reflect.apply(open, defaultImport, [object2]);
}
}