2016-10-28 15:45:43 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
|
|
|
import React from 'react';
|
|
|
|
import Posts from "meteor/nova:posts";
|
2016-11-02 19:04:34 +09:00
|
|
|
import Events from "meteor/nova:events";
|
2016-10-28 15:45:43 +09:00
|
|
|
|
|
|
|
import { graphql } from 'react-apollo';
|
|
|
|
import gql from 'graphql-tag';
|
2016-11-10 10:11:43 +09:00
|
|
|
import { composeWithTracker } from 'react-komposer';
|
|
|
|
|
|
|
|
const currentUserComposer = (props, onData) => {
|
2016-11-10 17:26:55 +09:00
|
|
|
|
|
|
|
const userSubscription = Meteor.subscribe('users.current');
|
|
|
|
|
2016-11-10 10:11:43 +09:00
|
|
|
const data = {
|
2016-11-10 17:26:55 +09:00
|
|
|
currentUser: Meteor.user(),
|
|
|
|
userLoading: !userSubscription.ready()
|
2016-11-10 10:11:43 +09:00
|
|
|
}
|
2016-11-10 17:26:55 +09:00
|
|
|
|
2016-11-10 10:11:43 +09:00
|
|
|
onData(null, data);
|
|
|
|
}
|
2016-10-28 15:45:43 +09:00
|
|
|
|
|
|
|
const AppContainer = (props, context) => {
|
|
|
|
|
2016-11-10 10:11:43 +09:00
|
|
|
const {loading, refetch, /*currentUser,*/ categories} = props.data;
|
2016-10-29 14:18:16 +09:00
|
|
|
|
2016-11-10 17:26:55 +09:00
|
|
|
const { currentUser, userLoading } = props;
|
2016-11-10 10:11:43 +09:00
|
|
|
|
2016-10-28 15:45:43 +09:00
|
|
|
return <Telescope.components.App
|
2016-11-10 17:26:55 +09:00
|
|
|
loading={loading || userLoading}
|
2016-10-29 14:18:16 +09:00
|
|
|
currentUser={currentUser}
|
|
|
|
categories={categories}
|
2016-11-02 19:04:34 +09:00
|
|
|
events={Events}
|
2016-10-28 15:45:43 +09:00
|
|
|
{...props}
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
|
|
|
|
AppContainer.propTypes = {
|
|
|
|
data: React.PropTypes.shape({
|
|
|
|
loading: React.PropTypes.bool,
|
2016-10-28 13:56:07 +02:00
|
|
|
categories: React.PropTypes.array,
|
|
|
|
currentUser: React.PropTypes.object,
|
2016-10-28 15:45:43 +09:00
|
|
|
}).isRequired,
|
|
|
|
params: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
AppContainer.displayName = "AppContainer";
|
|
|
|
|
|
|
|
const AppContainerWithData = graphql(gql`
|
|
|
|
query getAppData {
|
|
|
|
categories {
|
|
|
|
_id
|
|
|
|
name
|
|
|
|
description
|
|
|
|
order
|
|
|
|
slug
|
|
|
|
image
|
|
|
|
}
|
2016-11-10 10:11:43 +09:00
|
|
|
#currentUser {
|
|
|
|
# _id
|
|
|
|
# username
|
|
|
|
# createdAt
|
|
|
|
# isAdmin
|
|
|
|
# nova_bio
|
|
|
|
# nova_commentCount
|
|
|
|
# nova_displayName
|
|
|
|
# nova_downvotedComments {
|
|
|
|
# itemId
|
|
|
|
# power
|
|
|
|
# votedAt
|
|
|
|
# }
|
|
|
|
# nova_downvotedPosts {
|
|
|
|
# itemId
|
|
|
|
# power
|
|
|
|
# votedAt
|
|
|
|
# }
|
|
|
|
# nova_email
|
|
|
|
# nova_emailHash
|
|
|
|
# nova_htmlBio
|
|
|
|
# nova_karma
|
|
|
|
# nova_postCount
|
|
|
|
# nova_slug
|
|
|
|
# nova_twitterUsername
|
|
|
|
# nova_upvotedComments {
|
|
|
|
# itemId
|
|
|
|
# power
|
|
|
|
# votedAt
|
|
|
|
# }
|
|
|
|
# nova_upvotedPosts {
|
|
|
|
# itemId
|
|
|
|
# power
|
|
|
|
# votedAt
|
|
|
|
# }
|
|
|
|
# nova_website
|
|
|
|
# nova_groups
|
|
|
|
# nova_notifications_users
|
|
|
|
# nova_notifications_posts
|
|
|
|
# nova_newsletter_subscribeToNewsletter
|
|
|
|
#}
|
2016-10-28 15:45:43 +09:00
|
|
|
}
|
|
|
|
`, {
|
|
|
|
options(ownProps) {
|
|
|
|
return {
|
|
|
|
variables: {},
|
2016-11-02 19:56:44 +09:00
|
|
|
// pollInterval: 20000,
|
2016-10-28 15:45:43 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
})(AppContainer);
|
|
|
|
|
2016-11-10 10:11:43 +09:00
|
|
|
module.exports = composeWithTracker(currentUserComposer)(AppContainerWithData);
|