diff --git a/web/src/prefs.js b/web/src/prefs.js index 3abf58843..dbe9400dd 100644 --- a/web/src/prefs.js +++ b/web/src/prefs.js @@ -71,14 +71,20 @@ export class Prefs extends EventTarget { if (value === null) { return fallback; } - if (value === 'true') { - return true; + + const type = typeof fallback; + if (type === 'boolean') { + if (value === 'true') { + return true; + } + if (value === 'false') { + return false; + } + return fallback; } - if (value === 'false') { - return false; - } - if (/^\d+$/.test(value)) { - return Number.parseInt(value, 10); + if (type === 'number') { + const f = Number.parseFloat(value); + return Number.isNaN(f) ? fallback : f; } return value; } diff --git a/web/src/transmission.js b/web/src/transmission.js index 52c88509d..e44981e4e 100644 --- a/web/src/transmission.js +++ b/web/src/transmission.js @@ -375,7 +375,8 @@ export class Transmission extends EventTarget { case Prefs.RefreshRate: { clearInterval(this.refreshTorrentsInterval); const callback = this.refreshTorrents.bind(this); - const msec = Math.max(2, this.prefs.refresh_rate_sec) * 1000; + const pref = this.prefs.refresh_rate_sec; + const msec = pref > 0 ? pref * 1000 : 1000; this.refreshTorrentsInterval = setInterval(callback, msec); break; }