1
+ import { useMobile } from "@follow/components/hooks/useMobile.js"
1
2
import { ActionButton } from "@follow/components/ui/button/index.js"
2
3
import { Skeleton } from "@follow/components/ui/skeleton/index.jsx"
3
4
import { cn } from "@follow/utils/utils"
4
5
import { atom } from "jotai"
5
- import { useLayoutEffect , useRef , useState } from "react"
6
+ import { useLayoutEffect , useMemo , useRef , useState } from "react"
6
7
7
8
import { RelativeTime } from "~/components/ui/datetime"
8
9
import { Media } from "~/components/ui/media"
@@ -34,6 +35,17 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
34
35
35
36
const ref = useRef < HTMLDivElement > ( null )
36
37
const [ showAction , setShowAction ] = useState ( false )
38
+
39
+ const isMobile = useMobile ( )
40
+ const handleMouseEnter = useMemo ( ( ) => {
41
+ if ( isMobile ) return
42
+ return ( ) => setShowAction ( true )
43
+ } , [ isMobile ] )
44
+ const handleMouseLeave = useMemo ( ( ) => {
45
+ if ( isMobile ) return
46
+ return ( ) => setShowAction ( false )
47
+ } , [ isMobile ] )
48
+
37
49
useLayoutEffect ( ( ) => {
38
50
if ( ref . current ) {
39
51
jotaiStore . set ( socialMediaContentWidthAtom , ref . current . offsetWidth )
@@ -50,8 +62,8 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
50
62
51
63
return (
52
64
< div
53
- onMouseEnter = { ( ) => setShowAction ( true ) }
54
- onMouseLeave = { ( ) => setShowAction ( false ) }
65
+ onMouseEnter = { handleMouseEnter }
66
+ onMouseLeave = { handleMouseLeave }
55
67
className = { cn (
56
68
"relative flex px-2 py-6 lg:px-8" ,
57
69
"group" ,
0 commit comments