mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at rm-proxy 80 lines 2.2 kB view raw
1import React from 'react' 2import {StyleSheet, View} from 'react-native' 3import {ChatBskyConvoDefs} from '@atproto/api' 4 5import {atoms as a} from '#/alf' 6import {MessageMenu} from '#/components/dms/MessageMenu' 7import {useMenuControl} from '#/components/Menu' 8 9export function ActionsWrapper({ 10 message, 11 isFromSelf, 12 children, 13}: { 14 message: ChatBskyConvoDefs.MessageView 15 isFromSelf: boolean 16 children: React.ReactNode 17}) { 18 const menuControl = useMenuControl() 19 const viewRef = React.useRef(null) 20 21 const [showActions, setShowActions] = React.useState(false) 22 23 const onMouseEnter = React.useCallback(() => { 24 setShowActions(true) 25 }, []) 26 27 const onMouseLeave = React.useCallback(() => { 28 setShowActions(false) 29 }, []) 30 31 // We need to handle the `onFocus` separately because we want to know if there is a related target (the element 32 // that is losing focus). If there isn't that means the focus is coming from a dropdown that is now closed. 33 const onFocus = React.useCallback<React.FocusEventHandler>(e => { 34 if (e.nativeEvent.relatedTarget == null) return 35 setShowActions(true) 36 }, []) 37 38 return ( 39 <View 40 // @ts-expect-error web only 41 onMouseEnter={onMouseEnter} 42 onMouseLeave={onMouseLeave} 43 onFocus={onFocus} 44 onBlur={onMouseLeave} 45 style={StyleSheet.flatten([a.flex_1, a.flex_row])} 46 ref={viewRef}> 47 {isFromSelf && ( 48 <View 49 style={[ 50 a.mr_xl, 51 a.justify_center, 52 { 53 marginLeft: 'auto', 54 }, 55 ]}> 56 <MessageMenu 57 message={message} 58 control={menuControl} 59 triggerOpacity={showActions || menuControl.isOpen ? 1 : 0} 60 /> 61 </View> 62 )} 63 <View 64 style={{ 65 maxWidth: '80%', 66 }}> 67 {children} 68 </View> 69 {!isFromSelf && ( 70 <View style={[a.flex_row, a.align_center, a.ml_xl]}> 71 <MessageMenu 72 message={message} 73 control={menuControl} 74 triggerOpacity={showActions || menuControl.isOpen ? 1 : 0} 75 /> 76 </View> 77 )} 78 </View> 79 ) 80}