Fix unwanted highlight matching when favorite had additional filters

This commit is contained in:
nathangray 2016-05-25 13:28:27 -06:00
parent 31b6c8607b
commit a46f418fb6

View File

@ -926,8 +926,10 @@ var AppJS = (function(){ "use strict"; return Class.extend(
if(!favorite || jQuery.isEmptyObject(favorite)) return; if(!favorite || jQuery.isEmptyObject(favorite)) return;
var match_count = 0; var match_count = 0;
var extra_keys = Object.keys(favorite.state);
for(var state_key in state) for(var state_key in state)
{ {
extra_keys.splice(extra_keys.indexOf(state_key),1);
if(typeof favorite.state != 'undefined' && typeof state[state_key] != 'undefined'&&typeof favorite.state[state_key] != 'undefined' && ( state[state_key] == favorite.state[state_key] || !state[state_key] && !favorite.state[state_key])) if(typeof favorite.state != 'undefined' && typeof state[state_key] != 'undefined'&&typeof favorite.state[state_key] != 'undefined' && ( state[state_key] == favorite.state[state_key] || !state[state_key] && !favorite.state[state_key]))
{ {
match_count++; match_count++;
@ -990,6 +992,11 @@ var AppJS = (function(){ "use strict"; return Class.extend(
return; return;
} }
} }
// Check for anything set that the current one does not have
for(var i = 0; i < extra_keys.length; i++)
{
if(favorite.state[extra_keys[i]]) return;
}
if(match_count > best_count) if(match_count > best_count)
{ {
best_match = this.dataset.id; best_match = this.dataset.id;