Merge branch 'master' of github.com:xwiki-labs/cryptpad

pull/1/head
ansuz 8 years ago
commit b4973b7610

@ -7,14 +7,16 @@ define(function () {
var userData = exp.userData = {}; var userData = exp.userData = {};
var userList = exp.userList = info.userList; var userList = exp.userList = info.userList;
var myData = exp.myData = {}; var myData = exp.myData = {};
var myUserName = exp.myUserName = info.myID; exp.myUserName = info.myID;
var myNetfluxId = exp.myNetfluxId = info.myID; exp.myNetfluxId = info.myID;
var network = Cryptpad.getNetwork();
var parsed = Cryptpad.parsePadUrl(window.location.href); var parsed = Cryptpad.parsePadUrl(window.location.href);
var appType = parsed ? parsed.type : undefined; var appType = parsed ? parsed.type : undefined;
var users = userList.users;
var addToUserData = exp.addToUserData = function(data) { var addToUserData = exp.addToUserData = function(data) {
var users = userList.users;
for (var attrname in data) { userData[attrname] = data[attrname]; } for (var attrname in data) { userData[attrname] = data[attrname]; }
if (users && users.length) { if (users && users.length) {
@ -34,7 +36,7 @@ define(function () {
return { return {
data: userData, data: userData,
list: userList, list: userList,
userNetfluxId: myNetfluxId userNetfluxId: exp.myNetfluxId
}; };
}; };
@ -44,13 +46,14 @@ define(function () {
if(myUserNameTemp.length > 32) { if(myUserNameTemp.length > 32) {
myUserNameTemp = myUserNameTemp.substr(0, 32); myUserNameTemp = myUserNameTemp.substr(0, 32);
} }
myUserName = myUserNameTemp; exp.myUserName = myUserNameTemp;
myData[myNetfluxId] = { myData = {};
name: myUserName, myData[exp.myNetfluxId] = {
name: exp.myUserName,
uid: Cryptpad.getUid(), uid: Cryptpad.getUid(),
}; };
addToUserData(myData); addToUserData(myData);
Cryptpad.setAttribute('username', myUserName, function (err) { Cryptpad.setAttribute('username', exp.myUserName, function (err) {
if (err) { if (err) {
console.log("Couldn't set username"); console.log("Couldn't set username");
console.error(err); console.error(err);
@ -72,7 +75,7 @@ define(function () {
if (typeof(lastName) === 'string') { if (typeof(lastName) === 'string') {
setName(lastName, onLocal); setName(lastName, onLocal);
} else { } else {
myData[myNetfluxId] = { myData[exp.myNetfluxId] = {
name: "", name: "",
uid: Cryptpad.getUid(), uid: Cryptpad.getUid(),
}; };
@ -90,6 +93,11 @@ define(function () {
setName(newName, onLocal); setName(newName, onLocal);
}); });
network.on('reconnect', function (uid) {
exp.myNetfluxId = uid;
exp.setName(exp.myUserName);
});
return exp; return exp;
}; };

Loading…
Cancel
Save