Set default time to 'this week' in discover params
This commit is contained in:
parent
9645bf0cc7
commit
ee34118b7d
|
@ -37,7 +37,7 @@ async function discover(params, options = {}) {
|
|||
|
||||
async function sanitizeDiscoverParams(params) {
|
||||
return getDiscoverOptions().then( options => {
|
||||
const getOptionValue = (optArr, value) => {
|
||||
const getOptionValue = (optArr, value, defaultIndex = 0) => {
|
||||
if (value !== undefined && optArr) {
|
||||
const opt = optArr.find( o => o.value == value );
|
||||
if (opt) {
|
||||
|
@ -45,7 +45,7 @@ async function sanitizeDiscoverParams(params) {
|
|||
}
|
||||
}
|
||||
if (optArr) {
|
||||
return optArr[0].value;
|
||||
return optArr[defaultIndex].value;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
@ -66,7 +66,7 @@ async function sanitizeDiscoverParams(params) {
|
|||
// or subgenre is 'all-metal')
|
||||
const timeAllowed = sanitized.subgenre === undefined || sanitized.subgenre == subgenreOptions[0].value;
|
||||
if (timeAllowed) {
|
||||
sanitized.time = getOptionValue(options.times, params.time);
|
||||
sanitized.time = getOptionValue(options.times, params.time, 1);
|
||||
}
|
||||
sanitized.location = getOptionValue(options.locations, params.location);
|
||||
sanitized.format = getOptionValue(options.formats, params.format);
|
||||
|
|
Loading…
Reference in New Issue
Block a user