prioritise targeted suggestions in products list:

- sort list so "targeted" (`show-if-active`) extensions are first
- don't randomly choose suggestion for product list, always choose
first one
This commit is contained in:
haszari 2019-03-08 13:48:00 +13:00
parent d575bf5013
commit e4ea021907
2 changed files with 9 additions and 4 deletions

View File

@ -263,7 +263,7 @@
return ! _.contains( marketplace_suggestions.active_plugins, promo['hide-if-active'] );
} );
// hide promos that are not applicable based on user's installed extensions
// hide promos that are not applicable based on user's active extensions
promos = _.filter( promos, function( promo ) {
if ( ! promo['show-if-active'] ) {
// this promotion is relevant to all
@ -274,6 +274,11 @@
return ( _.intersection( marketplace_suggestions.active_plugins, promo['show-if-active'] ).length > 0 );
} );
// sort the promos so extension-dependent ones are at the start of the list
promos = _.sortBy( promos, function( promo ) {
return _.isEmpty( promo['show-if-active'] ) ? 1 : 0;
} );
return promos;
}
@ -384,8 +389,8 @@
return;
}
// shuffle/randomly select the suggestion to display
var suggestionToDisplay = _.sample( promos );
// show the first suggestion from the list
var suggestionToDisplay = promos[0];
// dismiss is allowed by default
var allowDismiss = true;

File diff suppressed because one or more lines are too long