diff --git a/css/base.css b/css/base.css
index 5e043afc..2ec07f45 100644
--- a/css/base.css
+++ b/css/base.css
@@ -1161,7 +1161,7 @@ ul.tabbar li.active > a:after {
/* Miscellaneous */
/* Badge with the number of unread messages */
-.badge {
+.unread {
display: inline-block;
font-size: 0.75rem;
font-weight: bolder;
@@ -1176,6 +1176,39 @@ ul.tabbar li.active > a:after {
vertical-align: middle;
}
+/* Badge with a label, like [you], [muted], etc */
+.badge {
+ font-family: monospace;
+ font-size: 0.75rem;
+ border: 1px solid #666;
+ background-color: #eee;
+ color: #666;
+ padding: 0 0.15rem 0 0.15rem;
+ margin-left: 0.1rem;
+ margin-right: 0.1rem;
+ border-radius: 0.15rem;
+ display: inline-block;
+ align-self: flex-start;
+}
+
+.badge.green {
+ border-color: #383;
+ background-color: #efe;
+ color: #383;
+}
+
+.badge.yellow {
+ border-color: #660;
+ background-color: #ffe;
+ color: #660;
+}
+
+.badge.red {
+ border-color: #933;
+ background-color: #fee;
+ color: #933;
+}
+
/* Letter tile base style, responsive square box */
.lettertile {
width: 100%;
diff --git a/index.html b/index.html
index 7356b685..5a1e5cf6 100644
--- a/index.html
+++ b/index.html
@@ -131,8 +131,6 @@
// Function is used by context menu to set permissions.
function topicPermissionSetter(mode, topicName, uid) {
- console.log("topicPermissionSetter called with arguments:");
- console.log(arguments);
var topic = Tinode.getTopic(topicName);
if (!topic) {
console.log("Topic not found: " + topicName);
@@ -527,6 +525,7 @@
{this.props.userTitle ?
: null}
@@ -1210,6 +1209,19 @@
}
var online = this.props.now ? "online" : "offline";
var avatar = this.props.avatar ? this.props.avatar : true;
+ var badges = [];
+ if (this.props.badges && this.props.badges.length > 0) {
+ var count = 0;
+ this.props.badges.map(function(b) {
+ var style = "badge" + (b.color ? " " + b.color : "");
+ badges.push(
{b.name});
+ count ++;
+ });
+ }
+ if (this.props.mode) {
+ badges.push(
{this.props.mode});
+ }
+
return (
@@ -1224,9 +1236,10 @@
{title}
- {this.props.showUnread && (this.props.unread > 0) ?
- : null}
+ {this.props.unread > 0 ?
: null}
+
{this.props.comment ? {this.props.comment}
: null}
+ {badges}
{this.props.showContextMenu ?
@@ -1245,12 +1258,29 @@
var showUnreadBadge = null;
if (this.props.count > 0) {
var count = this.props.count > 9 ? "9+" : this.props.count;
- showUnreadBadge = {count};
+ showUnreadBadge = {count};
}
return showUnreadBadge;
}
});
+ /* Contact's labels: [you], [muted], [blocked], etc */
+ Contact.Badges = React.createClass({
+ render: function() {
+ var badges = null;
+ if (this.props.badges && this.props.badges.length > 0) {
+ var count = 0;
+ badges = [];
+ this.props.badges.map(function(b) {
+ var style = "badge" + (b.color ? " " + b.color : "");
+ badges.push({b.name});
+ count ++;
+ });
+ }
+ return badges;
+ }
+ });
+
/* ContactsView holds all contacts-related stuff */
var ContactsView = React.createClass({
getInitialState: function() {
@@ -1261,7 +1291,6 @@
componentWillMount: function() {
var me = Tinode.getMeTopic();
me.onContactUpdate = this.tnMeContactUpdate;
- me.onData = this.tnInvite;
me.onSubsUpdated = this.tnMeSubsUpdated;
},
componentWillUnmount: function() {
@@ -1301,12 +1330,6 @@
}
},
- tnInvite: function(invite) {
- // TODO(gene): implement invite handling
- console.log("Got invite:");
- console.log(invite);
- },
-
tnMeSubsUpdated: function(names) {
this.resetContactList();
},
@@ -1314,10 +1337,7 @@
prepareContactList: function() {
var contacts = [];
Tinode.getMeTopic().contacts(function(c) {
- c.unread = c.seq;
- if (c.read > 0) {
- c.unread -= c.read;
- }
+ c.unread = c.seq - (c.read > 0 ? c.read : 0);
contacts.push(c);
}, this);
@@ -1347,6 +1367,7 @@
* such as a list of group members in a group chat */
var ContactList = React.createClass({
render: function() {
+ var me = Tinode.getCurrentUserID();
var contactNodes = [];
var instance = this;
var showCheckmark = Array.isArray(this.props.topicSelected);
@@ -1354,7 +1375,6 @@
if (this.props.contacts && this.props.contacts.length > 0) {
this.props.contacts.map(function(c) {
var key = c.topic ? c.topic : c.user;
-
// If filter function is provided, filter out the items
// which don't satisfy the condition.
if (instance.props.filterFunc && instance.props.filter) {
@@ -1374,16 +1394,24 @@
(this.props.topicSelected.indexOf(key) > -1) :
(this.props.topicSelected === key);
+ var mode = this.props.showMode && c.acs ? c.acs.getMode() : null;
+
+ var badges = (key === me ? [{name:'you',color:'green'}] : null);
+
+ var comment = Array.isArray(c.private) ? c.private.join(", ") : c.private;
+
contactNodes.push(
@@ -1602,11 +1629,16 @@
1:1
- group
+ group
+
+
+ by id
{this.state.tabSelected === "grp" ?
:
+ this.state.tabSelected === "byId" ?
+ :
+ );
+ }
+ });
/* END Create new topic and invite users or send an invite */
/* BEGIN InfoView: panel with topic/user info */
@@ -1881,9 +1949,6 @@
},
handleLaunchPermissionsEditor: function(which, uid) {
- console.log("handleLaunchPermissionsEditor called with arguments");
- console.log(arguments);
-
var toEdit, toCompare, toSkip, titleEdit, titleCompare, userTitle, userAvatar
switch (which) {
case 'mode':
@@ -1976,9 +2041,6 @@
},
handleContextMenu: function(item, x, y) {
- console.log("handleContextMenu called with agruments");
- console.log(arguments);
-
var instance = this;
var topic = Tinode.getTopic(this.props.topic);
if (!topic) {
@@ -2025,6 +2087,7 @@
modeTitle={this.state.editedPermissionsTitle}
compareTitle={this.state.immutablePermissionsTitle}
userTitle={this.state.userPermissionsTitle}
+ item={this.state.userPermissionsEdited}
userAvatar={this.state.userPermissionsAvatar}
skip={this.state.editedPermissionsSkipped}
onSubmit={this.handlePermissionsChanged}
@@ -2139,6 +2202,7 @@
topicSelected={this.state.selectedContact}
showOnline={false}
showUnread={false}
+ showMode={true}
noScroll={true}
onTopicSelected={this.handleMemberSelected}
showContextMenu={this.state.admin ? this.handleContextMenu : false}
@@ -2927,9 +2991,6 @@
},
handleShowContextMenu: function(topicName, y, x, uid, menuItems) {
- console.log("handleShowContextMenu called with arguments");
- console.log(arguments);
-
this.setState({
contextMenuVisible: true,
contextMenuClickAt: {x: x, y: y},
@@ -2989,7 +3050,7 @@
if (added && added.length > 0) {
added.map(function(uid) {
- topic.invite(uid, null, "Join my group!");
+ topic.invite(uid, null);
});
}