don't allow setting image quality to empty value, #3894

This commit is contained in:
zadam
2023-05-09 23:32:06 +02:00
parent 331d280075
commit cc1f831a6a
3 changed files with 9 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ function getOptionOrNull(name) {
// e.g. in initial sync becca is not loaded because DB is not initialized
option = sql.getRow("SELECT * FROM options WHERE name = ?", name);
}
return option ? option.value : null;
}
@@ -27,13 +27,17 @@ function getOption(name) {
/**
* @returns {number}
*/
function getOptionInt(name) {
function getOptionInt(name, defaultValue = undefined) {
const val = getOption(name);
const intVal = parseInt(val);
if (isNaN(intVal)) {
throw new Error(`Could not parse "${val}" into integer for option "${name}"`);
if (defaultValue === undefined) {
throw new Error(`Could not parse "${val}" into integer for option "${name}"`);
} else {
return defaultValue;
}
}
return intVal;