feat: share an album from the desktop app - #1473
Conversation
The only way to render a scannable link without a network round trip, and QR generation was deliberately kept off the Python side.
Types mirror the Pydantic models in backend/app/schemas/share.py, which is the source of truth for the response shape.
Configures expiry and an optional password, then shows the QR code, the link and every address the share can be reached on. Machines with more than one interface get a picker, because which address a phone can reach depends on the network rather than on anything we can detect.
A shared album is ringed and badged, so what is currently reachable on the network is visible without opening anything.
The single column grew taller than the window, which put the buttons out of reach. The QR code, link and share details sit left, the address list and actions right, with the addresses capped and scrolling on their own. DialogContent also gains a height cap, since nothing bounded it before.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughThe frontend adds local-network album sharing. It includes share API wrappers, a QR-enabled share dialog, album-card sharing status, share creation and revocation controls, and tests for the new behavior. ChangesAlbum sharing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AlbumPage
participant ShareAlbumDialog
participant shareFunctions
participant Backend
AlbumPage->>shareFunctions: Load active shares
shareFunctions->>Backend: Request share list
Backend-->>shareFunctions: Return shares
shareFunctions-->>AlbumPage: Provide sharing status
AlbumPage->>ShareAlbumDialog: Open selected album
ShareAlbumDialog->>shareFunctions: Create or revoke share
shareFunctions->>Backend: Update album share
Backend-->>shareFunctions: Return share result
shareFunctions-->>ShareAlbumDialog: Update dialog
ShareAlbumDialog-->>AlbumPage: Notify share change
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/src/components/Albums/AlbumCard.tsx (1)
68-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the redundant comment.
Line 68 only repeats the condition below it. Remove the comment.
As per coding guidelines, “Write short comments that explain why rather than what.” As per path instructions, “Point out redundant obvious comments that do not add clarity to the code.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/components/Albums/AlbumCard.tsx` at line 68, Remove the redundant “Sharing Badge” comment immediately preceding the sharing badge condition in AlbumCard; leave the condition and its rendering behavior unchanged.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/Album/Album.tsx`:
- Around line 117-124: Update the sharesByAlbum handling in Album so multiple
active shares for the same album are preserved rather than reduced to one token.
Pass all shares into the share-management/revocation flow, or make creation
idempotent per album, and add an integration test covering two active shares
that verifies both are revoked and the album is no longer shared.
---
Nitpick comments:
In `@frontend/src/components/Albums/AlbumCard.tsx`:
- Line 68: Remove the redundant “Sharing Badge” comment immediately preceding
the sharing badge condition in AlbumCard; leave the condition and its rendering
behavior unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1cb38391-247a-4155-8e45-b7a3e4a64563
⛔ Files ignored due to path filters (1)
frontend/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
frontend/package.jsonfrontend/src/api/api-functions/index.tsfrontend/src/api/api-functions/share.tsfrontend/src/api/apiEndpoints.tsfrontend/src/components/Albums/AlbumCard.tsxfrontend/src/components/Albums/ShareAlbumDialog.tsxfrontend/src/components/Albums/__tests__/ShareAlbumDialog.test.tsxfrontend/src/pages/Album/Album.tsxfrontend/src/pages/__tests__/Album.test.tsxfrontend/src/types/Album.tsfrontend/src/types/Share.ts
Creating a share leaves earlier ones valid, so the page kept one token per album and dropped the rest. Stopping then reported the album was off the network while another token still served it.
Part of #1468
Adds the desktop side of album sharing, following the backend in #1469 and the password in #1471. An album can now be shared from its card, and the dialog hands back a QR code and a link to open on another device.
Sharing is offered from the album card's menu, and a shared album is ringed and badged in the grid so what is currently reachable on the network is visible without opening anything. The dialog asks for how long to keep sharing and whether to require a password, then shows the QR code, the link, and the addresses the share can be reached on. Reopening a shared album goes straight to that view, where the share can also be stopped.
Machines with more than one usable address get a picker, and the QR code follows the selection. Which address a phone can actually reach depends on the network rather than on anything the host can detect, so the choice belongs to the person sharing. The backend already ranks the candidates, so the first one is selected by default.
Active shares are read through react-query rather than a Redux slice. They exist only in the backend's memory, so the query is the record of them; a slice would have been a second source of truth for the same data. Redux stays where the rest of the codebase puts it, on UI state.
Not included
The backend counts no views and no downloads, and has no downloads toggle, so none of that is shown. A separate management dashboard is also left out for now: minus those figures it would be a list of shares with copy, QR and stop, which is what this dialog already does per album.
Dependency
One addition,
qrcode.react, to render the link as a scannable code. Generating it on the desktop side keeps the backend free of another dependency.Testing
Eight new tests covering creating a share with and without a password, rejecting a password the backend would refuse, switching addresses, and revoking, with the full suite at 359 passing. The album page's own tests needed the new query mocked.
Summary by CodeRabbit
New Features
Tests