Remove the friend request button when the request is sent
This commit is contained in:
parent
5ce49af57b
commit
82c87144cb
@ -261,10 +261,11 @@ define(function () {
|
|||||||
// contacts/userlist
|
// contacts/userlist
|
||||||
out.userlist_addAsFriendTitle = 'Ajouter "{0}" comme contact';
|
out.userlist_addAsFriendTitle = 'Ajouter "{0}" comme contact';
|
||||||
out.userlist_thisIsYou = 'Vous ("{0}")';
|
out.userlist_thisIsYou = 'Vous ("{0}")';
|
||||||
|
out.userlist_pending = "En attente...";
|
||||||
out.contacts_title = "Contacts";
|
out.contacts_title = "Contacts";
|
||||||
out.contacts_addError = "Erreur lors de l'ajout de ce contact dans votre liste";
|
out.contacts_addError = "Erreur lors de l'ajout de ce contact dans votre liste";
|
||||||
out.contacts_added = 'Invitation de contact acceptée';
|
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_request = '<em>{0}</em> souhaite vous ajouter en tant que contact. <b>Accepter<b> ?';
|
||||||
out.contacts_send = 'Envoyer';
|
out.contacts_send = 'Envoyer';
|
||||||
out.contacts_remove = 'Supprimer ce contact';
|
out.contacts_remove = 'Supprimer ce contact';
|
||||||
|
|||||||
@ -266,6 +266,7 @@ define(function () {
|
|||||||
// contacts/userlist
|
// contacts/userlist
|
||||||
out.userlist_addAsFriendTitle = 'Add "{0}" as a contact';
|
out.userlist_addAsFriendTitle = 'Add "{0}" as a contact';
|
||||||
out.userlist_thisIsYou = 'This is you ("{0}")';
|
out.userlist_thisIsYou = 'This is you ("{0}")';
|
||||||
|
out.userlist_pending = "Pending...";
|
||||||
out.contacts_title = "Contacts";
|
out.contacts_title = "Contacts";
|
||||||
out.contacts_addError = 'Error while adding that contact to the list';
|
out.contacts_addError = 'Error while adding that contact to the list';
|
||||||
out.contacts_added = 'Contact invite accepted.';
|
out.contacts_added = 'Contact invite accepted.';
|
||||||
|
|||||||
@ -19,6 +19,7 @@ define([
|
|||||||
|
|
||||||
var ready = [];
|
var ready = [];
|
||||||
var pending = {};
|
var pending = {};
|
||||||
|
var pendingRequests = [];
|
||||||
|
|
||||||
var parseMessage = function (content) {
|
var parseMessage = function (content) {
|
||||||
return Marked(content);
|
return Marked(content);
|
||||||
@ -637,7 +638,8 @@ define([
|
|||||||
friends[pubKey] = data;
|
friends[pubKey] = data;
|
||||||
|
|
||||||
common.whenRealtimeSyncs(common.getRealtime(), function () {
|
common.whenRealtimeSyncs(common.getRealtime(), function () {
|
||||||
common.pinPads([data.channel], cb);
|
cb();
|
||||||
|
common.pinPads([data.channel]);
|
||||||
});
|
});
|
||||||
common.changeDisplayName(proxy[common.displayNameKey]);
|
common.changeDisplayName(proxy[common.displayNameKey]);
|
||||||
};
|
};
|
||||||
@ -690,6 +692,8 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg[0] === "FRIEND_REQ_OK") {
|
if (msg[0] === "FRIEND_REQ_OK") {
|
||||||
|
var idx = pendingRequests.indexOf(sender);
|
||||||
|
if (idx !== -1) { pendingRequests.splice(idx, 1); }
|
||||||
addToFriendList(common, msgData, function (err) {
|
addToFriendList(common, msgData, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return void common.log(common.Messages.contacts_addError);
|
return void common.log(common.Messages.contacts_addError);
|
||||||
@ -702,7 +706,11 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg[0] === "FRIEND_REQ_NOK") {
|
if (msg[0] === "FRIEND_REQ_NOK") {
|
||||||
|
var idx = pendingRequests.indexOf(sender);
|
||||||
|
if (idx !== -1) { pendingRequests.splice(idx, 1); }
|
||||||
common.log(common.Messages.contacts_rejected);
|
common.log(common.Messages.contacts_rejected);
|
||||||
|
var proxy = common.getProxy();
|
||||||
|
common.changeDisplayName(proxy[common.displayNameKey]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg[0] === "FRIEND_REQ_ACK") {
|
if (msg[0] === "FRIEND_REQ_ACK") {
|
||||||
@ -723,6 +731,10 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Msg.getPending = function () {
|
||||||
|
return pendingRequests;
|
||||||
|
};
|
||||||
|
|
||||||
Msg.inviteFromUserlist = function (common, netfluxId) {
|
Msg.inviteFromUserlist = function (common, netfluxId) {
|
||||||
var network = common.getNetwork();
|
var network = common.getNetwork();
|
||||||
var parsed = common.parsePadUrl(window.location.href);
|
var parsed = common.parsePadUrl(window.location.href);
|
||||||
@ -737,6 +749,11 @@ define([
|
|||||||
var key = cryptor.cryptKey;
|
var key = cryptor.cryptKey;
|
||||||
var msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
var msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
||||||
// Send encrypted message
|
// Send encrypted message
|
||||||
|
if (pendingRequests.indexOf(netfluxId) === -1) {
|
||||||
|
pendingRequests.push(netfluxId);
|
||||||
|
var proxy = common.getProxy();
|
||||||
|
common.changeDisplayName(proxy[common.displayNameKey]);
|
||||||
|
}
|
||||||
network.sendto(netfluxId, msgStr);
|
network.sendto(netfluxId, msgStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,7 @@ define([
|
|||||||
common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
||||||
common.getFriendListUI = Messaging.getFriendListUI;
|
common.getFriendListUI = Messaging.getFriendListUI;
|
||||||
common.createData = Messaging.createData;
|
common.createData = Messaging.createData;
|
||||||
|
common.getPendingInvites = Messaging.getPending;
|
||||||
|
|
||||||
// Userlist
|
// Userlist
|
||||||
common.createUserList = UserList.create;
|
common.createUserList = UserList.create;
|
||||||
|
|||||||
@ -203,6 +203,7 @@ define([
|
|||||||
var $editUsersList = $('<div>', {'class': 'userlist-others'});
|
var $editUsersList = $('<div>', {'class': 'userlist-others'});
|
||||||
|
|
||||||
// Editors
|
// Editors
|
||||||
|
var pendingFriends = Cryptpad.getPendingInvites();
|
||||||
editUsersNames.forEach(function (data) {
|
editUsersNames.forEach(function (data) {
|
||||||
var name = data.name || Messages.anonymous;
|
var name = data.name || Messages.anonymous;
|
||||||
var $span = $('<span>', {'title': name, 'class': 'avatar'});
|
var $span = $('<span>', {'title': name, 'class': 'avatar'});
|
||||||
@ -217,15 +218,20 @@ define([
|
|||||||
name
|
name
|
||||||
])).text(name);
|
])).text(name);
|
||||||
} else if (!proxy.friends || !proxy.friends[data.curvePublic]) {
|
} else if (!proxy.friends || !proxy.friends[data.curvePublic]) {
|
||||||
$('<span>', {
|
if (pendingFriends.indexOf(data.netfluxId) !== -1) {
|
||||||
'class': 'fa fa-user-plus friend',
|
$('<span>', {'class': 'friend'}).text(Messages.userlist_pending)
|
||||||
'title': Messages._getKey('userlist_addAsFriendTitle', [
|
.appendTo($rightCol);
|
||||||
name
|
} else {
|
||||||
])
|
$('<span>', {
|
||||||
}).appendTo($rightCol).click(function (e) {
|
'class': 'fa fa-user-plus friend',
|
||||||
e.stopPropagation();
|
'title': Messages._getKey('userlist_addAsFriendTitle', [
|
||||||
Cryptpad.inviteFromUserlist(Cryptpad, data.netfluxId);
|
name
|
||||||
});
|
])
|
||||||
|
}).appendTo($rightCol).click(function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
Cryptpad.inviteFromUserlist(Cryptpad, data.netfluxId);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.profile) {
|
if (data.profile) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user