diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index 50188fd6e..fb9416f7c 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -2,8 +2,7 @@ define([ '/common/cryptpad-common.js', '/common/cryptget.js', '/common/userObject.js', - 'json.sortify' -], function (Cryptpad, Crypt, FO, Sortify) { +], function (Cryptpad, Crypt, FO) { var exp = {}; var getType = function (el) { diff --git a/www/common/userObject.js b/www/common/userObject.js index 320d91903..666d1e053 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -133,18 +133,6 @@ define([ return data.filename || data.title || NEW_FILE_NAME; }; - var getIdFromHref = exp.getIdFromHref = function (href) { - var result; - getFiles([FILES_DATA]).some(function (id) { - if (files[FILES_DATA][id].href === href) { - result = id; - return true; - } - return; - }); - return result; - }; - // PATHS var comparePath = exp.comparePath = function (a, b) { @@ -282,6 +270,18 @@ define([ return Cryptpad.deduplicateString(ret); }; + var getIdFromHref = exp.getIdFromHref = function (href) { + var result; + getFiles([FILES_DATA]).some(function (id) { + if (files[FILES_DATA][id].href === href) { + result = id; + return true; + } + return; + }); + return result; + }; + // SEARCH var _findFileInRoot = function (path, file) { if (!isPathIn(path, [ROOT, TRASH])) { return []; } @@ -415,7 +415,7 @@ define([ }; // FILES DATA - var pushFileData = exp.pushData = function (data, cb) { + exp.pushData = function (data, cb) { if (typeof cb !== "function") { cb = function () {}; } var todo = function () { var id = Cryptpad.createRandomInteger(); @@ -535,7 +535,7 @@ define([ } // Add to root if path is ROOT or if no path var filesList = getFiles([ROOT, TRASH, 'hrefArray']); - if (path && isPathIn(newPath, [ROOT]) || filesList.indexOf(href) === -1) { + if (path && isPathIn(newPath, [ROOT]) || filesList.indexOf(id) === -1) { parentEl = find(newPath || [ROOT]); if (parentEl) { var newName = getAvailableName(parentEl, Cryptpad.createChannelId()); @@ -618,7 +618,6 @@ define([ var allFilesPaths = paths.filter(function(x) { return isPathIn(x, [FILES_DATA]); }); if (!Cryptpad.isLoggedIn()) { - var toSplice = []; allFilesPaths.forEach(function (path) { var el = find(path); if (!el) { return; } @@ -717,8 +716,7 @@ define([ if (typeof cb === "function") { cb(); } return; } - var oldName = getTitle(element, 'name'); - if (oldName === newName) { return; } + if (getTitle(element, 'name') === newName) { return; } data.filename = newName; if (typeof cb === "function") { cb(); } }; @@ -771,7 +769,6 @@ define([ delete files[UNSORTED]; return; } - var root = find([ROOT]); us.forEach(function (el) { if (typeof el !== "string") { return; @@ -916,7 +913,9 @@ define([ delete tr[el]; } else { toClean = []; - tr[el].forEach(function (obj, idx) { addToClean(obj, idx, el); }); + for (var j=0; j