import React from 'react' import {StyleSheet, View} from 'react-native' import {ChatBskyConvoDefs} from '@atproto/api' import {atoms as a} from '#/alf' import {MessageMenu} from '#/components/dms/MessageMenu' import {useMenuControl} from '#/components/Menu' export function ActionsWrapper({ message, isFromSelf, children, }: { message: ChatBskyConvoDefs.MessageView isFromSelf: boolean children: React.ReactNode }) { const menuControl = useMenuControl() const viewRef = React.useRef(null) const [showActions, setShowActions] = React.useState(false) const onMouseEnter = React.useCallback(() => { setShowActions(true) }, []) const onMouseLeave = React.useCallback(() => { setShowActions(false) }, []) // We need to handle the `onFocus` separately because we want to know if there is a related target (the element // that is losing focus). If there isn't that means the focus is coming from a dropdown that is now closed. const onFocus = React.useCallback(e => { if (e.nativeEvent.relatedTarget == null) return setShowActions(true) }, []) return ( {isFromSelf && ( )} {children} {!isFromSelf && ( )} ) }