diff --git a/index.html b/index.html
index 9d8eae23..b2457d63 100644
--- a/index.html
+++ b/index.html
@@ -65,7 +65,7 @@
handleSubmit: function(e) {
e.preventDefault();
this.setState({errorCleared: false, submitDisabled: true});
- this.props.onLogin(this.state.login, this.state.password);
+ this.props.onLogin(this.state.login.trim(), this.state.password.trim());
},
render: function() {
var submitClassList = "btn btn-primary";
@@ -524,21 +524,52 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
var MessagesView = React.createClass({
getInitialState: function() {
- return {messages: []};
+ return {
+ messages: [],
+ title: ''
+ };
},
componentDidMount: function() {
- this.setState({messages: messagesList});
+ this.propsChange(this.props);
+ },
+ componentWillReceiveProps: function(nextProps) {
+ this.propsChange(nextProps);
+ },
+ propsChange: function(props) {
+ var topic = Tinode.getTopic(props.topic);
+ // Clear messages cached in the component
+ this.setState({messages: []});
+ 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"});
+ }
+ },
+ handleInfoChange: function(info) {
+ console.log("handleInfoChange: " + info);
+ this.setState({title: info.public});
+ },
+ handleSubsUpdated: function(uids) {
+
+ },
+ handleNewMessage: function(msg) {
+ this.setState({messages: this.state.messages.concat(msg)});
},
render: function() {
+ var me = Tinode.getCurrentUserID();
var messageNodes = this.state.messages.map(function(msg) {
+ var isReply = !(msg.from === me);
return (
-