diff --git a/ts/components/CallingPendingParticipants.dom.tsx b/ts/components/CallingPendingParticipants.dom.tsx index 33104c9513..10c3001a96 100644 --- a/ts/components/CallingPendingParticipants.dom.tsx +++ b/ts/components/CallingPendingParticipants.dom.tsx @@ -6,7 +6,8 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import lodash from 'lodash'; import classNames from 'classnames'; -import { animated, useSpring } from '@react-spring/web'; +import { AnimatePresence, motion } from 'framer-motion'; + import { Avatar, AvatarSize } from './Avatar.dom.js'; import { ContactName } from './conversation/ContactName.dom.js'; import { InContactsIcon } from './InContactsIcon.dom.js'; @@ -22,9 +23,7 @@ import type { ServiceIdString } from '../types/ServiceId.std.js'; import { handleOutsideClick } from '../util/handleOutsideClick.dom.js'; import { Theme } from '../util/theme.std.js'; import { ConfirmationDialog } from './ConfirmationDialog.dom.js'; -import { usePrevious } from '../hooks/usePrevious.std.js'; import { useReducedMotion } from '../hooks/useReducedMotion.dom.js'; -import { drop } from '../util/drop.std.js'; const { noop } = lodash; @@ -58,25 +57,7 @@ export function CallingPendingParticipants({ }: PropsType): React.JSX.Element | null { const reducedMotion = useReducedMotion(); - // eslint-disable-next-line react-hooks/exhaustive-deps - const [opacitySpringProps, opacitySpringApi] = useSpring( - { - from: { opacity: 0 }, - to: { opacity: 1 }, - config: { clamp: true, friction: 22, tension: 360 }, - immediate: reducedMotion, - }, - [] - ); - - // We show the first pending participant. Save this participant, so if all requests - // are resolved then we can keep showing the participant while fading out. - const lastParticipantRef = React.useRef(); - lastParticipantRef.current = participants[0] ?? lastParticipantRef.current; const participantCount = participants.length; - const prevParticipantCount = usePrevious(participantCount, participantCount); - - const [isVisible, setIsVisible] = useState(participantCount > 0); const [isExpanded, setIsExpanded] = useState(defaultIsExpanded ?? false); const [confirmDialogState, setConfirmDialogState] = useState(ConfirmDialogState.None); @@ -194,32 +175,6 @@ export function CallingPendingParticipants({ ); }, [isExpanded, handleHideAllRequests]); - useEffect(() => { - if (participantCount > prevParticipantCount) { - setIsVisible(true); - opacitySpringApi.stop(); - drop(Promise.all(opacitySpringApi.start({ opacity: 1 }))); - } else if (participantCount === 0) { - opacitySpringApi.stop(); - drop( - Promise.all( - opacitySpringApi.start({ - to: { opacity: 0 }, - onRest: () => { - if (!participantCount) { - setIsVisible(false); - } - }, - }) - ) - ); - } - }, [opacitySpringApi, participantCount, prevParticipantCount, setIsVisible]); - - if (!isVisible) { - return null; - } - if (confirmDialogState === ConfirmDialogState.ApproveAll) { return ( 0; + const participant = participants[0]; const isExpandable = participantCount > 1; - return ( - -
- + {renderApprovalButtons(participant, participantCount > 0)}
- - {renderApprovalButtons(participant, participantCount > 0)} - - {isExpandable && ( -
- -
- )} -
+ {isExpandable && ( +
+ +
+ )} + + ) : null} + ); } diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index f8f6f84967..91dbd22740 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -1028,14 +1028,6 @@ "updated": "2024-06-28T01:22:22.509Z", "reasonDetail": "For outside click handling" }, - { - "rule": "React-useRef", - "path": "ts/components/CallingPendingParticipants.dom.tsx", - "line": " const lastParticipantRef = React.useRef();", - "reasonCategory": "usageTrusted", - "updated": "2024-09-20T02:11:27.851Z", - "reasonDetail": "For fading out, to keep showing the last known participant" - }, { "rule": "React-useRef", "path": "ts/components/CallingPip.dom.tsx",