From c1b658e3745505f0d16d91d5a9813f6f1cd2a1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 13 Apr 2023 11:31:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20webcam=20view=20w/=20one?= =?UTF-8?q?=20webcam=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In that case the nav container isn't available, and thus the attempt to select the first link from that to activate simply failed silently. Instead we now check whether the nav container is even there, and if not just activate the first tab pane. Closes #4791 --- src/octoprint/static/js/app/viewmodels/control.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 107d28c6d..9601f7f6f 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -77,6 +77,12 @@ $(function () { const selectedCameraStorageKey = "core.control.selectedCamera"; self.selectDefaultWebcam = function () { + if (!document.querySelector("#webcam_plugins_container .nav")) { + // we only have one webcam plugin, select that and be done (note: this bypasses local storage) + $("#webcam-group .tab-pane:first").addClass("active"); + return; + } + let div = localStorage[selectedCameraStorageKey]; if (!div || document.getElementById(div.slice(1)) === null) {