import { CreateAnimation, IonButton, IonCol, IonIcon, IonLabel, IonRow } from '@ionic/react'; import { closeCircleOutline } from 'ionicons/icons'; import { useEffect } from 'react'; import { useState } from 'react'; const ReplyTo = ({ contact, replyToMessage = false, replyToAnimationRef, setReplyToMessage, messageSent }) => { const [cancellingReplyTo, setCancellingReplyTo] = useState(false); useEffect(() => { messageSent && cancelReplyTo(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [messageSent]); const slideAnimation = { property: 'transform', fromValue: 'translateY(100px)', toValue: 'translateY(0px)', }; const replyToAnimation = { duration: 300, direction: !cancellingReplyTo ? 'normal' : 'reverse', iterations: '1', fromTo: [slideAnimation], easing: 'ease-in-out', }; // Cancel the reply-to const cancelReplyTo = async () => { setCancellingReplyTo(true); await replyToAnimationRef.current.animation.play(); setCancellingReplyTo(false); setReplyToMessage(false); }; return ( {contact} {replyToMessage.preview} ); }; export default ReplyTo;