fetching messages from the server

This commit is contained in:
Gene S
2016-01-12 18:57:34 -08:00
parent 4c759913c7
commit eee2db628a
+22 -4
View File
@@ -329,7 +329,7 @@
/* A single topic */ /* A single topic */
var Contact = React.createClass({ var Contact = React.createClass({
handleClick: function() { handleClick: function() {
this.props.onSelected(this.props.public); this.props.onSelected(this.props.topic);
}, },
render: function() { render: function() {
return ( return (
@@ -391,7 +391,7 @@
var c = this.props.data[key]; var c = this.props.data[key];
return ( return (
<Contact public={c.public} comment={c.private} unread={c.unread} <Contact public={c.public} comment={c.private} unread={c.unread}
onSelected={this.onSelectionChange} key={c.topic} /> onSelected={this.onSelectionChange} topic={c.topic} key={c.topic} />
); );
}, this); }, this);
} }
@@ -591,9 +591,16 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
instance.setState({loginDisabled: false, errorText: err.message}); instance.setState({loginDisabled: false, errorText: err.message});
}); });
}, },
handleInfoChange: function(info) {
console.log(info);
this.setState({selectedTopicName: info.public});
},
handleMeInfoChange: function(info) { handleMeInfoChange: function(info) {
this.setState({sideTitle: info.public}); this.setState({sideTitle: info.public});
}, },
handleSubsUpdated: function(uids) {
console.log(uids);
},
handleMeSubsChange: function(sub) { handleMeSubsChange: function(sub) {
var subs = this.state.subscriptions; var subs = this.state.subscriptions;
subs[sub.topic] = sub; subs[sub.topic] = sub;
@@ -602,8 +609,19 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
handleNewAccount: function(login_, password_, public_, private_) { handleNewAccount: function(login_, password_, public_, private_) {
}, },
handleTopicSelected: function(topic) { handleNewMessage: function(msg) {
this.setState({selectedTopicName: topic}); console.log(msg);
},
handleTopicSelected: function(topicName) {
var topic = Tinode.getTopic(topicName);
if (topic.isSubscribed()) {
this.handleInfoChange(topic);
} else {
topic.onData = this.handleNewMessage;
topic.onInfoChange = this.handleInfoChange;
topic.onSubsUpdated = this.handleSubsUpdated;
topic.subscribe({get: "info sub data"});
}
}, },
handleSignUp: function() { handleSignUp: function() {
this.setState({sidePanel: 'register'}); this.setState({sidePanel: 'register'});