From 92050eb04f7cbd52cb5cc471625c8cecf23381e0 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 14 Feb 2017 10:56:38 +0100 Subject: [PATCH] Fix the trash button in toolbar not always working --- www/common/cryptpad-common.js | 3 ++- www/common/fileObject.js | 2 ++ www/drive/main.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index a0fbbd778..acba58503 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -400,6 +400,7 @@ define([ }; var getRelativeHref = common.getRelativeHref = function (href) { + if (!href) { return; } var parsed = common.parsePadUrl(href); return '/' + parsed.type + '/#' + parsed.hash; }; @@ -563,7 +564,7 @@ define([ }; if (typeof(getStore().forgetPad) === "function") { - getStore().forgetPad(href, callback); + getStore().forgetPad(common.getRelativeHref(href), callback); } }; diff --git a/www/common/fileObject.js b/www/common/fileObject.js index 35ea31375..99cf742a3 100644 --- a/www/common/fileObject.js +++ b/www/common/fileObject.js @@ -698,6 +698,7 @@ define([ var forgetPad = exp.forgetPad = function (href) { if (workgroup) { return; } + if (!href) { return; } var rootFiles = getRootFiles().slice(); if (rootFiles.indexOf(href) !== -1) { removeFileFromRoot(files[ROOT], href); @@ -712,6 +713,7 @@ define([ var addUnsortedPad = exp.addPad = function (href, path, name) { if (workgroup) { return; } + if (!href) { return; } var unsortedFiles = getUnsortedFiles(); var rootFiles = getRootFiles(); var trashFiles = getTrashFiles(); diff --git a/www/drive/main.js b/www/drive/main.js index 83fc6eb26..c1e2a3021 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -1810,6 +1810,8 @@ define([ return false; }).on('remove', [], function (o, p) { var path = arguments[1]; + if (path[0] !== 'drive') { return false; } + path = path.slice(1); var cPath = currentPath.slice(); if ((filesOp.isPathInUnsorted(cPath) && filesOp.isPathInUnsorted(path)) || (filesOp.isPathInTemplate(cPath) && filesOp.isPathInTemplate(path)) ||