Fix issue newPadPath with new templates

pull/1/head
yflory 4 years ago committed by ansuz
parent da31b71482
commit 7eea957a4d

@ -2270,12 +2270,14 @@ define([
icon: h('span.cptools.cptools-new-template') icon: h('span.cptools.cptools-new-template')
}); });
} }
if (!privateData.newTemplate) {
allData.unshift({ allData.unshift({
name: Messages.creation_noTemplate, name: Messages.creation_noTemplate,
id: 0, id: 0,
//icon: h('span.fa.fa-file') //icon: h('span.fa.fa-file')
icon: UI.getFileIcon({type: type}) icon: UI.getFileIcon({type: type})
}); });
}
var redraw = function (index) { var redraw = function (index) {
if (index < 0) { i = 0; } if (index < 0) { i = 0; }
else if (index > allData.length - 1) { return; } else if (index > allData.length - 1) { return; }

@ -488,6 +488,8 @@ define([
fileHost: ApiConfig.fileHost, fileHost: ApiConfig.fileHost,
readOnly: readOnly, readOnly: readOnly,
isTemplate: isTemplate, isTemplate: isTemplate,
newTemplate: Array.isArray(Cryptpad.initialPath)
&& Cryptpad.initialPath[0] === "template",
feedbackAllowed: Utils.Feedback.state, feedbackAllowed: Utils.Feedback.state,
isPresent: parsed.hashData && parsed.hashData.present, isPresent: parsed.hashData && parsed.hashData.present,
isEmbed: parsed.hashData && parsed.hashData.embed, isEmbed: parsed.hashData && parsed.hashData.embed,
@ -1662,6 +1664,7 @@ define([
nThen(function(waitFor) { nThen(function(waitFor) {
if (data.templateId) { if (data.templateId) {
if (data.templateId === -1) { if (data.templateId === -1) {
isTemplate = true;
initialPathInDrive = ['template']; initialPathInDrive = ['template'];
return; return;
} }

@ -74,6 +74,7 @@ define([
}; };
window.addEventListener('message', whenReady); window.addEventListener('message', whenReady);
}).nThen(function () { }).nThen(function () {
var isTemplate = config.data.isTemplate;
var updateMeta = function () { var updateMeta = function () {
//console.log('EV_METADATA_UPDATE'); //console.log('EV_METADATA_UPDATE');
var metaObj; var metaObj;
@ -85,6 +86,12 @@ define([
} }
metaObj = n; metaObj = n;
})); }));
if (typeof(isTemplate) === "undefined") {
Cryptpad.isTemplate(currentPad.href, waitFor(function (err, t) {
if (err) { console.log(err); }
isTemplate = t;
}));
}
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
metaObj.doc = {}; metaObj.doc = {};
var additionalPriv = { var additionalPriv = {
@ -96,7 +103,7 @@ define([
feedbackAllowed: Utils.Feedback.state, feedbackAllowed: Utils.Feedback.state,
hashes: config.data.hashes, hashes: config.data.hashes,
password: config.data.password, password: config.data.password,
isTemplate: config.data.isTemplate, isTemplate: isTemplate,
file: config.data.file, file: config.data.file,
}; };
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; } for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }

Loading…
Cancel
Save