Skip to content

Commit

Permalink
Force update - Merge branch with latest changes from new-design
Browse files Browse the repository at this point in the history
  • Loading branch information
jm90m committed Oct 27, 2017
1 parent 510ac74 commit fb0d77e
Showing 1 changed file with 17 additions and 56 deletions.
73 changes: 17 additions & 56 deletions src/app/Sidebar/RightSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Route, Switch } from 'react-router-dom';
import people from '../../helpers/people';
import {
getIsAuthenticated,
getAuthenticatedUser,
getIsAuthFetching,
getRecommendations,
} from '../../reducers';
import { updateRecommendations } from '../../user/userActions';
import {
getFollowingList,
} from '../../reducers';
import InterestingPeople from '../../components/Sidebar/InterestingPeople';
import InterestingPeopleWithAPI from '../../components/Sidebar/InterestingPeopleWithAPI';
import PostRecommendation from '../../components/Sidebar/PostRecommendation';
import StartNow from '../../components/Sidebar/StartNow';
import SignUp from '../../components/Sidebar/SignUp';
import PostRecommendation from '../../components/Sidebar/PostRecommendation';

@connect(
state => ({
authenticated: getIsAuthenticated(state),
authenticatedUser: getAuthenticatedUser(state),
Expand All @@ -29,18 +26,11 @@ import SignUp from '../../components/Sidebar/SignUp';
updateRecommendations,
},
)
@connect(state => ({
authenticated: getIsAuthenticated(state),
authenticatedUser: getAuthenticatedUser(state),
authFetching: getIsAuthFetching(state),
followingList: getFollowingList(state),
export default class RightSidebar extends React.Component {
static propTypes = {
authenticated: PropTypes.bool.isRequired,
authenticatedUser: PropTypes.shape().isRequired,
isAuthFetching: PropTypes.bool.isRequired,
authFetching: PropTypes.bool.isRequired,
followingList: PropTypes.arrayOf(PropTypes.string).isRequired,
showPostRecommendation: PropTypes.bool,
recommendations: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string })).isRequired,
updateRecommendations: PropTypes.func,
Expand All @@ -49,70 +39,41 @@ export default class RightSidebar extends React.Component {
static defaultProps = {
showPostRecommendation: false,
updateRecommendations: () => {},
};

handleInterestingPeopleRefresh = () => this.props.updateRecommendations();
=======
constructor(props) {
super(props);
this.state = {
randomPeople: this.getRandomPeople(),
};
}

getRandomPeople = () =>
people
.reduce((res, item) => {
if (!this.props.followingList.includes(item)) {
res.push({ name: item });
}
return res;
}, [])
.sort(() => 0.5 - Math.random())
.slice(0, 5);

handleRefreshInterestingPeople = () =>
this.setState({
randomPeople: this.getRandomPeople(),
});

render() {
const { authenticated, authenticatedUser, authFetching, showPostRecommendation } = this.props;
const { authenticated, authenticatedUser, showPostRecommendation, isAuthFetching } = this.props;

return (
<div>
{!authenticated && <SignUp />}
<Switch>
<Route
exact
path="/@:name"
component={() =>
authenticated &&
<InterestingPeopleWithAPI
authenticatedUser={authenticatedUser}
authFetching={isAuthFetching}
/>}
/>
<Route
path="/"
render={() => (
<div>
{authenticatedUser.last_root_post === '1970-01-01T00:00:00' && <StartNow />}
<<<<<<< 3aa813af336a1228402490e4ca53a76fb88b6ca9
<InterestingPeople
users={this.props.recommendations}
onRefresh={this.handleInterestingPeopleRefresh}
/>
=======
{authenticated &&
<InterestingPeople
users={this.state.randomPeople}
onRefresh={this.handleRefreshInterestingPeople}
users={this.props.recommendations}
onRefresh={this.handleInterestingPeopleRefresh}
/>}
>>>>>>> Hide Interesting People for unauthenticated users
</div>
)}
/>
<Route
path="/@:name"
component={() =>
authenticated &&
<InterestingPeopleWithAPI
authenticatedUser={authenticatedUser}
authFetching={authFetching}
/>}
/>
</Switch>
{showPostRecommendation && <PostRecommendation isAuthFetching={authFetching} />}
{showPostRecommendation && <PostRecommendation isAuthFetching={isAuthFetching} />}
</div>
);
}
Expand Down

0 comments on commit fb0d77e

Please sign in to comment.