145 lines
5.9 KiB
TypeScript
145 lines
5.9 KiB
TypeScript
// Metro module 11006 (f11007).
|
|
import { useRef, useState, useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import { AnalyticEvents } from "../../../../Constants";
|
|
import { MessageSendLocation } from "../../../messages/MessageConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import MessageActionCreators from "../../../../actions/MessageActionCreators";
|
|
import MessageParser from "../../../messages/MessageParser";
|
|
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
|
|
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
|
|
import useSafeAreaInsetsKeyboardAware_native from "../../../safe_area/useSafeAreaInsetsKeyboardAware.native";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { TextArea } from "../../../../design/components/TextInput/native/TextArea.native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { getGiftIntentCustomMessagePlaceholder } from "./GiftIntentMessagePlaceholder";
|
|
import GIFPicker from "../../../gif_picker/native/GIFPicker";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import ModalActionCreators from "../../../../actions/ModalActionCreators";
|
|
import useInitialValue from "../../../../hooks/useInitialValue";
|
|
import { getHeaderCloseButton } from "../../../../design/components/Navigator/native/NavigatorHeader.native";
|
|
import { Navigator } from "../../../../design/components/Navigator/native/Navigator.native";
|
|
let useStyles, GiftIntentGifModalBody, c7415_15;
|
|
let _sendGiftIntentGif = function _sendGiftIntentGif() {
|
|
const r8 = async (c26903_0) => {
|
|
let c26903_2;
|
|
c26903_2 = void 0;
|
|
let c30330_0 = c26903_0.channel;
|
|
let c30330_1 = c26903_0.giftIntentType;
|
|
let c30330_2 = c26903_0.text;
|
|
let c30330_3 = c26903_0.gif;
|
|
await void 0;
|
|
let c30330_4 = c30330_2.trim().length > 0;
|
|
if (c30330_4) {
|
|
await MessageActionCreators.sendMessage(c30330_0.id, MessageParser.parse(c30330_0, c30330_2), true, {
|
|
location: MessageSendLocation.GIFTING
|
|
});
|
|
}
|
|
await MessageActionCreators.sendMessage(c30330_0.id, MessageParser.parse(c30330_0, c30330_3.url), true, {
|
|
location: MessageSendLocation.GIFTING
|
|
});
|
|
AnalyticsUtils.track(AnalyticEvents.GIFT_INTENT_MESSAGE_SENT, {
|
|
gift_intent_type: c30330_1,
|
|
is_custom_message: c30330_4,
|
|
location_stack: [AnalyticsLocation.PREMIUM_GIFT_INTENT_CARD]
|
|
});
|
|
};
|
|
_sendGiftIntentGif = r8;
|
|
return r8.apply(this, arguments);
|
|
};
|
|
GiftIntentGifModalBody = function GiftIntentGifModalBody(props) {
|
|
let ref, state, setState;
|
|
const { channelId, giftIntentType, onClose } = props;
|
|
ref = void 0;
|
|
state = void 0;
|
|
setState = void 0;
|
|
const styles = useStyles();
|
|
const insets = useSafeAreaInsetsKeyboardAware_native().insets;
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId));
|
|
ref = useRef(null);
|
|
[state, setState] = useState(null);
|
|
const ref2 = useRef(null);
|
|
const callback2 = useCallback((c26904_0) => {
|
|
setState((prevState) => {
|
|
const src = prevState?.src;
|
|
return src !== c26904_0.src ? c26904_0 : null;
|
|
});
|
|
}, []);
|
|
const callback3 = useCallback(() => {
|
|
if (stateFromStores != null && state != null && state.url.length !== 0) {
|
|
const current = ref.current;
|
|
let text = current == null ? void 0 : current.getText();
|
|
if (text == null) {
|
|
text = "";
|
|
}
|
|
(function sendGiftIntentGif() {
|
|
return _sendGiftIntentGif.apply(this, arguments);
|
|
})({
|
|
channel: stateFromStores,
|
|
giftIntentType,
|
|
text,
|
|
gif: state
|
|
});
|
|
onClose();
|
|
}
|
|
}, [stateFromStores, giftIntentType, state, onClose]);
|
|
const r74 = [<View style={styles.messageContainer}>
|
|
<TextArea ref={ref} accessibilityLabel={intl.string(t.ZV02cV)} placeholder={getGiftIntentCustomMessagePlaceholder()} />
|
|
</View>, , ,];
|
|
let guildId = stateFromStores?.guild_id;
|
|
if (guildId == null) {
|
|
guildId = void 0;
|
|
}
|
|
r74[1] = <View style={styles.pickerContainer}>
|
|
<GIFPicker bottomSheetRef={ref2} channelId={channelId} guildId={guildId} initialQuery={intl.string(t.jrtJi4)} inActionSheet={false} contentHorizontalPadding={Module712.space.PX_16} selectedGifSrc={state?.src} keyboardDismissMode="on-drag" onPressGIF={callback2} />
|
|
</View>;
|
|
r74[2] = <View style={styles.footer}>
|
|
<Button grow variant="primary" text={intl.string(t.TXNS7S)} onPress={callback3} disabled={state == null} />
|
|
<Button grow variant="secondary" text={intl.string(t["ETE/oC"])} onPress={onClose} />
|
|
</View>;
|
|
return <View style={[styles.container, {
|
|
paddingBottom: insets.bottom
|
|
}]}>{r74}</View>;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
|
|
},
|
|
messageContainer: {
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingBottom: Module712.space.PX_8
|
|
},
|
|
pickerContainer: {
|
|
flex: 1
|
|
},
|
|
footer: {
|
|
gap: Module712.space.PX_8,
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingTop: Module712.space.PX_8
|
|
}
|
|
});
|
|
c7415_15 = {
|
|
GIFT_INTENT_GIF: "GIFT_INTENT_GIF"
|
|
};
|
|
export default function GiftIntentGifModal(props) {
|
|
const { channelId: channelId2, giftIntentType: giftIntentType2, onDismiss } = props;
|
|
const callback = useCallback(() => {
|
|
ModalActionCreators.pop();
|
|
if (onDismiss != null) {
|
|
onDismiss();
|
|
}
|
|
}, [onDismiss]);
|
|
return <Navigator initialRouteName={c7415_15.GIFT_INTENT_GIF} screens={useInitialValue(() => {
|
|
const r1 = {};
|
|
r1[c7415_15.GIFT_INTENT_GIF] = {
|
|
title: intl.string(t.PQRuGc),
|
|
headerLeft: getHeaderCloseButton(callback),
|
|
render: () => <GiftIntentGifModalBody channelId={channelId2} giftIntentType={giftIntentType2} onClose={callback} />
|
|
};
|
|
return r1;
|
|
})} />;
|
|
};
|