@@ -3,8 +3,6 @@ import { Transition } from "@headlessui/react";
33import classNames from "classnames" ;
44import { useCallback , useEffect , useState } from "react" ;
55import { httpGet , httpPost } from "../utils/http" ;
6- import { useVisitorAuth } from "../hooks/useVisitorAuth" ;
7- import VisitorAuthModal from "./visitor-auth-modal" ;
86
97const ReactionsCounter = ( {
108 postId,
@@ -13,23 +11,16 @@ const ReactionsCounter = ({
1311 floating,
1412 optimisticUpdate,
1513 setShowPicker,
16- onAuthRequired,
1714} : {
1815 postId : string ;
1916 aggregate : IReactions ;
2017 user : IReactions ;
2118 floating : boolean ;
2219 optimisticUpdate ?: ( reaction : string , status : boolean ) => void ;
2320 setShowPicker ?: ( v : boolean ) => void ;
24- onAuthRequired ?: ( ) => void ;
2521} ) => {
2622 const doReact = useCallback (
2723 ( reaction : string ) => {
28- if ( onAuthRequired ) {
29- onAuthRequired ( ) ;
30- return ;
31- }
32-
3324 if ( setShowPicker ) {
3425 setShowPicker ( false ) ;
3526 }
@@ -47,7 +38,7 @@ const ReactionsCounter = ({
4738 } ,
4839 } ) ;
4940 } ,
50- [ postId , setShowPicker , user , optimisticUpdate , onAuthRequired ]
41+ [ postId , setShowPicker , user , optimisticUpdate ]
5142 ) ;
5243
5344 return (
@@ -220,9 +211,7 @@ const ReactionsCounter = ({
220211
221212export default function Reactions ( props : any ) {
222213 const { post } = props ;
223- const { visitor } = useVisitorAuth ( ) ;
224214 const [ showPicker , setShowPicker ] = useState ( false ) ;
225- const [ isAuthModalOpen , setIsAuthModalOpen ] = useState ( false ) ;
226215 const [ reactions , setReactions ] = useState < IReactions > ( { } ) ;
227216 const [ userReaction , setUserReaction ] = useState < IReactions > ( { } ) ;
228217
@@ -269,20 +258,12 @@ export default function Reactions(props: any) {
269258 updateReactions ( ) ;
270259 } , [ updateReactions ] ) ;
271260
272- const handleReactionClick = useCallback ( ( ) => {
273- if ( ! visitor ) {
274- setIsAuthModalOpen ( true ) ;
275- return ;
276- }
277- setShowPicker ( ( v ) => ! v ) ;
278- } , [ visitor ] ) ;
279-
280261 return (
281262 < div className = "flex" >
282263 < div className = "relative flex items-center" >
283264 < button
284265 className = "text-sm p-1.5 my-2 border border-gray-300 dark:border-gray-700 rounded-full bg-white dark:bg-gray-800 text-gray-500 hover:text-gray-700 dark:text-gray-300 dark:hover:text-gray-200"
285- onClick = { handleReactionClick }
266+ onClick = { ( ) => setShowPicker ( ( v ) => ! v ) }
286267 >
287268 < svg
288269 className = " w-4 h-4"
@@ -332,15 +313,9 @@ export default function Reactions(props: any) {
332313 user = { userReaction }
333314 optimisticUpdate = { optimisticUpdate }
334315 setShowPicker = { setShowPicker }
335- onAuthRequired = { ! visitor ? ( ) => setIsAuthModalOpen ( true ) : undefined }
336316 floating = { false }
337317 />
338318 ) : null }
339-
340- < VisitorAuthModal
341- isOpen = { isAuthModalOpen }
342- onClose = { ( ) => setIsAuthModalOpen ( false ) }
343- />
344319 </ div >
345320 ) ;
346321}
0 commit comments