fix(ui): hide disabled media browser buttons when empty - #3387
Open
JamBalaya56562 wants to merge 3 commits into
Open
fix(ui): hide disabled media browser buttons when empty#3387JamBalaya56562 wants to merge 3 commits into
JamBalaya56562 wants to merge 3 commits into
Conversation
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 <noreply@anthropic.com>
Marijn0
reviewed
Jul 1, 2026
Comment on lines
+4722
to
+4731
| 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(); | ||
| } | ||
| }); | ||
| } |
Collaborator
There was a problem hiding this comment.
I’m not sure we should call the media list endpoint just to decide whether to hide a button. Even with with_stat=false, this can still be resource-intensive for users with lots of saved files. Unfortunately, I don’t see an easy alternative solution either.
Contributor
Author
There was a problem hiding this comment.
Thanks, agreed that calling the full media list just to decide whether to hide the button would be too expensive for large media directories.
I addressed this in c23c3d8 by turning that request into a bounded existence check instead of a full listing:
- the UI now calls
/list/?with_stat=false&limit=1for the hide-button check; - the picture/movie list handlers parse an optional positive
limitquery parameter; - local media listing stops walking as soon as the requested number of matching files is found, so
limit=1returns after the first actual media file; - the limit is also respected across recursive subdirectories;
- remote camera list requests forward
with_stat=falseandlimit=1only when explicitly requested, while the default request remains unchanged for compatibility with older remote motionEye instances.
I also added tests for the early-stop behavior, handler query parsing, recursive limit handling, and remote query forwarding.
Tested with WSL/Linux:
pytest tests/test_mediafiles.py tests/test_remote.py tests/test_handlers/test_media_list_limit.py -q
65 passed, 123 subtests passed
pytest tests -q
146 passed, 10 warnings, 123 subtests passed
JamBalaya56562
force-pushed
the
codex/hide-disabled-media-browser-buttons
branch
from
July 2, 2026 00:16
09efcef to
c23c3d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Hide a media-browser button (Pictures / Movies) in the camera overlay when its capture mode is disabled and there are no existing files of that type to browse.
Fixes #2731.
Why
The overlay showed the media-browser buttons even when the corresponding capture feature was disabled, which is inconsistent with the camera settings. Simply hiding on the config flag (the first approach) would also cut off access to media recorded before the user disabled capture — per @Marijn0's review, the button should disappear only when it truly has nothing to show.
How
…/list/?with_stat=false) and the button is hidden only ifmediaListcomes back empty. Enabled modes issue no request; on error / while unsure the button stays visible (no flicker for the case that still has media).Validation
motioneye/static/js/main.js(+22/-0);node --checkpasses.Screenshots
Setup used for the comparison: one JPEG network camera, Still Images and Movies both disabled, and no media files stored for the camera. (Same camera/config on both servers; only the motionEye code differs.)
dev)…/list/?with_stat=false&limit=1check found no existing media. The other overlay buttons are unaffected.