From 1fe5ef8e947e6621b4c3c70bf2fae3d96ebf3ded Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Mon, 8 Jun 2020 10:32:41 -0700 Subject: [PATCH] fix #79: errors when "infinite" selected on load I've never seen this happen in Chrome; each load/reload starts fresh, so infinite is never selected. But on Firefox it seems to remember the setting across reloads, triggering this bug. This bug was introduced in 58152e8: it started parsing/normalizing the HTML form into a Javascript field on change. It didn't handle the initial load properly. Prior to that commit, fetch() simply read directly from the HTML form, so it didn't care about initial vs update. --- ui-src/lib/views/NVRSettingsView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui-src/lib/views/NVRSettingsView.js b/ui-src/lib/views/NVRSettingsView.js index 05de622..95594ae 100644 --- a/ui-src/lib/views/NVRSettingsView.js +++ b/ui-src/lib/views/NVRSettingsView.js @@ -84,11 +84,11 @@ export default class NVRSettingsView { */ wireControls_() { const videoLengthEl = $(`#${this.ids_.videoLenId}`); - this.videoLength_ = this.findSelectedOrFirst_(videoLengthEl); + + function normalize(v) { return v == 'infinite' ? Infinity : Number(v); } + this.videoLength_ = normalize(this.findSelectedOrFirst_(videoLengthEl)); videoLengthEl.change((e) => { - const newValueStr = e.currentTarget.value; - this.videoLength_ = - newValueStr == 'infinite' ? Infinity : Number(newValueStr); + this.videoLength_ = normalize(e.currentTarget.value); if (this.videoLengthHandler_) { this.videoLengthHandler_(this.videoLength_); }