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.
This commit is contained in:
Scott Lamb 2020-06-08 10:32:41 -07:00
parent 2b7a3a31e2
commit 1fe5ef8e94

View File

@ -84,11 +84,11 @@ export default class NVRSettingsView {
*/ */
wireControls_() { wireControls_() {
const videoLengthEl = $(`#${this.ids_.videoLenId}`); 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) => { videoLengthEl.change((e) => {
const newValueStr = e.currentTarget.value; this.videoLength_ = normalize(e.currentTarget.value);
this.videoLength_ =
newValueStr == 'infinite' ? Infinity : Number(newValueStr);
if (this.videoLengthHandler_) { if (this.videoLengthHandler_) {
this.videoLengthHandler_(this.videoLength_); this.videoLengthHandler_(this.videoLength_);
} }