import { Components, getRawComponent, registerComponent } from 'meteor/nova:lib'; import React from 'react'; import { withList } from 'meteor/nova:core'; import Posts from 'meteor/nova:posts'; import gql from 'graphql-tag'; import { withCurrentUser } from 'meteor/nova:core'; const PostsList = (props) => { const {results, terms, loading, count, totalCount, loadMore, showHeader = true, networkStatus, currentUser} = props; const loadingMore = networkStatus === 2; if (results && results.length) { const hasMore = totalCount > results.length; return (
{showHeader ? : null}
{results.map(post => )}
{hasMore ? (loadingMore ? : ) : }
) } else if (loading) { return (
{showHeader ? : null}
) } else { return (
{showHeader ? : null}
) } }; PostsList.displayName = "PostsList"; PostsList.propTypes = { results: React.PropTypes.array, terms: React.PropTypes.object, hasMore: React.PropTypes.bool, loading: React.PropTypes.bool, count: React.PropTypes.number, totalCount: React.PropTypes.number, loadMore: React.PropTypes.func, showHeader: React.PropTypes.bool, }; PostsList.fragment = gql` fragment PostsItemFragment on Post { _id title url slug thumbnailUrl baseScore postedAt sticky status categories { # ...minimumCategoryInfo _id name slug } commentCount commenters { # ...avatarUserInfo _id __displayName __emailHash __slug } upvoters { _id } downvoters { _id } upvotes # should be asked only for admins? score # should be asked only for admins? viewCount # should be asked only for admins? clickCount # should be asked only for admins? user { # ...avatarUserInfo _id __displayName __emailHash __slug } userId } `; const options = { collection: Posts, queryName: 'postsListQuery', fragment: PostsList.fragment, }; registerComponent('PostsList', PostsList, withCurrentUser, withList(options));