Friend requests with mailboxes

This commit is contained in:
yflory
2019-05-21 18:43:11 +02:00
parent 0732773bba
commit 991c56fec3
10 changed files with 326 additions and 368 deletions

View File

@@ -380,14 +380,24 @@ define([
funcs.mergeAnonDrive = function (cb) {
ctx.sframeChan.query('Q_MERGE_ANON_DRIVE', null, cb);
};
// Friends
var pendingFriends = [];
// Create friend request
funcs.getPendingFriends = function () {
return pendingFriends.slice();
return ctx.metadataMgr.getPrivateData().pendingFriends;
};
funcs.sendFriendRequest = function (netfluxId) {
ctx.sframeChan.query('Q_SEND_FRIEND_REQUEST', netfluxId, $.noop);
pendingFriends.push(netfluxId);
funcs.sendFriendRequest = function (data, cb) {
ctx.sframeChan.query('Q_SEND_FRIEND_REQUEST', data, cb);
};
// Friend requests received
var friendRequests = {};
funcs.addFriendRequest = function (data) {
var curve = Util.find(data, ['content', 'msg', 'author']);
console.log(data);
console.log(curve);
friendRequests[curve] = data;
};
funcs.getFriendRequests = function () {
return JSON.parse(JSON.stringify(friendRequests));
};
// Feedback
@@ -524,15 +534,6 @@ define([
UI.addTooltips();
ctx.sframeChan.on('Q_INCOMING_FRIEND_REQUEST', function (confirmMsg, cb) {
UI.confirm(confirmMsg, cb, null, true);
});
ctx.sframeChan.on('EV_FRIEND_REQUEST', function (data) {
var i = pendingFriends.indexOf(data.netfluxId);
if (i !== -1) { pendingFriends.splice(i, 1); }
UI.log(data.logText);
});
ctx.sframeChan.on("EV_PAD_PASSWORD", function () {
UIElements.displayPasswordPrompt(funcs);
});