Don't open comment w/o new bet

This commit is contained in:
Ian Philips 2022-06-09 08:53:01 -06:00
parent 65bc0f0f86
commit bdb3bbd960

View File

@ -69,9 +69,21 @@ export function FeedAnswerCommentGroup(props: {
user, user,
answer.number.toString() answer.number.toString()
) )
const [usersMostRecentBetTimeAtLoad] = useState( const [usersMostRecentBetTimeAtLoad, setUsersMostRecentBetTimeAtLoad] =
mostRecentCommentableBet?.createdTime ?? 0 useState<number | undefined>(
) !user ? undefined : mostRecentCommentableBet?.createdTime ?? 0
)
useEffect(() => {
if (user && usersMostRecentBetTimeAtLoad === undefined)
setUsersMostRecentBetTimeAtLoad(
mostRecentCommentableBet?.createdTime ?? 0
)
}, [
mostRecentCommentableBet?.createdTime,
user,
usersMostRecentBetTimeAtLoad,
])
const scrollAndOpenReplyInput = useEvent( const scrollAndOpenReplyInput = useEvent(
(comment?: Comment, answer?: Answer) => { (comment?: Comment, answer?: Answer) => {
@ -84,6 +96,7 @@ export function FeedAnswerCommentGroup(props: {
useEffect(() => { useEffect(() => {
if ( if (
mostRecentCommentableBet && mostRecentCommentableBet &&
usersMostRecentBetTimeAtLoad !== undefined &&
mostRecentCommentableBet.createdTime > usersMostRecentBetTimeAtLoad && mostRecentCommentableBet.createdTime > usersMostRecentBetTimeAtLoad &&
!showReply !showReply
) )