Fix the "rename" feature which was not working anymore in some cases

pull/1/head
yflory 8 years ago
parent a989b51d74
commit 8575f3f79f

@ -446,20 +446,20 @@ define([
} }
var contains; var contains;
var renamed = recent.map(function (pad) { var renamed = recent.map(function (pad) {
var p = parsePadUrl(pad.href); var p = parsePadUrl(pad.href);
if (p.type !== parsed.type) { return pad; } 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 : // Version 1 : we have up to 4 differents hash for 1 pad, keep the strongest :
// Edit > Edit (present) > View > View (present) // Edit > Edit (present) > View > View (present)
var bypass = false;
var pHash = parseHash(p.hash); var pHash = parseHash(p.hash);
var parsedHash = parseHash(parsed.hash); var parsedHash = parseHash(parsed.hash);
if (pHash.version === 1 && parsedHash.version === 1 && pHash.channel === parsedHash.channel) { if (!shouldUpdate && pHash.version === 1 && parsedHash.version === 1 && pHash.channel === parsedHash.channel) {
if (pHash.mode === 'view' && parsedHash.mode === 'edit') { bypass = true; } if (pHash.mode === 'view' && parsedHash.mode === 'edit') { shouldUpdate = true; }
else if (pHash.mode === parsedHash.mode && pHash.present) { bypass = true; } else if (pHash.mode === parsedHash.mode && pHash.present) { shouldUpdate = true; }
else { else {
// Editing a "weaker" version of a stored hash : update the date and do not push the current hash // Editing a "weaker" version of a stored hash : update the date and do not push the current hash
pad.atime = new Date().toISOString(); pad.atime = new Date().toISOString();
@ -468,7 +468,7 @@ define([
} }
} }
if (p.hash === parsed.hash || bypass) { if (shouldUpdate) {
contains = true; contains = true;
// update the atime // update the atime
pad.atime = new Date().toISOString(); pad.atime = new Date().toISOString();

Loading…
Cancel
Save