From 59ad96e491c9a25e448c591700f4a35b5a4b9861 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 16:11:50 +0200 Subject: [PATCH 1/4] Make sure the user is redirected to the drive at registration --- www/register/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/register/main.js b/www/register/main.js index 7de37e8bf..1b7103cac 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -85,6 +85,8 @@ define([ Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.login(result.userHash, result.userName, function () { registering = false; + /* + FIXME: migration and readme not working if not redirected to drive if (sessionStorage.redirectTo) { var h = sessionStorage.redirectTo; var parser = document.createElement('a'); @@ -95,6 +97,7 @@ define([ return; } } + */ window.location.href = '/drive/'; }); }); From 138ad17e3e1f5d8933325e6bbb6943cd3d541cc6 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 17:09:26 +0200 Subject: [PATCH 2/4] Fix 'import local pads' in settings creating duplicates --- www/common/mergeDrive.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index ce3e0b157..0cbe312bf 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -111,12 +111,14 @@ define([ var newFo = newData.fo; var oldRecentPads = parsed.drive[newFo.FILES_DATA]; var newRecentPads = proxy.drive[newFo.FILES_DATA]; - var newFiles = newFo.getFiles([newFo.FILES_DATA]); var oldFiles = oldFo.getFiles([newFo.FILES_DATA]); + var newHrefs = Object.keys(newRecentPads).map(function (id) { + return newRecentPads[id].href; + }); oldFiles.forEach(function (id) { var href = oldRecentPads[id].href; // Do not migrate a pad if we already have it, it would create a duplicate in the drive - if (newFiles.indexOf(id) !== -1) { return; } + if (newHrefs.indexOf(href) !== -1) { return; } // If we have a stronger version, do not add the current href if (Cryptpad.findStronger(href, newRecentPads)) { return; } // If we have a weaker version, replace the href by the new one From a8eecee590faf5f9f9fa8ccefe3791d842621ef1 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 17:29:31 +0200 Subject: [PATCH 3/4] Fix access to undefined variable in drive --- www/common/userObject.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/www/common/userObject.js b/www/common/userObject.js index 3f4ab7dd6..ddacbb806 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -456,7 +456,7 @@ define([ }; exp.getRecentPads = function () { var allFiles = files[FILES_DATA]; - var sorted = Object.keys(allFiles) + var sorted = Object.keys(allFiles).filter(function (a) { return allFiles[a]; }) .sort(function (a,b) { return allFiles[a].atime < allFiles[b].atime; }) @@ -1037,20 +1037,6 @@ define([ } }); }; - var migrateAttributes = function (el, id, parsed) { - // Migrate old pad attributes - ['userid', 'previewMode'].forEach(function (attr) { - var key = parsed.hash + '.' + attr; - var key2 = parsed.hash.slice(0,-1) + '.' + attr;// old pads not ending with / - if (typeof(files[key]) !== "undefined" || typeof(files[key2]) !== "undefined") { - debug("Migrating pad attribute", attr, "for pad", id); - el[attr] = files[key] || files[key2]; - delete files[key]; - delete files[key2]; - } - }); - // Migration done - }; var fixFilesData = function () { if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; } var fd = files[FILES_DATA]; @@ -1077,8 +1063,6 @@ define([ continue; } - migrateAttributes(el, id, parsed); - if ((Cryptpad.isLoggedIn() || config.testMode) && rootFiles.indexOf(id) === -1) { debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el); var newName = Cryptpad.createChannelId(); From 1fd7a6e2b32fcc61edadb9e6d893f42d22ab2bb9 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 25 Sep 2017 18:03:31 +0200 Subject: [PATCH 4/4] Mistake in mkEvent which makes all events only work once --- www/common/common-util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/common-util.js b/www/common/common-util.js index 4015fbfe4..c6cbe4055 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -16,7 +16,7 @@ define([], function () { handlers.splice(handlers.indexOf(cb), 1); }, fire: function () { - if (fired) { return; } + if (once && fired) { return; } fired = true; var args = Array.prototype.slice.call(arguments); handlers.forEach(function (h) { h.apply(null, args); });