diff --git a/index.html b/index.html index 98fecb3e..ef903d06 100644 --- a/index.html +++ b/index.html @@ -10,8 +10,8 @@ - - + + @@ -274,7 +274,7 @@ this.props.state === 'settings' ? : this.props.state === 'contacts' ? - : + : null} ); @@ -317,7 +317,13 @@ var contactsData = [ {id: "usrBOB", public: "Bob Smith", comment: "This is another comment", online: {now: true}, unread: 0}, {id: "usrCAROL", public: "Carol Xmas", comment: "No comments", online: {now: false, when: "1 hour ago"}, unread: 2}, - {id: "usrDAVE", public: "Dave Goliaphsson", comment: "This is a comment", online: {now: false, when: "30 min ago"}, unread: 0} + {id: "usrDAVE", public: "Dave Goliaphsson", comment: "This is a comment", online: {now: false, when: "30 min ago"}, unread: 0}, + {id: "usrBOB2", public: "Bob Smith", comment: "This is another comment", online: {now: true}, unread: 0}, + {id: "usrCAROL2", public: "Carol Xmas", comment: "No comments", online: {now: false, when: "1 hour ago"}, unread: 2}, + {id: "usrDAVE2", public: "Dave Goliaphsson", comment: "This is a comment", online: {now: false, when: "30 min ago"}, unread: 0}, + {id: "usrBOB3", public: "Bob Smith", comment: "This is another comment", online: {now: true}, unread: 0}, + {id: "usrCAROL3", public: "Carol Xmas", comment: "No comments", online: {now: false, when: "1 hour ago"}, unread: 2}, + {id: "usrDAVE3", public: "Dave Goliaphsson", comment: "This is a comment", online: {now: false, when: "30 min ago"}, unread: 0} ]; /* A single topic */ @@ -379,14 +385,16 @@ this.props.onTopicSelected(sel); }, render: function() { - var contactNodes = this.props.data.map(function(c) { - return ( - - ); - }, this); + var contactNodes = null; + if (this.props.data) { + contactNodes = Object.keys(this.props.data).map(function(key) { + var c = this.props.data[key]; + return ( + + ); + }, this); + } return (
    @@ -399,18 +407,12 @@ /* The panel to hold all contacts-related stuff together */ var ContactsView = React.createClass({ - getInitialState: function() { - return {contacts: []}; - }, - componentDidMount: function() { - this.setState({contacts: contactsData}); - }, render: function() { return (
    -
    @@ -561,7 +563,8 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab loggedIn: false, errorText: '', selectedTopicName: '', - loginDisabled: false + loginDisabled: false, + subscriptions: {} }; }, componentDidMount: function() { @@ -577,15 +580,27 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab }).then(function() { instance.setState({loggedIn: true}); var me = Tinode.getMeTopic(); + me.onInfoChange = instance.handleMeInfoChange; + me.onSubsChange = instance.handleMeSubsChange; // Subscribe, fetch topic info and the list of subscriptions. return me.subscribe({get: "info sub"}); }).then(function() { var me = Tinode.getMeTopic(); - instance.setState({sidePanel: "contacts", sideTitle: me.public}); + instance.setState({sidePanel: "contacts"}); }).catch(function(err) { instance.setState({loginDisabled: false, errorText: err.message}); }); }, + handleMeInfoChange: function(info) { + this.setState({sideTitle: info.public}); + }, + handleMeSubsChange: function(sub) { + var subs = this.state.subscriptions; + subs[sub.topic] = sub; + console.log("in handleMeSubsChange, processing " + JSON.stringify(sub)); + this.setState({subscriptions: subs}); + console.log("in handleMeSubsChange, subs length: ", this.state.subscriptions.length); + }, handleNewAccount: function(login_, password_, public_, private_) { }, @@ -613,6 +628,7 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
    - {this.state.selTopic ? + {this.state.selectedTopicName ? : }