online presence

This commit is contained in:
Gene S
2016-01-20 19:07:36 -08:00
parent d3e2436527
commit 22e2be2dc8
2 changed files with 18 additions and 9 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ html, body {
.label-as-badge { .label-as-badge {
border-radius: 1em; border-radius: 1em;
margin-left: 1em; margin-left: 0.5em;
} }
.contactBox { .contactBox {
+17 -8
View File
@@ -395,7 +395,8 @@
render: function() { render: function() {
var showUnreadBadge = null; var showUnreadBadge = null;
if (this.props.count > 0) { if (this.props.count > 0) {
showUnreadBadge = <span className="label label-primary label-as-badge">{this.props.count}</span>; var count = this.props.count > 99 ? "99+" : this.props.count;
showUnreadBadge = <span className="label label-primary label-as-badge">{count}</span>;
} }
return ( return (
<span>{showUnreadBadge}</span> <span>{showUnreadBadge}</span>
@@ -408,7 +409,7 @@
render: function() { render: function() {
var lastOnline = ''; var lastOnline = '';
if (this.props.now) { if (this.props.now) {
lastOnline = "online now"; lastOnline = "online";
} else if (this.props.when) { } else if (this.props.when) {
lastOnline = this.props.when; lastOnline = this.props.when;
} else { } else {
@@ -417,7 +418,8 @@
return ( return (
<span className="text-muted pull-right"> <span className="text-muted pull-right">
<span className={this.props.now ? "online" : "offline"}>&#x25cf;</span> <small className="text-muted">&nbsp;{lastOnline}</small> <span className={this.props.now ? "online" : "offline"}>&#x25cf;</span>
<small>&nbsp;{lastOnline}</small>
</span> </span>
); );
} }
@@ -456,10 +458,9 @@
render: function() { render: function() {
var contactNodes = []; var contactNodes = [];
Tinode.getMeTopic().contacts(function(c) { Tinode.getMeTopic().contacts(function(c) {
var online = false;
var lastSeen = null; var lastSeen = null;
if (c.seen) { if (c.seen) {
lastSeen = shortDateFormat(new Date(c.seen.when)); lastSeen = shortDateFormat(c.seen.when);
// TODO(gene): also handle user agent in c.seen.ua // TODO(gene): also handle user agent in c.seen.ua
} }
var unread = c.seq; var unread = c.seq;
@@ -467,7 +468,7 @@
unread -= c.read; unread -= c.read;
} }
contactNodes.push( contactNodes.push(
<Contact public={c.public} comment={c.private} unread={unread} now={online} when={lastSeen} <Contact public={c.public} comment={c.private} unread={unread} now={c.online} when={lastSeen}
onSelected={this.onSelectionChange} topic={c.topic} key={c.topic} /> onSelected={this.onSelectionChange} topic={c.topic} key={c.topic} />
); );
}, this); }, this);
@@ -744,7 +745,7 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
getInitialState: function() { getInitialState: function() {
return { return {
sidePanelSelected: 'login', sidePanelSelected: 'login',
sidePanelTitle: 'not set', sidePanelTitle: null,
loggedIn: false, loggedIn: false,
errorText: '', errorText: '',
topicSelected: '', topicSelected: '',
@@ -759,7 +760,15 @@ dignissim a diam a hendrerit. Nulla vel est ut quam rhoncus pulvinar. In hac hab
Tinode.setup(HOST, API_KEY); Tinode.setup(HOST, API_KEY);
}, },
handleDicsonnect: function() { handleDicsonnect: function() {
console.log("DISCONNECTED!"); this.setState({
sidePanelSelected: 'login',
sidePanelTitle: null,
loggedIn: false,
errorText: 'disconnected',
topicSelected: '',
loginDisabled: false,
subscriptions: {}
});
}, },
// User clicked Login button in the side panel. // User clicked Login button in the side panel.
handleLoginRequest: function(login, password) { handleLoginRequest: function(login, password) {