Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
[#838] Fix user name in user page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
voidxnull committed Jul 16, 2017
1 parent 153707a commit f565b6c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/pages/user-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { addUser } from '../actions/users';
import { setPostsToFavouritesRiver } from '../actions/river';
import { ActionsTrigger } from '../triggers';
import { createSelector, currentUserSelector } from '../selectors';
import { getName } from '../utils/user';

import NotFound from './not-found';
import BaseUserPageWithoutHeader from './base/user-without_header';
Expand Down Expand Up @@ -117,7 +118,7 @@ class UserFavoritesPage extends React.Component {
triggers={triggers}
user={user}
>
<Helmet title={`Favorites of ${user.get('fullName')} on `} />
<Helmet title={`Favorites of ${getName(user)} on `} />
<River
comments={comments}
current_user={current_user}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/user-likes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { addUser } from '../actions/users';
import { setPostsToLikesRiver } from '../actions/river';
import { ActionsTrigger } from '../triggers';
import { createSelector, currentUserSelector } from '../selectors';
import { getName } from '../utils/user';

import NotFound from './not-found';
import BaseUserPageWithoutHeader from './base/user-without_header';
Expand Down Expand Up @@ -116,7 +117,7 @@ class UserLikesPage extends Component {
triggers={triggers}
user={user}
>
<Helmet title={`Likes of ${user.get('fullName')} on `} />
<Helmet title={`Likes of ${getName(user)} on `} />
<River
comments={comments}
current_user={current_user}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { addUser } from '../actions/users';
import { setUserPosts } from '../actions/posts';
import { ActionsTrigger } from '../triggers';
import { createSelector, currentUserSelector } from '../selectors';
import { getName } from '../utils/user';

import NotFound from './not-found';
import BaseUserPage from './base/user';
Expand Down Expand Up @@ -135,7 +136,7 @@ class UserPage extends React.Component {
triggers={triggers}
user={user}
>
<Helmet title={`Posts of ${user.get('fullName')} on `} />
<Helmet title={`Posts of ${getName(user)} on `} />
<River
comments={comments}
current_user={current_user}
Expand Down
7 changes: 4 additions & 3 deletions src/utils/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
// @flow
import { fromJS, List } from 'immutable';
import type { Map } from 'immutable';
import { isEmpty, isString } from 'lodash';

export function getName(user: Map<string, string>) {
const fullName = user.get('fullName');
if (fullName === ' ') {
return user.get('username');
if (isString(fullName) && !isEmpty(fullName.trim())) {
return fullName;
}

return fullName;
return user.get('username');
}

const SERVICES_SEQ = [
Expand Down

0 comments on commit f565b6c

Please sign in to comment.