Skip to content

Commit

Permalink
Add error message display for public feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushiknishchay committed Apr 2, 2018
1 parent ed2f19a commit 362640a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import RepoList from './RepoList';
import { getFeeds, getPublicFeeds, getRepos } from '../service/httpFetch';
import FeedList from './FeedsList';
// import { sentryExtra } from '../lib/utils';
import { USER_FEEDS_ERROR, USER_REPO_ERROR } from '../lib/constants';
import { PUBLIC_FEEDS_ERROR, USER_FEEDS_ERROR, USER_REPO_ERROR } from '../lib/constants';

class Home extends Component {
constructor(props) {
Expand Down Expand Up @@ -97,8 +97,6 @@ class Home extends Component {
this.setState({
isError: USER_FEEDS_ERROR,
});
}).catch((err) => {
console.log(err);
});
}

Expand All @@ -111,7 +109,9 @@ class Home extends Component {
fetchedFeeds: false,
});
}).catch((err) => {
console.log(err);
this.setState({
isError: PUBLIC_FEEDS_ERROR,
});
});
}
}
Expand All @@ -134,15 +134,17 @@ class Home extends Component {
const { repoList, feedList } = this.state;
const feedError = this.state.isError === USER_FEEDS_ERROR;
const repoError = this.state.isError === USER_REPO_ERROR;
const publicFeedError = this.state.isError === PUBLIC_FEEDS_ERROR;

return (
<div className="row">
<div className="row" ref={(re) => { this.homeRef = re; }}>
<div className="col-lg-12">
<br />
{data && <Profile data={data} />}

<br />
{ feedError && <div><h1>Please try again.</h1> <p>Can not fetch feeds.</p></div> }
{ feedError && <div className="error"><h1>Please try again.</h1> <p>Can not fetch feeds.</p></div> }
{ publicFeedError && <div className="error"><h1>Please try again.</h1> <p>Can not fetch feeds.</p></div> }

<FeedList feeds={feedList} />

Expand Down Expand Up @@ -172,7 +174,7 @@ class Home extends Component {
</div>
}

{ repoError && <div><h1>Please try again.</h1> <p>Can not repository list.</p></div> }
{ repoError && <div className="error"><h1>Please try again.</h1> <p>Can not repository list.</p></div> }

<RepoList data={repoList} />
</div>
Expand Down

0 comments on commit 362640a

Please sign in to comment.