@@ -64,11 +64,19 @@ const DotFormattedDate = ({ date, className, locale }) => {
6464 </ FormattedDate >
6565 ) ;
6666} ;
67+
68+ // I will remove it once I update the useLiveData function of VLT.
69+ function useLiveData ( field ) {
70+ const formData = useSelector ( ( state ) => state . form . global ?. [ field ] ) ;
71+ return formData ;
72+ }
6773const Rating = ( props ) => {
6874 const location = useLocation ( ) ;
6975 const content = useSelector ( ( state ) => state . content . data ) ;
7076 const pathname = location . pathname ;
71- const allow_discussion = content ?. allow_discussion ;
77+ const allow_discussion =
78+ useLiveData ( 'allow_discussion' ) || content ?. allow_discussion ;
79+ const enable_likes = useLiveData ( 'enable_likes' ) || content ?. enable_likes ;
7280 const votes = content ?. votes ;
7381 const loggedIn = useSelector ( ( state ) => state . userSession . token , shallowEqual )
7482 ? true
@@ -136,37 +144,39 @@ const Rating = (props) => {
136144 < Container className = "content-engagement" >
137145 < div className = "engagement-container" >
138146 < div className = "engagement-section" >
139- < div className = { cx ( 'likes-section' , { anon : ! loggedIn } ) } >
140- { loggedIn ? (
141- < Button aria-label = "liked" onClick = { ( ) => onLike ( ) } >
142- < div className = "icon-wrapper" >
143- { liked ? (
144- < Icon
145- name = { thumbsFilledSVG }
146- size = "33px"
147- className = "liked"
148- />
149- ) : (
147+ { enable_likes && (
148+ < div className = { cx ( 'likes-section' , { anon : ! loggedIn } ) } >
149+ { loggedIn ? (
150+ < Button aria-label = "liked" onClick = { ( ) => onLike ( ) } >
151+ < div className = "icon-wrapper" >
152+ { liked ? (
153+ < Icon
154+ name = { thumbsFilledSVG }
155+ size = "33px"
156+ className = "liked"
157+ />
158+ ) : (
159+ < Icon name = { thumbsSVG } size = "33px" />
160+ ) }
161+ </ div >
162+ </ Button >
163+ ) : (
164+ < Link
165+ aria-label = "unliked"
166+ to = { `${ pathname } /login` }
167+ title = { intl . formatMessage ( messages . loginToLike ) }
168+ >
169+ < div className = "icon-wrapper" >
150170 < Icon name = { thumbsSVG } size = "33px" />
151- ) }
152- </ div >
153- </ Button >
154- ) : (
155- < Link
156- aria-label = "unliked"
157- to = { `${ pathname } /login` }
158- title = { intl . formatMessage ( messages . loginToLike ) }
159- >
160- < div className = "icon-wrapper" >
161- < Icon name = { thumbsSVG } size = "33px" />
162- </ div >
163- </ Link >
164- ) }
165- < div className = "likes-count" >
166- < span > ({ amount } )</ span >
171+ </ div >
172+ </ Link >
173+ ) }
174+ < div className = "likes-count" >
175+ < span > ({ amount } )</ span >
176+ </ div >
167177 </ div >
168- </ div >
169- { ( allow_discussion || comment_count >= 0 ) && (
178+ ) }
179+ { ( allow_discussion || comment_count > 0 ) && (
170180 < div className = "comments-section" >
171181 < Button aria-label = "comments" >
172182 < div className = "icon-wrapper" >
0 commit comments