From 8575f3f79f6866de479cbba4d0c52080125da2d0 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 5 Oct 2016 17:22:42 +0200 Subject: [PATCH] Fix the "rename" feature which was not working anymore in some cases --- www/common/cryptpad-common.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 888ee5e31..edae7673b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -446,20 +446,20 @@ define([ } var contains; - var renamed = recent.map(function (pad) { var p = parsePadUrl(pad.href); if (p.type !== parsed.type) { return pad; } + var shouldUpdate = p.hash === parsed.hash; + // Version 1 : we have up to 4 differents hash for 1 pad, keep the strongest : // Edit > Edit (present) > View > View (present) - var bypass = false; var pHash = parseHash(p.hash); var parsedHash = parseHash(parsed.hash); - if (pHash.version === 1 && parsedHash.version === 1 && pHash.channel === parsedHash.channel) { - if (pHash.mode === 'view' && parsedHash.mode === 'edit') { bypass = true; } - else if (pHash.mode === parsedHash.mode && pHash.present) { bypass = true; } + if (!shouldUpdate && pHash.version === 1 && parsedHash.version === 1 && pHash.channel === parsedHash.channel) { + if (pHash.mode === 'view' && parsedHash.mode === 'edit') { shouldUpdate = true; } + else if (pHash.mode === parsedHash.mode && pHash.present) { shouldUpdate = true; } else { // Editing a "weaker" version of a stored hash : update the date and do not push the current hash pad.atime = new Date().toISOString(); @@ -468,7 +468,7 @@ define([ } } - if (p.hash === parsed.hash || bypass) { + if (shouldUpdate) { contains = true; // update the atime pad.atime = new Date().toISOString();