diff --git a/index.html b/index.html
index bb857097..5da48b56 100644
--- a/index.html
+++ b/index.html
@@ -278,7 +278,7 @@
this.setState({showErrorText: false});
},
handleLoginRequested: function(login, password) {
- this.props.onLogin(login, password);
+ this.props.onLoginRequest(login, password);
this.setState({showErrorText: true});
},
render: function() {
@@ -401,7 +401,7 @@
{showUnreadBadge}
);
}
- })
+ });
/* Online/offline indicator */
Contact.Online = React.createClass({
@@ -421,58 +421,66 @@
);
}
- })
+ });
- /* List of contacts/topics */
- var ContactList = React.createClass({
+ /* ContactsView holds all contacts-related stuff */
+ var ContactsView = React.createClass({
getInitialState: function() {
- return {selected: false};
+ return {subscriptions: []};
+ },
+ componentWillMount: function() {
+ var me = Tinode.getMeTopic();
+ me.onContactUpdate = this.tnMeContactUpdate;
+ me.onData = this.tnInvite;
+ me.onSubsUpdated = this.tnMeSubsUpdated;
+ },
+ tnMeContactUpdate: function(what, cont) {
+ console.log("changed: " + what + " in " + cont.topic);
+ this.forceUpdate();
+ },
+ tnInvite: function(invite) {
+ console.log(invite);
+ },
+ tnMeSubsUpdated: function(names) {
+ /*var subs = [];
+ Tinode.getMeTopic().contacts(function(cont) {
+ subs.push(cont);
+ });
+ this.setState({subscriptions: subs});
+ */
+ this.forceUpdate();
},
onSelectionChange: function(sel) {
- console.log("ContactList.onSelectionChange: " + sel);
this.props.onTopicSelected(sel);
},
render: function() {
- var contactNodes = null;
- if (this.props.data) {
- contactNodes = Object.keys(this.props.data).map(function(key) {
- var c = this.props.data[key];
- var online = false;
- var lastSeen = null;
- if (c.seen) {
- lastSeen = shortDateFormat(new Date(c.seen.when));
- // TODO(gene): also handle user agent in c.seen.ua
- }
- var unread = c.seq;
- if (c.read > 0) {
- unread -= c.read;
- }
+ var contactNodes = [];
+ Tinode.getMeTopic().contacts(function(c) {
+ var online = false;
+ var lastSeen = null;
+ if (c.seen) {
+ lastSeen = shortDateFormat(new Date(c.seen.when));
+ // TODO(gene): also handle user agent in c.seen.ua
+ }
+ var unread = c.seq;
+ if (c.read > 0) {
+ unread -= c.read;
+ }
+ contactNodes.push(
+