Repository navigation
Conversation
The viewer menu now shows Edit for an image Quick Look can modify when the device is online or the file is already stored locally, and the file context menu uses that same Edit title. A file already on the device still opens through the downloaded-file notification; otherwise, while online, the photo is marked for download with the Quick Look selector and the download is started. Unit tests check that an online preview-only image offers one Edit action and that building the menu leaves it undownloaded, and that a web view, a non-image, and an encrypted photo offer none. The new test file is included in the unit test target. Fixes nextcloud#4332 Assisted-by: AI Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
…ewer-edit-action Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
|
Thanks, Matt. Showing Edit for photos that only have a preview makes sense. I’d like to address two issues before merging.
Could you add regression coverage for these cases? The current tests verify whether Edit appears in the menu. The regressions above happen after the tap. |
Each Quick Look editor now owns its change flag, so opening a second editor no longer clears the first one's save prompt. Editors also get a temporary copy in their own directory, keeping the file name, so two photos with the same name never overwrite the file the other uploads. The download-then-open code moved into NCViewerQuickLook.presentEditor, which the Quick Look transfer selector now uses as well. Edit from the media viewer goes through the viewer's loader. The loader shares a download that is already running for the same photo, so Edit while Info downloads the original neither resets the transfer state nor starts a second download to the same path. Quick Look opens only if the viewer is still on screen and showing that photo when the download ends. New unit tests cover separate change flags, separate temporary files for same-name photos, joining a running download, and not opening the editor after the viewer moved on, closed, or the download failed. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Thanks @marinofaggiana, both are addressed in 8ce96c7. Isolated Quick Look sessions: Download tied to the Edit request: Edit from the media viewer now goes through the viewer's loader, which shares a download already running for the same photo ( Regression coverage is in |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow stale photo editors to be presented, queued downloads to continue after cancellation, and full-resolution temporary image copies to accumulate without cleanup.
3 open issues
What changed in this PR
This PR addresses #4332 by making photo editing available from the viewer’s overflow menu, including eligible photos whose originals are not yet downloaded.
Changes:
- Uses the Edit label in both viewer and file context menus.
- Adds viewer-aware editing, shared downloads, and isolated Quick Look editing sessions.
- Adds unit tests for menu eligibility, download sharing, and editing-session behavior.
| File | Description |
|---|---|
Tests/NextcloudUnitTests/NCViewerPhotoEditTests.swift |
Tests session isolation, shared downloads, and viewer-validity checks. |
Tests/NextcloudUnitTests/NCContextMenuViewerTests.swift |
Tests Edit availability and side-effect-free menu creation. |
Tests/NextcloudUnitTests/MockViewerPhotoEditSource.swift |
Provides a controllable viewer and download mock. |
Nextcloud.xcodeproj/project.pbxproj |
Registers the new tests and mock in the unit test target. |
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift |
Isolates editing state and temporary files; centralizes editor presentation. |
iOSClient/Viewer/NCViewerMedia/NCNextcloudMediaViewerLoader.swift |
Shares in-flight original-file downloads. |
iOSClient/Viewer/NCViewerMedia/NCMediaViewerHostingController.swift |
Connects the media viewer to the editing flow. |
iOSClient/Networking/NCNetworking+TransferDelegate.swift |
Uses the shared editor-presentation helper. |
iOSClient/Menu/NCContextMenuViewer.swift |
Adds eligible Edit actions and viewer-aware download handling. |
iOSClient/Menu/NCContextMenuMain.swift |
Renames the file context menu action to Edit. |
Review effort: Balanced
| let current = await NCManageDatabase.shared.getMetadataFromOcIdAsync(metadata.ocId) ?? metadata | ||
| NCViewerQuickLook.presentEditor(metadata: current, from: controller) |
| let directory = temporaryDirectory.appendingPathComponent("QuickLookEdit-" + UUID().uuidString, isDirectory: true) | ||
| do { | ||
| try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) |
The shared download ran in an unstructured task, so cancelling the viewer while it waited for a transfer slot left it queued. Each caller now registers on the shared operation; when the last one is cancelled the operation is cancelled too. cancelDownload(for:) and cancelAllDownloads() also cancel queued shared operations. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
0923dc8 to
b0a1f4c
Compare

While viewing a photo, the overflow menu has no way to edit it. Editing appears only from the file context menu, and only for some photos, under the label Modify. The viewer menu added that item only when the full image file was already on the device, so a photo that was only previewed or not yet downloaded was left out. Activating the item always notified transfer delegates that the file had already downloaded, using the Quick Look load selector. The title was the Modify string.
The viewer menu now shows Edit for an image Quick Look can modify when the device is online or the file is already stored locally, and the file context menu uses that same Edit title. A file already on the device still opens through the downloaded-file notification; otherwise, while online, the photo is marked for download with the Quick Look selector and the download is started. Unit tests check that an online preview-only image offers one Edit action and that building the menu leaves it undownloaded, and that a web view, a non-image, and an encrypted photo offer none. The new test file is included in the unit test target.
Tests for the ios NCContextMenuMain: change live in
Tests/NextcloudUnitTests/NCContextMenuViewerTests.swift.🤖 AI (if applicable)
AI was used for assistance.
Fixes #4332