Repository navigation
Conversation
Add a personal set of favorite cameras for each signed-in user. The Live
view gets a star on every tile to add or remove a camera and a Favorites
toggle in the toolbar that filters the grid, persisted in the URL like the
collection and tag filters.
Backend
- Migration 0088 adds camera_favorites(user_id, camera_uuid, created_at)
with cascading deletes from users and streams. A NULL user_id holds the
installation-wide set used while authentication is disabled, the same
convention as live_saved_layouts.
- GET /api/camera-favorites lists the caller's favorites filtered to the
cameras in their live-view scope; PUT and DELETE
/api/camera-favorites/{camera_uuid} add and remove idempotently. Demo
and scoped-token identities are read-only (403 on writes). PUT answers
404 for unknown and out-of-scope cameras alike.
- Favorites are a personal preference, not camera configuration, so they
are not audited.
Frontend
- live/cameraFavorites.js exposes pure helpers plus a hook over the query
cache; the tile star and toolbar toggle live inside the existing
LiveView rather than a separate surface. All strings go through i18n.
Replaces the favorites half of #624 by zirocool93 with an implementation
that fits the existing live view and the project's language conventions.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Replacement for the favorites half of #624 (thanks @zirocool93 for the idea and the groundwork). Each signed-in user gets a personal set of favorite cameras: a star on every Live tile adds or removes a camera, and a Favorites toggle in the Live toolbar filters the grid. The filter is persisted in the URL (
?favorites=1) like the collection and tag filters.Unlike #624 this lives inside the existing
LiveViewrather than a separate mobile surface, has no forced UI-mode selector, and every string goes through i18n.Design notes
camera_favorites(user_id, camera_uuid, created_at)with cascading deletes fromusersandstreams.user_idholds the single installation-wide set, the same conventionlive_saved_layoutsuses for its owner, so favorites work without logins.GETonly returns cameras inside the caller's current live-view scope (sameAUTHZ_LIVE_VIEWfilter as layouts).PUTanswers 404 for unknown and out-of-scope cameras alike. Demo and scoped-token identities are read-only.API
Documented in
docs/API.mdunder Camera Favorites.Frontend
web/js/components/preact/live/cameraFavorites.js: pure helpers (set derivation, filtering, cache update, request shape) plususeCameraFavorites()over the query cache with optimistic cache update and invalidation.LiveView.jsx: toolbar toggle (shown when the user can modify favorites or already has some), tile star overlay (hidden in reorder mode and when controls are hidden), favorites-aware empty state. A stale?favorites=1does not blank the grid if favorites are unavailable.live.css, larger hit target on coarse pointers.Testing
test_db_camera_favorites(6): idempotent add keepscreated_at, per-user scoping, installation scope without a user, invalid and unknown cameras, user-deletion cascade, soft vs permanent stream deletion.test_api_handlers_camera_favorites(3): put/list/delete round trip, 400/404 paths, demo identity read-only with 403 on writes.web/tests/cameraFavorites.spec.js(4): set derivation and filtering, cache update ordering, request method and UUID encoding, failure propagation.npx vite buildclean; Jest 311/311; full ctest 144/145 with the one failure being the known local FFmpeg header mismatch intest_mp4_segment_boundaries.Not included
🤖 Generated with Claude Code