diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 9418c2e79..9c1d2690c 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -719,7 +719,8 @@ define([ } } sframeChan.query('Q_SAVE_AS_TEMPLATE', { - toSave: toSave + toSave: toSave, + title: title }, function () { UI.alert(Messages.templateSaved); Feedback.send('TEMPLATE_CREATED'); diff --git a/www/common/cryptget.js b/www/common/cryptget.js index 5279a17c9..d08b4b297 100644 --- a/www/common/cryptget.js +++ b/www/common/cryptget.js @@ -28,9 +28,9 @@ define([ } }; - var makeConfig = function (hash, password) { + var makeConfig = function (hash, opt) { // We can't use cryptget with a file or a user so we can use 'pad' as hash type - var secret = Hash.getSecrets('pad', hash, password); + var secret = Hash.getSecrets('pad', hash, opt.password); if (!secret.keys) { secret.keys = secret.key; } // support old hashses var config = { websocketURL: NetConfig.getWebsocketURL(), @@ -38,6 +38,7 @@ define([ validateKey: secret.keys.validateKey || undefined, crypto: Crypto.createEncryptor(secret.keys), logLevel: 0, + initialState: opt.initialState }; return config; }; @@ -57,7 +58,7 @@ define([ } opt = opt || {}; - var config = makeConfig(hash, opt.password); + var config = makeConfig(hash, opt); var Session = { cb: cb, hasNetwork: Boolean(opt.network) }; config.onReady = function (info) { @@ -82,7 +83,7 @@ define([ } opt = opt || {}; - var config = makeConfig(hash, opt.password); + var config = makeConfig(hash, opt); var Session = { cb: cb, }; config.onReady = function (info) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 027b61929..7b9e939b1 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -512,6 +512,10 @@ define([ optsPut = optsPut || {}; var optsGet = {}; + + if (parsed.type === 'poll') { optsGet.initialState = '{}'; } + if (parsed2.type === 'poll') { optsPut.initialState = '{}'; } + Nthen(function (waitFor) { if (parsed.hashData && parsed.hashData.password) { common.getPadAttribute('password', waitFor(function (err, password) { diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index be0bcb9b8..e174ecad3 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -479,10 +479,11 @@ define([ Store.addPad = function (clientId, data, cb) { if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); } + var secret; if (!data.roHref) { var parsed = Hash.parsePadUrl(data.href); if (parsed.hashData.type === "pad") { - var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password); + secret = Hash.getSecrets(parsed.type, parsed.hash, data.password); data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret); } } @@ -490,7 +491,7 @@ define([ if (data.owners) { pad.owners = data.owners; } if (data.expire) { pad.expire = data.expire; } if (data.password) { pad.password = data.password; } - if (data.channel) { pad.channel = data.channel; } + if (data.channel || secret) { pad.channel = data.channel || secret.channel; } store.manager.addPad(data.path, pad, function (e) { if (e) { return void cb({error: e}); } sendDriveEvent('DRIVE_CHANGE', {