Skip to content

Commit

Permalink
Better null handling for authors
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Feb 9, 2018
1 parent 572a702 commit 1265e2f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions components/ReplyConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ export default class ReplyConnection extends React.PureComponent {
renderAuthor = () => {
const { replyConnection } = this.props;
const replyVersion = replyConnection.getIn(['reply', 'versions', 0]);
const connectionAuthor = replyConnection.get('user');
const replyAuthor = replyVersion.get('user');
const connectionAuthor = replyConnection.get('user') || Map();
const replyAuthor = replyVersion.get('user') || Map();

const connectionAuthorName = connectionAuthor
? connectionAuthor.get('name')
: '有人';
const connectionAuthorName = connectionAuthor.get('name') || '有人';

if (replyAuthor && connectionAuthor.get('id') !== replyAuthor.get('id')) {
if (
replyAuthor.get('name') &&
connectionAuthor.get('id') !== replyAuthor.get('id')
) {
return (
<span>
{connectionAuthorName}
Expand Down

0 comments on commit 1265e2f

Please sign in to comment.