Update display name in realtime across tabs and remember 'anonymous' name
This commit is contained in:
@@ -264,17 +264,10 @@ define([
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
module.userName.lastName = myUserName;
|
||||
onLocal();
|
||||
});
|
||||
};
|
||||
|
||||
var getLastName = function (cb) {
|
||||
Cryptpad.getAttribute('username', function (err, userName) {
|
||||
cb(err, userName || '');
|
||||
});
|
||||
};
|
||||
|
||||
var getHeadingText = function () {
|
||||
var lines = editor.getValue().split(/\n/);
|
||||
|
||||
@@ -418,13 +411,6 @@ define([
|
||||
var onInit = config.onInit = function (info) {
|
||||
userList = info.userList;
|
||||
|
||||
module.userName = {};
|
||||
// The lastName is stored in an object passed to the toolbar so that when the user clicks on
|
||||
// the "change display name" button, the prompt already knows his current name
|
||||
getLastName(function (err, lastName) {
|
||||
module.userName.lastName = lastName;
|
||||
});
|
||||
|
||||
var config = {
|
||||
displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
|
||||
userData: userData,
|
||||
@@ -435,10 +421,6 @@ define([
|
||||
defaultName: defaultName,
|
||||
suggestName: suggestName
|
||||
},
|
||||
userName: {
|
||||
setName: setName,
|
||||
lastName: module.userName
|
||||
},
|
||||
common: Cryptpad
|
||||
};
|
||||
if (readOnly) {delete config.changeNameID; }
|
||||
@@ -599,6 +581,8 @@ define([
|
||||
if (!window.location.hash || window.location.hash === '#') {
|
||||
Cryptpad.replaceHash(editHash);
|
||||
}
|
||||
|
||||
Cryptpad.onDisplayNameChanged(setName);
|
||||
};
|
||||
|
||||
var unnotify = module.unnotify = function () {
|
||||
@@ -673,7 +657,7 @@ define([
|
||||
//Cryptpad.log("Your document is ready");
|
||||
|
||||
onLocal(); // push local state to avoid parse errors later.
|
||||
getLastName(function (err, lastName) {
|
||||
Cryptpad.getLastName(function (err, lastName) {
|
||||
if (err) {
|
||||
console.log("Could not get previous name");
|
||||
console.error(err);
|
||||
@@ -682,7 +666,7 @@ define([
|
||||
// Update the toolbar list:
|
||||
// Add the current user in the metadata if he has edit rights
|
||||
if (readOnly) { return; }
|
||||
if (typeof(lastName) === 'string' && lastName.length) {
|
||||
if (typeof(lastName) === 'string') {
|
||||
setName(lastName);
|
||||
} else {
|
||||
myData[myID] = {
|
||||
|
||||
Reference in New Issue
Block a user