mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
use networkStatus === 1 instead of loading prop from apollo-client hoc
This commit is contained in:
parent
78ba0e8530
commit
4ca3cab7ce
3 changed files with 14 additions and 16 deletions
|
@ -1,30 +1,27 @@
|
|||
import React from 'react';
|
||||
import {FormattedMessage } from 'react-intl';
|
||||
import { ModalTrigger, withList } from 'meteor/nova:core';
|
||||
import { withCurrentUser, Components, registerComponent, Utils } from 'meteor/nova:core';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { ModalTrigger, withList, withCurrentUser, Components, registerComponent, Utils } from 'meteor/nova:core';
|
||||
import Comments from 'meteor/nova:comments';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const PostsCommentsThread = (props, context) => {
|
||||
|
||||
const {loading, terms: { postId }, results} = props;
|
||||
|
||||
const {loading, terms: { postId }, results, totalCount} = props;
|
||||
|
||||
if (loading) {
|
||||
|
||||
return <div className="posts-comments-thread"><Components.Loading/></div>
|
||||
|
||||
} else {
|
||||
|
||||
const commentCount = results.length;
|
||||
|
||||
|
||||
const resultsClone = _.map(results, _.clone); // we don't want to modify the objects we got from props
|
||||
const nestedComments = Utils.unflatten(resultsClone, '_id', 'parentCommentId');
|
||||
|
||||
return (
|
||||
<div className="posts-comments-thread">
|
||||
<h4 className="posts-comments-thread-title"><FormattedMessage id="comments.comments"/></h4>
|
||||
<Components.CommentsList comments={nestedComments} commentCount={commentCount}/>
|
||||
{ props.currentUser ?
|
||||
<Components.CommentsList comments={nestedComments} commentCount={totalCount}/>
|
||||
{!!props.currentUser ?
|
||||
<div className="posts-comments-thread-new">
|
||||
<h4><FormattedMessage id="comments.new"/></h4>
|
||||
<Components.CommentsNewForm
|
||||
|
@ -74,4 +71,4 @@ const options = {
|
|||
fragment: PostsCommentsThread.fragment,
|
||||
};
|
||||
|
||||
registerComponent('PostsCommentsThread', PostsCommentsThread, withCurrentUser, withList(options));
|
||||
registerComponent('PostsCommentsThread', PostsCommentsThread, withList(options), withCurrentUser);
|
||||
|
|
|
@ -25,11 +25,11 @@ export default function withDocument (options) {
|
|||
props: returnedProps => {
|
||||
const { ownProps, data } = returnedProps;
|
||||
return {
|
||||
loading: data.loading,
|
||||
loading: data.networkStatus === 1,
|
||||
document: data[singleResolverName],
|
||||
fragmentName,
|
||||
fragment,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,15 +149,16 @@ export default function withList (options) {
|
|||
},
|
||||
props(props) {
|
||||
|
||||
const loading = props.data.loading,
|
||||
fetchMore = props.data.fetchMore,
|
||||
const fetchMore = props.data.fetchMore,
|
||||
refetch = props.data.refetch,
|
||||
results = props.data[listResolverName],
|
||||
totalCount = props.data[totalResolverName],
|
||||
networkStatus = props.data.networkStatus;
|
||||
|
||||
return {
|
||||
loading,
|
||||
// see https://github.com/apollostack/apollo-client/blob/master/src/queries/store.ts#L28-L36
|
||||
// note: loading will propably change soon https://github.com/apollostack/apollo-client/issues/831
|
||||
loading: networkStatus === 1, // networkStatus = 1 <=> the graphql container is loading
|
||||
results,
|
||||
totalCount,
|
||||
refetch,
|
||||
|
|
Loading…
Add table
Reference in a new issue