• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CaptainFact / captain-fact-frontend / 19988174573

06 Dec 2025 12:02PM UTC coverage: 5.504% (+0.007%) from 5.497%
19988174573

Pull #1404

github

Betree
minor dependency updates
Pull Request #1404: Dependency updates

43 of 1647 branches covered (2.61%)

Branch coverage included in aggregate %.

192 of 2623 relevant lines covered (7.32%)

0.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/components/Statements/StatementComments.jsx
1
import { Users } from 'lucide-react'
2
import React from 'react'
3
import { withTranslation } from 'react-i18next'
4
import { connect } from 'react-redux'
5

6
import { Badge } from '@/components/ui/badge'
7

8
import { classifyComments } from '../../state/video_debate/comments/selectors'
9
import { CommentsList } from '../Comments/CommentsList'
10
import { Separator } from '../ui/separator'
11
import SpeakerComments from './SpeakerComments'
12

13
@withTranslation('videoDebate')
14
@connect((state, props) => {
15
  const classifiedComments = classifyComments(state, props)
×
16
  return {
×
17
    comments: classifiedComments.regularComments,
18
    speakerComments: classifiedComments.selfComments,
19
    approvingFacts: classifiedComments.approvingFacts,
20
    refutingFacts: classifiedComments.refutingFacts,
21
  }
22
})
23
export default class StatementComments extends React.PureComponent {
24
  render() {
25
    const { speaker, speakerComments, setReplyToComment } = this.props
×
26
    return (
×
27
      <React.Fragment>
28
        <SpeakerComments
29
          setReplyToComment={setReplyToComment}
30
          speaker={speaker}
31
          comments={speakerComments}
32
        />
33
        {this.renderCommunityComments()}
34
      </React.Fragment>
35
    )
36
  }
37

38
  renderCommunityComments() {
39
    const { t, approvingFacts, refutingFacts, comments, speakerComments } = this.props
×
40
    const hasSourcedComments = approvingFacts.size > 0 || refutingFacts.size > 0
×
41
    const hasRegularComments = comments.size > 0
×
42
    const hasCommunityComments = hasSourcedComments || hasRegularComments
×
43
    const hasSpeakerComments = speakerComments.size > 0
×
44

45
    return !hasCommunityComments ? null : (
×
46
      <React.Fragment>
47
        {hasSpeakerComments && (
×
48
          <div className="bg-neutral-100 text-center flex justify-center items-center gap-2 p-1">
49
            <Users size={14} />
50
            {t('community')}
51
          </div>
52
        )}
53
        <Separator />
54
        {hasSourcedComments && this.renderSourcedComments()}
×
55
        {hasRegularComments && this.renderRegularComments()}
×
56
      </React.Fragment>
57
    )
58
  }
59

60
  renderSourcedComments() {
61
    const { approvingFacts, refutingFacts, setReplyToComment } = this.props
×
62
    return (
×
63
      <div className="flex flex-wrap">
64
        <CommentsList
65
          className="w-full md:w-1/2 flex-grow basis-[450px] flex-col"
66
          comments={refutingFacts}
67
          setReplyToComment={setReplyToComment}
68
          header={this.renderCommentsListHeader(
69
            'refute',
70
            'destructive',
71
            this.calculateScore(refutingFacts),
72
          )}
73
          statementID={this.props.statement.id}
74
          commentType="refute"
75
        />
76
        <CommentsList
77
          className="w-full md:w-1/2 flex-grow basis-[450px] flex-col"
78
          comments={approvingFacts}
79
          setReplyToComment={setReplyToComment}
80
          header={this.renderCommentsListHeader(
81
            'approve',
82
            'success',
83
            this.calculateScore(approvingFacts),
84
          )}
85
          statementID={this.props.statement.id}
86
          commentType="approve"
87
        />
88
      </div>
89
    )
90
  }
91

92
  renderRegularComments() {
93
    const { comments, setReplyToComment } = this.props
×
94
    return (
×
95
      <div className="p-3">
96
        <CommentsList
97
          comments={comments}
98
          setReplyToComment={setReplyToComment}
99
          header={this.renderCommentsListHeader('comments')}
100
          className="w-full max-w-full"
101
        />
102
      </div>
103
    )
104
  }
105

106
  renderCommentsListHeader(label, variant, score = null) {
×
107
    return (
×
108
      <div className="flex mt-2 mb-3 items-center">
109
        <Separator className="flex-1 mx-2" />
110
        <div className="flex items-center gap-2 font-bold">
111
          <span>{this.props.t(label)}</span>
112
          {score !== null && (
×
113
            <Badge variant={variant} className="rounded-full px-4">
114
              {score}
115
            </Badge>
116
          )}
117
        </div>
118
        <Separator className="flex-1 mx-2" />
119
      </div>
120
    )
121
  }
122

123
  calculateScore(comments) {
124
    return comments.reduce((score, comment) => {
×
125
      return score + (comment.score > 0 ? comment.score : 0)
×
126
    }, 0)
127
  }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc