From eacfffed83b312baf1f4f7b9f75ef8015acb4a6c Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 29 Oct 2020 15:10:39 +0100 Subject: [PATCH] Fix issue newPadPath with new templates --- www/common/common-ui-elements.js | 14 ++++++++------ www/common/sframe-common-outer.js | 3 +++ www/secureiframe/main.js | 9 ++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 8b9415220..27aef1960 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2269,12 +2269,14 @@ define([ icon: h('span.cptools.cptools-new-template') }); } - allData.unshift({ - name: Messages.creation_noTemplate, - id: 0, - //icon: h('span.fa.fa-file') - icon: UI.getFileIcon({type: type}) - }); + if (!privateData.newTemplate) { + allData.unshift({ + name: Messages.creation_noTemplate, + id: 0, + //icon: h('span.fa.fa-file') + icon: UI.getFileIcon({type: type}) + }); + } var redraw = function (index) { if (index < 0) { i = 0; } else if (index > allData.length - 1) { return; } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 7170814d8..ebf15152b 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -494,6 +494,8 @@ define([ fileHost: ApiConfig.fileHost, readOnly: readOnly, isTemplate: isTemplate, + newTemplate: Array.isArray(Cryptpad.initialPath) + && Cryptpad.initialPath[0] === "template", feedbackAllowed: Utils.Feedback.state, isPresent: parsed.hashData && parsed.hashData.present, isEmbed: parsed.hashData && parsed.hashData.embed, @@ -1659,6 +1661,7 @@ define([ nThen(function(waitFor) { if (data.templateId) { if (data.templateId === -1) { + isTemplate = true; initialPathInDrive = ['template']; return; } diff --git a/www/secureiframe/main.js b/www/secureiframe/main.js index eca166592..060248097 100644 --- a/www/secureiframe/main.js +++ b/www/secureiframe/main.js @@ -74,6 +74,7 @@ define([ }; window.addEventListener('message', whenReady); }).nThen(function () { + var isTemplate = config.data.isTemplate; var updateMeta = function () { //console.log('EV_METADATA_UPDATE'); var metaObj; @@ -85,6 +86,12 @@ define([ } metaObj = n; })); + if (typeof(isTemplate) === "undefined") { + Cryptpad.isTemplate(currentPad.href, waitFor(function (err, t) { + if (err) { console.log(err); } + isTemplate = t; + })); + } }).nThen(function (/*waitFor*/) { metaObj.doc = {}; var additionalPriv = { @@ -96,7 +103,7 @@ define([ feedbackAllowed: Utils.Feedback.state, hashes: config.data.hashes, password: config.data.password, - isTemplate: config.data.isTemplate, + isTemplate: isTemplate, file: config.data.file, }; for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }