Sanitize: set default subgenre where applicable
This commit is contained in:
parent
bfe28315a0
commit
178059dc19
|
@ -50,11 +50,12 @@ async function sanitizeDiscoverParams(params) {
|
|||
};
|
||||
if (sanitized.sortBy !== 'rec') {
|
||||
// following only valid when sortBy is not 'rec' (artist-recommend)
|
||||
if (params.subgenre !== undefined && getOptionValue(options.subgenres[sanitized.genre], params.subgenre) !== null) {
|
||||
sanitized.subgenre = params.subgenre;
|
||||
const subgenreOptions = options.subgenres[sanitized.genre];
|
||||
if (subgenreOptions) { // false if genre is 'all'
|
||||
sanitized.subgenre = getOptionValue(subgenreOptions, params.subgenre);
|
||||
}
|
||||
if (sanitized.subgenre === undefined) {
|
||||
// 'time' only valid when 'subgenre' is not set
|
||||
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre === subgenreOptions[0].value;
|
||||
if (timeAllowed) {
|
||||
sanitized.time = getOptionValue(options.times, params.time);
|
||||
}
|
||||
sanitized.location = getOptionValue(options.locations, params.location);
|
||||
|
|
Loading…
Reference in New Issue
Block a user