Remove the friend request button when the request is sent

pull/1/head
yflory 8 years ago
parent 5ce49af57b
commit 82c87144cb

@ -261,10 +261,11 @@ define(function () {
// contacts/userlist
out.userlist_addAsFriendTitle = 'Ajouter "{0}" comme contact';
out.userlist_thisIsYou = 'Vous ("{0}")';
out.userlist_pending = "En attente...";
out.contacts_title = "Contacts";
out.contacts_addError = "Erreur lors de l'ajout de ce contact dans votre liste";
out.contacts_added = 'Invitation de contact acceptée';
out.contacts_rejected = 'Invitation d econtact rejetée';
out.contacts_rejected = 'Invitation de contact rejetée';
out.contacts_request = '<em>{0}</em> souhaite vous ajouter en tant que contact. <b>Accepter<b> ?';
out.contacts_send = 'Envoyer';
out.contacts_remove = 'Supprimer ce contact';

@ -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.';

@ -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);
};

@ -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;

@ -203,6 +203,7 @@ define([
var $editUsersList = $('<div>', {'class': 'userlist-others'});
// Editors
var pendingFriends = Cryptpad.getPendingInvites();
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;
var $span = $('<span>', {'title': name, 'class': 'avatar'});
@ -217,15 +218,20 @@ define([
name
])).text(name);
} else if (!proxy.friends || !proxy.friends[data.curvePublic]) {
$('<span>', {
'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) {
$('<span>', {'class': 'friend'}).text(Messages.userlist_pending)
.appendTo($rightCol);
} else {
$('<span>', {
'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) {

Loading…
Cancel
Save