?';
out.contacts_send = 'Envoyer';
out.contacts_remove = 'Supprimer ce contact';
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index f15a08f3b..f5ad75bf6 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -266,6 +266,7 @@ define(function () {
// contacts/userlist
out.userlist_addAsFriendTitle = 'Add "{0}" as a contact';
out.userlist_thisIsYou = 'This is you ("{0}")';
+ out.userlist_pending = "Pending...";
out.contacts_title = "Contacts";
out.contacts_addError = 'Error while adding that contact to the list';
out.contacts_added = 'Contact invite accepted.';
diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js
index 59b2f16c6..82c13e640 100644
--- a/www/common/common-messaging.js
+++ b/www/common/common-messaging.js
@@ -19,6 +19,7 @@ define([
var ready = [];
var pending = {};
+ var pendingRequests = [];
var parseMessage = function (content) {
return Marked(content);
@@ -637,7 +638,8 @@ define([
friends[pubKey] = data;
common.whenRealtimeSyncs(common.getRealtime(), function () {
- common.pinPads([data.channel], cb);
+ cb();
+ common.pinPads([data.channel]);
});
common.changeDisplayName(proxy[common.displayNameKey]);
};
@@ -690,6 +692,8 @@ define([
return;
}
if (msg[0] === "FRIEND_REQ_OK") {
+ var idx = pendingRequests.indexOf(sender);
+ if (idx !== -1) { pendingRequests.splice(idx, 1); }
addToFriendList(common, msgData, function (err) {
if (err) {
return void common.log(common.Messages.contacts_addError);
@@ -702,7 +706,11 @@ define([
return;
}
if (msg[0] === "FRIEND_REQ_NOK") {
+ var idx = pendingRequests.indexOf(sender);
+ if (idx !== -1) { pendingRequests.splice(idx, 1); }
common.log(common.Messages.contacts_rejected);
+ var proxy = common.getProxy();
+ common.changeDisplayName(proxy[common.displayNameKey]);
return;
}
if (msg[0] === "FRIEND_REQ_ACK") {
@@ -723,6 +731,10 @@ define([
});
};
+ Msg.getPending = function () {
+ return pendingRequests;
+ };
+
Msg.inviteFromUserlist = function (common, netfluxId) {
var network = common.getNetwork();
var parsed = common.parsePadUrl(window.location.href);
@@ -737,6 +749,11 @@ define([
var key = cryptor.cryptKey;
var msgStr = Crypto.encrypt(JSON.stringify(msg), key);
// Send encrypted message
+ if (pendingRequests.indexOf(netfluxId) === -1) {
+ pendingRequests.push(netfluxId);
+ var proxy = common.getProxy();
+ common.changeDisplayName(proxy[common.displayNameKey]);
+ }
network.sendto(netfluxId, msgStr);
};
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index b2e1ceeff..ac4d91d08 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -125,6 +125,7 @@ define([
common.getFriendChannelsList = Messaging.getFriendChannelsList;
common.getFriendListUI = Messaging.getFriendListUI;
common.createData = Messaging.createData;
+ common.getPendingInvites = Messaging.getPending;
// Userlist
common.createUserList = UserList.create;
diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js
index ffb8f2b10..1347518df 100644
--- a/www/common/toolbar2.js
+++ b/www/common/toolbar2.js
@@ -203,6 +203,7 @@ define([
var $editUsersList = $('', {'class': 'userlist-others'});
// Editors
+ var pendingFriends = Cryptpad.getPendingInvites();
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;
var $span = $('', {'title': name, 'class': 'avatar'});
@@ -217,15 +218,20 @@ define([
name
])).text(name);
} else if (!proxy.friends || !proxy.friends[data.curvePublic]) {
- $('', {
- 'class': 'fa fa-user-plus friend',
- 'title': Messages._getKey('userlist_addAsFriendTitle', [
- name
- ])
- }).appendTo($rightCol).click(function (e) {
- e.stopPropagation();
- Cryptpad.inviteFromUserlist(Cryptpad, data.netfluxId);
- });
+ if (pendingFriends.indexOf(data.netfluxId) !== -1) {
+ $('', {'class': 'friend'}).text(Messages.userlist_pending)
+ .appendTo($rightCol);
+ } else {
+ $('', {
+ 'class': 'fa fa-user-plus friend',
+ 'title': Messages._getKey('userlist_addAsFriendTitle', [
+ name
+ ])
+ }).appendTo($rightCol).click(function (e) {
+ e.stopPropagation();
+ Cryptpad.inviteFromUserlist(Cryptpad, data.netfluxId);
+ });
+ }
}
}
if (data.profile) {