Friend button in the userlist

pull/1/head
yflory 8 years ago
parent 8dc8aa27ab
commit bf17ad3f1e

@ -138,12 +138,23 @@ body .userlist-drawer {
color: black;
font-size: 40px;
}
.right-col {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: flex;
flex-flow: column;
.name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.friend {
padding: 0;
}
}
media-tag {
min-height: 50px;
min-width: 50px;

@ -1185,6 +1185,21 @@ define([
return button;
};
// Messaging
var addDirectMessageHandler = function () {
var network = getNetwork();
if (!network) { return void console.error('Network not ready'); }
network.on('message', function (msg, sender) {
if (sender === network.historyKeeper) { return; }
});
};
common.inviteFromUserlist = function (netfluxId) {
var network = getNetwork();
network.sendto(netfluxId, '["FRIEND_REQ", "Salut"]')
};
var emoji_patt = /([\uD800-\uDBFF][\uDC00-\uDFFF])/;
var isEmoji = function (str) {
@ -1691,6 +1706,8 @@ define([
Store.ready(function (err, storeObj) {
store = common.store = env.store = storeObj;
addDirectMessageHandler();
var proxy = getProxy();
var network = getNetwork();

@ -200,7 +200,8 @@ types of messages:
return sendMsg(ctx, data, cb);
};
network.on('message', function (msg) {
network.on('message', function (msg, sender) {
if (sender !== network.historyKeeper) { return; }
onMsg(ctx, msg);
});
@ -305,6 +306,7 @@ types of messages:
};
network.on('message', function (msg) {
if (sender !== network.historyKeeper) { return; }
onAnonMsg(ctx, msg);
});

@ -148,7 +148,8 @@ define([
//if (user !== userNetfluxId) {
var data = userData[user] || {};
var userId = data.uid;
if (!data.uid) { return; }
if (!userId) { return; }
data.netfluxId = user;
if (uids.indexOf(userId) === -1) {// && (!myUid || userId !== myUid)) {
uids.push(userId);
list.push(data);
@ -206,8 +207,17 @@ define([
// Editors
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;
var $name = $('<span>', {'class': 'name'}).text(name);
var $span = $('<span>', {'title': name});
var $rightCol = $('<span>', {'class': 'right-col'});
var $name = $('<span>', {'class': 'name'}).text(name).appendTo($rightCol);
// TODO: if account
var $button = $('<button>', {'class': 'friend'}).appendTo($rightCol);
$button.text('Add friend').click(function (e) {
console.log('TODO');
e.stopPropagation();
Cryptpad.inviteFromUserlist(data.netfluxId);
});
// TODO: end if
if (data.profile) {
$span.addClass('clickable');
$span.click(function () {
@ -216,13 +226,13 @@ define([
}
if (data.avatar && avatars[data.avatar]) {
$span.append(avatars[data.avatar]);
$span.append($name);
$span.append($rightCol);
} else {
Cryptpad.displayAvatar($span, data.avatar, name, function ($img) {
if (data.avatar && $img) {
avatars[data.avatar] = $img[0].outerHTML;
}
$span.append($name);
$span.append($rightCol);
});
}
$span.data('uid', data.uid);

Loading…
Cancel
Save