Improve getStrongerHash to also look inside shared folders

This commit is contained in:
yflory
2019-10-08 17:54:52 +02:00
parent e0a1b8724b
commit 4e4d01a471
4 changed files with 28 additions and 43 deletions

View File

@@ -420,36 +420,6 @@ Version 1
};
// STORAGE
Hash.findStronger = function (href, channel, recents) {
var parsed = parsePadUrl(href);
if (!parsed.hash) { return false; }
var parsedHash = parsed.hashData;
// We can't have a stronger hash if we're already in edit mode
if (!parsedHash || parsedHash.mode === 'edit') { return; }
// We don't have stronger/weaker versions of files or users
if (parsedHash.type !== 'pad') { return; }
var stronger;
Object.keys(recents).some(function (id) {
var pad = recents[id];
// Not the same channel? reject
if (channel !== pad.channel) { return; }
// If this pad doesn't have an edit link, it can't be stronger
// XXX encrypted href
if (!pad.href || !pad.roHref) { return; }
// This is a pad with an EDIT href and using the same channel as our target
// ==> it is stronger
stronger = pad;
return true;
});
return stronger;
};
Hash.hrefToHexChannelId = function (href, password) {
var parsed = Hash.parsePadUrl(href);
if (!parsed || !parsed.hash) { return; }