diff options
Diffstat (limited to 'vnext/src')
-rw-r--r-- | vnext/src/components/Thread.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index 23654d86..b0e73b40 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -86,7 +86,7 @@ export default class Thread extends React.Component { msg.mid ? ( <Message data={msg} visitor={this.props.visitor}> {this.state.active === (msg.rid || 0) && <MessageInput data={msg} onSend={this.postComment}>Write a comment...</MessageInput>} - <Recommendations src={msg.recommendations || []} /> + <Recommendations forMessage={msg} /> </Message> ) : ( <Spinner /> @@ -170,14 +170,18 @@ Thread.propTypes = { visitor: UserType.isRequired }; -function Recommendations({src, ...rest}) { - return src.length > 0 && ( - <div className="msg-recomms">{`Recommended by (${src.length}): `} +function Recommendations({forMessage, ...rest}) { + const { likes, recommendations } = forMessage; + return recommendations && recommendations.length > 0 && ( + <div className="msg-recomms">{'Recommended by '} { - src.map(it => ( + recommendations.map(it => ( <Link key={it} to={`/${it}/`}>{it}</Link> )).reduce((prev, curr) => [prev, ', ', curr]) } + { + likes > recommendations.length && (<span> and {likes - recommendations.length} others</span>) + } </div> ) || null; } |