Profile refactoring with friend request

This commit is contained in:
yflory
2019-05-24 17:45:03 +02:00
parent 64b0a8c5e3
commit df7a2f35fb
8 changed files with 376 additions and 211 deletions

View File

@@ -43,18 +43,13 @@ define([
// No password for profiles
return void cb(null, Hash.getSecrets('profile', window.location.hash.slice(1)));
}
var editHash;
nThen(function (waitFor) {
// 2nd case: visiting our own existing profile
Cryptpad.getProfileEditUrl(waitFor(function (hash) {
editHash = hash;
waitFor.abort();
return void cb(null, Hash.getSecrets('profile', hash));
}));
}).nThen(function () {
if (editHash) {
// No password for profile
return void cb(null, Hash.getSecrets('profile', editHash));
}
// 3rd case: profile creation (create a new random hash, store it later if needed)
if (!Utils.LocalStore.isLoggedIn()) {
// Unregistered users can't create a profile
window.location.href = '/drive/';
@@ -79,6 +74,10 @@ define([
cb(null, secret);
});
};
var addData = function (meta, Cryptad, user) {
meta.isOwnProfile = !window.location.hash ||
window.location.hash.slice(1) === user.profile;
};
var addRpc = function (sframeChan, Cryptpad, Utils) {
// Adding a new avatar from the profile: pin it and store it in the object
sframeChan.on('Q_PROFILE_AVATAR_ADD', function (data, cb) {
@@ -100,6 +99,7 @@ define([
getSecrets: getSecrets,
noHash: true, // Don't add the hash in the URL if it doesn't already exist
addRpc: addRpc,
addData: addData,
owned: true
});
});