Do not share the title in the doc if it is the default title
This commit is contained in:
@@ -193,10 +193,11 @@ define([
|
||||
|
||||
// append the userlist to the hyperjson structure
|
||||
obj.metadata = {
|
||||
users: userList,
|
||||
title: APP.title
|
||||
users: userList
|
||||
};
|
||||
|
||||
if (!isDefaultTitle()) {
|
||||
obj.metadata.title = APP.title;
|
||||
}
|
||||
// stringify the json and send it into chainpad
|
||||
var shjson = stringify(obj);
|
||||
|
||||
@@ -254,11 +255,15 @@ define([
|
||||
return text.trim();
|
||||
};
|
||||
|
||||
var isDefaultTitle = function () {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
return Cryptpad.isDefaultName(parsed, APP.title);
|
||||
};
|
||||
var suggestName = function () {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
var name = Cryptpad.getDefaultName(parsed, []);
|
||||
|
||||
if (APP.title.slice(0, name.length) === name) {
|
||||
if (Cryptpad.isDefaultName(parsed, APP.title)) {
|
||||
return getHeadingText() || APP.title;
|
||||
} else {
|
||||
return APP.title || getHeadingText() || name;
|
||||
@@ -343,43 +348,43 @@ define([
|
||||
onLocal();
|
||||
}));
|
||||
$rightside.append($import);
|
||||
}
|
||||
|
||||
/* add a rename button */
|
||||
var $setTitle = Cryptpad.createButton('rename', true)
|
||||
.click(function () {
|
||||
var suggestion = suggestName();
|
||||
/* add a rename button */
|
||||
var $setTitle = Cryptpad.createButton('rename', true)
|
||||
.click(function () {
|
||||
var suggestion = suggestName();
|
||||
|
||||
Cryptpad.prompt(Messages.renamePrompt,
|
||||
suggestion, function (title, ev) {
|
||||
if (title === null) { return; }
|
||||
Cryptpad.prompt(Messages.renamePrompt,
|
||||
suggestion, function (title, ev) {
|
||||
if (title === null) { return; }
|
||||
|
||||
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
||||
if (err) {
|
||||
console.log("Unable to determine if name caused a conflict");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conflicts) {
|
||||
Cryptpad.alert(Messages.renameConflict);
|
||||
return;
|
||||
}
|
||||
|
||||
Cryptpad.setPadTitle(title, function (err, data) {
|
||||
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
||||
if (err) {
|
||||
console.log("unable to set pad title");
|
||||
console.log(err);
|
||||
console.log("Unable to determine if name caused a conflict");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
onLocal();
|
||||
|
||||
if (conflicts) {
|
||||
Cryptpad.alert(Messages.renameConflict);
|
||||
return;
|
||||
}
|
||||
|
||||
Cryptpad.setPadTitle(title, function (err, data) {
|
||||
if (err) {
|
||||
console.log("unable to set pad title");
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
onLocal();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
$rightside.append($setTitle);
|
||||
});
|
||||
$rightside.append($setTitle);
|
||||
}
|
||||
|
||||
/* add a forget button */
|
||||
var $forgetPad = Cryptpad.createButton('forget', true)
|
||||
@@ -684,11 +689,13 @@ define([
|
||||
var hjson2 = {
|
||||
content: localDoc,
|
||||
metadata: {
|
||||
users: userList,
|
||||
title: APP.title
|
||||
users: userList
|
||||
},
|
||||
highlightMode: highlightMode,
|
||||
};
|
||||
if (!isDefaultTitle()) {
|
||||
hjson2.metadata.title = APP.title;
|
||||
}
|
||||
var shjson2 = stringify(hjson2);
|
||||
if (shjson2 !== shjson) {
|
||||
console.error("shjson2 !== shjson");
|
||||
|
||||
Reference in New Issue
Block a user