mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-22 19:05:56 -04:00
Clean up activity item rendering logic
This commit is contained in:
parent
5865b6d619
commit
d6de9ffe37
1 changed files with 21 additions and 19 deletions
|
@ -36,25 +36,27 @@ var Activity = React.createClass({
|
|||
{this.props.items && this.props.items.length > 0 ? [
|
||||
<ul>
|
||||
{this.props.items.map(function (item) {
|
||||
var actorProfileUrl = '/users/' + item.actor.username + '/';
|
||||
var actionDate = new Date(item.datetime_created + 'Z');
|
||||
var activityMessageHTML = '<a href=' + actorProfileUrl + '>' +
|
||||
item.actor.username + '</a>' + item.message;
|
||||
if (item.message.replace(/\s/g, '')) {
|
||||
return (
|
||||
<li key={item.pk}>
|
||||
<a href={actorProfileUrl}>
|
||||
<img src={item.actor.thumbnail_url} width="34" height="34" />
|
||||
<p dangerouslySetInnerHTML={{__html: activityMessageHTML}}></p>
|
||||
<p>
|
||||
<span className="stamp">
|
||||
<FormattedRelative value={actionDate} />
|
||||
</span>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
if (item.message.replace(/\s/g, '')) {
|
||||
var actorProfileUrl = '/users/' + item.actor.username + '/';
|
||||
var actionDate = new Date(item.datetime_created + 'Z');
|
||||
var activityMessageHTML = (
|
||||
'<a href=' + actorProfileUrl + '>' + item.actor.username + '</a>' +
|
||||
item.message
|
||||
);
|
||||
return (
|
||||
<li key={item.pk}>
|
||||
<a href={actorProfileUrl}>
|
||||
<img src={item.actor.thumbnail_url} width="34" height="34" />
|
||||
<p dangerouslySetInnerHTML={{__html: activityMessageHTML}}></p>
|
||||
<p>
|
||||
<span className="stamp">
|
||||
<FormattedRelative value={actionDate} />
|
||||
</span>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</ul>
|
||||
] : [
|
||||
|
|
Loading…
Reference in a new issue