From 79884e2400561e19ee9fdd8b5ffb8b054fadc419 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Sep 2016 17:12:46 +0200 Subject: [PATCH] Use the same username for all pads --- www/code/main.js | 4 ++-- www/common/cryptpad-common.js | 12 ++++++++++++ www/pad/main.js | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/www/code/main.js b/www/code/main.js index 684a813f1..6fffd26ec 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -186,7 +186,7 @@ define([ name: myUserName }; addToUserList(myData); - Cryptpad.setPadAttribute('username', myUserName, function (err, data) { + Cryptpad.setAttribute('username', myUserName, function (err, data) { if (err) { console.log("Couldn't set username"); console.error(err); @@ -197,7 +197,7 @@ define([ }; var getLastName = function (cb) { - Cryptpad.getPadAttribute('username', function (err, userName) { + Cryptpad.getAttribute('username', function (err, userName) { cb(err, userName || ''); }); }; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 125df6a79..3185f462c 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -318,6 +318,12 @@ define([ cb(err, data); }); }; + var setAttribute = common.setAttribute = function (attr, value, cb, legacy) { + getStore(legacy).set(["cryptpad", attr].join('.'), value, function (err, data) { + cb(err, data); + }); + }; + // STORAGE var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) { @@ -325,6 +331,12 @@ define([ cb(err, data); }); }; + var getAttribute = common.getAttribute = function (attr, cb, legacy) { + getStore(legacy).get(["cryptpad", attr].join('.'), function (err, data) { + cb(err, data); + }); + }; + // STORAGE /* fetch and migrate your pad history from localStorage */ diff --git a/www/pad/main.js b/www/pad/main.js index f104b4fc4..02a0e49f4 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -269,7 +269,7 @@ define([ }; var getLastName = function (cb) { - Cryptpad.getPadAttribute('username', function (err, userName) { + Cryptpad.getAttribute('username', function (err, userName) { cb(err, userName || ''); }); }; @@ -287,7 +287,7 @@ define([ addToUserList(myData); editor.fire('change'); - Cryptpad.setPadAttribute('username', newName, function (err, data) { + Cryptpad.setAttribute('username', newName, function (err, data) { if (err) { console.error("Couldn't set username"); }