|
|
@ -11,17 +11,8 @@ define([
|
|
|
|
unfriend: 'UNFRIEND'
|
|
|
|
unfriend: 'UNFRIEND'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: pin the chat channel!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: new Types
|
|
|
|
|
|
|
|
// - send a rename message to the chat
|
|
|
|
|
|
|
|
// - petnames
|
|
|
|
|
|
|
|
// - close a chat / remove a friend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
// - mute a channel (hide notifications or don't open it?)
|
|
|
|
// - mute a channel (hide notifications or don't open it?)
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ready = [];
|
|
|
|
var ready = [];
|
|
|
|
var pending = {};
|
|
|
|
var pending = {};
|
|
|
@ -87,6 +78,7 @@ define([
|
|
|
|
var $rightCol = $('<span>', {'class': 'right-col'});
|
|
|
|
var $rightCol = $('<span>', {'class': 'right-col'});
|
|
|
|
$('<span>', {'class': 'name'}).text(data.displayName).appendTo($rightCol);
|
|
|
|
$('<span>', {'class': 'name'}).text(data.displayName).appendTo($rightCol);
|
|
|
|
var $remove = $('<span>', {'class': 'remove fa fa-user-times'}).appendTo($rightCol);
|
|
|
|
var $remove = $('<span>', {'class': 'remove fa fa-user-times'}).appendTo($rightCol);
|
|
|
|
|
|
|
|
$remove.attr('title', common.Messages.contacts_remove);
|
|
|
|
$friend.dblclick(function () {
|
|
|
|
$friend.dblclick(function () {
|
|
|
|
if (data.profile) {
|
|
|
|
if (data.profile) {
|
|
|
|
window.open('/profile/#' + data.profile);
|
|
|
|
window.open('/profile/#' + data.profile);
|
|
|
@ -97,10 +89,12 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$remove.click(function (e) {
|
|
|
|
$remove.click(function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
common.confirm("TODO: Are you sure?", function (yes) {//XXX
|
|
|
|
common.confirm(common.Messages.getKey('contacts_confirmRemove', [
|
|
|
|
|
|
|
|
common.fixHTML(data.displayName)
|
|
|
|
|
|
|
|
]), function (yes) {
|
|
|
|
if (!yes) { return; }
|
|
|
|
if (!yes) { return; }
|
|
|
|
remove(data.curvePublic);
|
|
|
|
remove(data.curvePublic);
|
|
|
|
});
|
|
|
|
}, null, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (data.avatar && avatars[data.avatar]) {
|
|
|
|
if (data.avatar && avatars[data.avatar]) {
|
|
|
|
$friend.append(avatars[data.avatar]);
|
|
|
|
$friend.append(avatars[data.avatar]);
|
|
|
@ -273,7 +267,7 @@ define([
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
$('<button>').text('TODO: Send').appendTo($inputBlock).click(send); // XXX
|
|
|
|
$('<button>').text(common.Messages.contacts_send).appendTo($inputBlock).click(send);
|
|
|
|
$input.on('keypress', function (e) {
|
|
|
|
$input.on('keypress', function (e) {
|
|
|
|
if (e.which === 13) { send(); }
|
|
|
|
if (e.which === 13) { send(); }
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -550,16 +544,18 @@ define([
|
|
|
|
todo(true);
|
|
|
|
todo(true);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
common.confirm("Accept friend?", todo);// TODO
|
|
|
|
var confirmMsg = common.Messages._getKey('contacts_request', [
|
|
|
|
|
|
|
|
common.fixHTML(msgData.displayName)
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
common.confirm(confirmMsg, todo, null, true);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (msg[0] === "FRIEND_REQ_OK") {
|
|
|
|
if (msg[0] === "FRIEND_REQ_OK") {
|
|
|
|
// XXX
|
|
|
|
|
|
|
|
addToFriendList(common, msgData, function (err) {
|
|
|
|
addToFriendList(common, msgData, function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return void common.log('Error while adding that friend to the list');
|
|
|
|
return void common.log(common.Messages.contacts_addError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
common.log('Friend invite accepted.');
|
|
|
|
common.log(common.Messages.contacts_added);
|
|
|
|
var msg = ["FRIEND_REQ_ACK", chan];
|
|
|
|
var msg = ["FRIEND_REQ_ACK", chan];
|
|
|
|
var msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
|
|
|
var msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
|
|
|
network.sendto(sender, msgStr);
|
|
|
|
network.sendto(sender, msgStr);
|
|
|
@ -567,19 +563,17 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (msg[0] === "FRIEND_REQ_NOK") {
|
|
|
|
if (msg[0] === "FRIEND_REQ_NOK") {
|
|
|
|
// XXX
|
|
|
|
common.log(common.Messages.contacts_rejected);
|
|
|
|
common.log('Friend invite rejected');
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (msg[0] === "FRIEND_REQ_ACK") {
|
|
|
|
if (msg[0] === "FRIEND_REQ_ACK") {
|
|
|
|
// XXX
|
|
|
|
|
|
|
|
var data = pending[sender];
|
|
|
|
var data = pending[sender];
|
|
|
|
if (!data) { return; }
|
|
|
|
if (!data) { return; }
|
|
|
|
addToFriendList(common, data, function (err) {
|
|
|
|
addToFriendList(common, data, function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return void common.log('Error while adding that friend to the list');
|
|
|
|
return void common.log(common.Messages.contacts_addError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
common.log('Friend added to the list.');
|
|
|
|
common.log(common.Messages.contacts_added);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|