Skip to content

Conversation

@chauduong1192
Copy link
Contributor

No description provided.

@chauduong1192 chauduong1192 added this to the 1.0 milestone Jan 14, 2018
@chauduong1192 chauduong1192 self-assigned this Jan 14, 2018
};

export {
// eslint-disable-next-line import/prefer-default-export
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this line anymore when exporting multiple variables


const getHomePosts = state => sortBy => (
sort(Object.values(state.posts.home), sortBy)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpler way

const getHomePosts = state => sortBy => sort(Object.values(state.posts.home), sortBy);

do the same for the others

sort(Object.values(state.posts.saved), sortBy)
);

const getSourcePosts = state => (sortBy, source) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the source param is required but the sortBy is optional, so we should put the source to the front

);

const getSourcePosts = state => (sortBy, source) => (
state.posts.sources[source] ? sort(state.posts.sources, sortBy, source) : 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return an empty array instead of 0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and why don't we just pass state.posts.sources[source] instead of sort(state.posts.sources, ... !?

the solution should be sort(state.posts.sources[source] || [], sortBy)

and refactoring the sort function is needed for this change. The sort function is just for sorting an inputted posts array, so only 2 params (posts, sortBy) are required.

const title = source ? source.title : 'Explore';

return <Home title={title} source={source} {...rest} />;
return <Home title={title} source={source} {...rest} match={match} />;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to pass match to Home props anymore because I extracted the source id (source) from it already in

const source = match.params.source ? getSource(match.params.source) : undefined;

return <Home title={title} source={source} {...rest} />;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you just need to change source to sourceId

const sourceId = match.params.sourceId ? getSource(match.params.sourceId) : undefined;

return <Home title={title} sourceId={sourceId} {...rest} />;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants