From c257868e80bedf9171fc31bf6fe70e012762352c Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Tue, 30 Jun 2026 02:04:46 +0000 Subject: [PATCH 1/2] fix(ui): hide disabled media browser buttons --- motioneye/static/js/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index a45cf24b9..d833d0e98 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -4835,6 +4835,12 @@ function addCameraFrameUi(cameraConfig) { picturesButton.hide(); moviesButton.hide(); } + else if (!cameraConfig['still_images']) { + picturesButton.hide(); + } + if (cameraConfig['proto'] != 'mjpeg' && !cameraConfig['movies']) { + moviesButton.hide(); + } cameraFrameDiv.attr('id', 'camera' + cameraId); cameraFrameDiv[0].refreshDivider = 0; From c154a74c88c3a847c7cca8e57395f60d3ae43cbd Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Wed, 1 Jul 2026 07:37:21 +0900 Subject: [PATCH 2/2] address review: keep the media button when old files still exist Per @Marijn0's review: hiding a media-browser button purely on the capture-mode flag also cut off access to media recorded before the mode was disabled. Now, when a capture mode is disabled, the button is hidden only after an async check of the existing list endpoint (with_stat=false) finds no files of that type. Enabled modes issue no request, and simple MJPEG cameras still hide both buttons. Co-Authored-By: Claude Opus 4.8 --- motioneye/static/js/main.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index d833d0e98..b6f1affda 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -4719,6 +4719,17 @@ function runMediaDialog(cameraId, mediaType) { /* camera frames */ +function hideMediaButtonIfEmpty(cameraId, mediaType, button) { + /* the list endpoint returns {mediaList: [...]} (empty when there are no + * files); with_stat=false keeps the request cheap. On error the button is + * left visible (safe default - don't hide when we are unsure). */ + ajax('GET', basePath + mediaType + '/' + cameraId + '/list/?with_stat=false', null, function (data) { + if (data && data.mediaList && !data.mediaList.length) { + button.hide(); + } + }); +} + function addCameraFrameUi(cameraConfig) { var cameraId = cameraConfig.id; @@ -4835,11 +4846,16 @@ function addCameraFrameUi(cameraConfig) { picturesButton.hide(); moviesButton.hide(); } - else if (!cameraConfig['still_images']) { - picturesButton.hide(); - } - if (cameraConfig['proto'] != 'mjpeg' && !cameraConfig['movies']) { - moviesButton.hide(); + else { + /* when a capture mode is disabled, only hide its media-browser button + * if there are no existing files left to browse, so media recorded + * before disabling capture stays accessible (#2731) */ + if (!cameraConfig['still_images']) { + hideMediaButtonIfEmpty(cameraId, 'picture', picturesButton); + } + if (!cameraConfig['movies']) { + hideMediaButtonIfEmpty(cameraId, 'movie', moviesButton); + } } cameraFrameDiv.attr('id', 'camera' + cameraId);