feat: 修复评论数量问题

This commit is contained in:
2025-09-24 15:33:01 +08:00
parent e89ed5943c
commit ea2f4bb905
3 changed files with 18 additions and 6 deletions

View File

@@ -247,6 +247,7 @@ function isFull(counts) {
// 底部操作栏
function StickyButton(props) {
const { handleShare, handleJoinGame, detail, onStatusChange, handleAddComment, getCommentCount } = props;
const [commentCount, setCommentCount] = useState(0)
const ntrpRef = useRef(null);
const { id, price, user_action_status, match_status, start_time, end_time, is_organizer } =
detail || {};
@@ -258,6 +259,12 @@ function StickyButton(props) {
ntrpRef?.current?.show();
}
useEffect(() => {
getCommentCount?.((count) => {
setCommentCount(count)
})
}, [getCommentCount])
function generateTextAndAction(
user_action_status: null | { [key: string]: boolean }
): undefined | { text: string | React.FC; action?: () => void; available?: boolean } {
@@ -370,8 +377,6 @@ function StickyButton(props) {
};
}
const commentCount = getCommentCount()
return (
<>
<View className="sticky-bottom-bar">
@@ -1224,7 +1229,7 @@ function Index() {
detail={detail}
onStatusChange={onStatusChange}
handleAddComment={() => { commentRef.current && commentRef.current.addComment() }}
getCommentCount={() => commentRef.current && commentRef.current.getCommentCount()}
getCommentCount={commentRef.current && commentRef.current.getCommentCount}
/>
{/* share popup */}
<SharePopup