Fix empty title with new documents

pull/1/head
yflory 8 years ago
parent 4963c77b61
commit 605072cfbf

@ -174,7 +174,9 @@ define([
defaultTitle: defaultName
}
};
obj.metadata.title = document.title;
if (!initializing) {
obj.metadata.title = document.title;
}
// set mode too...
obj.highlightMode = module.highlightMode;
@ -348,6 +350,7 @@ define([
var updateMetadata = function(shjson) {
// Extract the user list (metadata) from the hyperjson
var json = (shjson === "") ? "" : JSON.parse(shjson);
var titleUpdated = false;
if (json && json.metadata) {
if (json.metadata.users) {
var userData = json.metadata.users;
@ -359,8 +362,12 @@ define([
}
if (typeof json.metadata.title !== "undefined") {
updateTitle(json.metadata.title || defaultName);
titleUpdated = true;
}
}
if (!titleUpdated) {
updateTitle(defaultName);
}
};
var onInit = config.onInit = function (info) {

@ -370,7 +370,9 @@ define([
defaultTitle: defaultName
}
};
hjson[3].metadata.title = document.title;
if (!initializing) {
hjson[3].metadata.title = document.title;
}
return stringify(hjson);
};
@ -438,6 +440,7 @@ define([
// Extract the user list (metadata) from the hyperjson
var hjson = JSON.parse(shjson);
var peerMetadata = hjson[3];
var titleUpdated = false;
if (peerMetadata && peerMetadata.metadata) {
if (peerMetadata.metadata.users) {
var userData = peerMetadata.metadata.users;
@ -449,8 +452,12 @@ define([
}
if (typeof peerMetadata.metadata.title !== "undefined") {
updateTitle(peerMetadata.metadata.title || defaultName);
titleUpdated = true;
}
}
if (!titleUpdated) {
updateTitle(defaultName);
}
};
var unnotify = function () {

@ -215,7 +215,9 @@ define([
defaultTitle: defaultName
}
};
obj.metadata.title = APP.title;
if (!initializing) {
obj.metadata.title = APP.title;
}
if (textColor) {
obj.metadata.color = textColor;
}
@ -383,6 +385,7 @@ define([
var updateMetadata = function(shjson) {
// Extract the user list (metadata) from the hyperjson
var json = (shjson === "") ? "" : JSON.parse(shjson);
var titleUpdated = false;
if (json && json.metadata) {
if (json.metadata.users) {
var userData = json.metadata.users;
@ -394,9 +397,13 @@ define([
}
if (typeof json.metadata.title !== "undefined") {
updateTitle(json.metadata.title || defaultName);
titleUpdated = true;
}
updateColors(json.metadata.color, json.metadata.backColor);
}
if (!titleUpdated) {
updateTitle(defaultName);
}
};
var renameCb = function (err, title) {

Loading…
Cancel
Save