From 002e22ee9a6736c8e0f7962b9f76cde73d3ca61f Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 4 Nov 2016 16:17:59 +0100 Subject: [PATCH] turn off unwanted behaviour until we can do it correctly --- www/poll/main.js | 57 ++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index 4cf46da73..6eb063487 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -72,6 +72,23 @@ define([ }); }; + var getLastName = module.getLastName = function (cb) { + Cryptpad.getAttribute('username', function (err, userName) { + cb(err, userName || ''); + }); + }; + + var setName = module.setName = function (uname, cb) { + if (typeof(uname) !== 'string') { + return void cb(new Error('expected string')); + } + uname = Cryptpad.fixHTML(uname.trim()).slice(0, 32); + Cryptpad.setAttribute('username', uname, function (err, data) { + if (err) { return void cb(err); } + cb(void 0, uname); + }); + }; + module.Wizard = Wizard; // special UI elements @@ -825,6 +842,10 @@ define([ setEditable(true); + return; + + // shortcircuiting before all of this code since it's not quite the + // behaviour we want, and it's a bit of work to make it Do The Right Thing if (First) { // assume the first user to the poll wants to be the administrator... @@ -840,39 +861,33 @@ define([ module.activeColumn = ''; var promptForName = function () { - // HERE - Cryptpad.prompt(Messages.promptName, "", function (name, ev) { - if (name === null) { - name = ''; - } - if (!module.isEditable) { return; } + var followUp = function (name) { + if (!name) { return; } var id = module.activeColumn = coluid(); Cryptpad.setPadAttribute('column', id, function (err) { - if (err) { - console.error("Couldn't remember your column id"); - return; - } - - console.log(id); + if (err) { return void console.error("Couldn't remember your column id"); } makeUser(module.rt.proxy, id, name).focus().val(name); makeUserEditable(id, true); }); + }; + + getLastName(function (err, uname) { + if (!uname) { + return void Cryptpad.prompt(Messages.promptName, "", function (name, ev) { + if (!(name || module.isEditable)) { return; } + followUp(name); + }); + } + followUp(uname); }); }; - if (column === null) { - //console.log("Looks like you're new to this poll, why don't you make a column"); - promptForName(); - return; - } + if (column === null) { return void promptForName(); } // column might be defined, but that column might have been deleted... - if (proxy.table.colsOrder.indexOf(column) === -1) { - promptForName(); - return; - } + if (proxy.table.colsOrder.indexOf(column) === -1) { return void promptForName(); } }); };