2016-02-16 15:40:37 +09:00
|
|
|
const AppContainer = React.createClass({
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
mixins: [ReactMeteorData],
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
getMeteorData() {
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
var data = {
|
2016-02-23 11:34:40 +09:00
|
|
|
currentUser: Meteor.user(),
|
2016-02-16 15:08:30 +09:00
|
|
|
ready: false
|
|
|
|
};
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
var handles = Telescope.subscriptions.map((sub) => Meteor.subscribe(sub.name, sub.arguments));
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
if(!handles.length || _.every(handles, handle => handle.ready())) {
|
|
|
|
data.ready = true;
|
|
|
|
}
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-02-16 15:08:30 +09:00
|
|
|
return data;
|
|
|
|
},
|
2016-02-14 12:27:20 +09:00
|
|
|
|
|
|
|
|
|
|
|
render() {
|
2016-02-16 15:08:30 +09:00
|
|
|
|
|
|
|
const Layout = Telescope.getComponent("Layout");
|
|
|
|
|
|
|
|
if (this.data.ready) {
|
2016-02-23 11:34:40 +09:00
|
|
|
return <Layout currentUser={this.data.currentUser}>{this.props.content}</Layout>
|
2016-02-16 15:08:30 +09:00
|
|
|
} else {
|
|
|
|
return <p>Loading App…</p>
|
|
|
|
}
|
|
|
|
|
2016-02-14 12:27:20 +09:00
|
|
|
// return this.data.ready ? this.props.content : <Loading/>;
|
|
|
|
}
|
|
|
|
|
2016-02-16 15:40:37 +09:00
|
|
|
});
|
|
|
|
|
2016-02-28 18:56:58 +09:00
|
|
|
module.exports = AppContainer;
|
|
|
|
export default AppContainer;
|