-
Notifications
You must be signed in to change notification settings - Fork 1
/
Link.jsx
55 lines (50 loc) · 1.29 KB
/
Link.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Link = React.createClass({
propTypes: {
// require data proto --> contains all link info
data: React.PropTypes.object.isRequired
},
// set state of svgs to empty array
getInitialState () {
return {svgs: []}
},
presentation () {
// declare identifier variables in function scope
let user = Meteor.user()._id;
let link = this.props.data.link;
let gid = this.props.data.gid;
let react = this;
// opens a query and waits for a change to occur
Presentations.find({gid: gid.toString()}).observe({
added: function (newDoc) {
console.log('we have a change', newDoc);
react.setState({svgs: newDoc.svgs});
}
});
// call method to create a
Meteor.call('createPresentation', link, user, gid, function (err, result) {
if(err){
console.error(err);
};
})
},
svgs () {
return <div>{this.state.svgs[0]}</div>
},
makeSlides () {
if(this.state.svgs.length > 0){
console.log("trying to make slides")
return <Slides svgs={this.state.svgs} />
}
},
render () {
return (
<li>
<div onClick={this.presentation}>
<img src={this.props.data.thumbnail}/>
<h1>{this.props.data.title}</h1>
</div>
{this.makeSlides()}
</li>
)
}
})