Media view count doesn't update for new files - blocked by thumbnail download queue
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.5k
- Forks
- 1k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 13
Description
Description
The Media view's photo/video count doesn't update when new files are uploaded to the server. The count only updates when clearing the app cache. However, deleting a file DOES update the count immediately.
Steps to reproduce
- Open Nextcloud iOS app, go to Media view
- Note the count (e.g., "5207 Images • 630 Videos")
- Upload new photos from another device (or same device via auto-upload)
- Pull down to refresh / scroll around / close and reopen app
- Count remains unchanged
- Delete one photo from Media view
- Count decrements immediately (5206 Images)
- New uploads still don't appear until cache is cleared
Expected behavior
The Media view should discover and display new files when refreshing, and the count should update accordingly.
Actual behavior
- Delete: Count updates immediately ✓
- Add: Count stays stale until cache is cleared ✗
Root cause analysis (from source code review)
Examined the source code and found multiple issues in iOSClient/Media/:
1. No pull-to-refresh
NCMedia.swift has no UIRefreshControl - users cannot manually trigger a refresh.
2. searchMediaUI() blocked by thumbnail downloads
In NCMediaDataSource.swift:51-58:
guard self.isViewActived,
!self.searchMediaInProgress,
!self.isPinchGestureActive,
!self.showOnlyImages,
!self.showOnlyVideos,
!self.isEditMode,
self.networking.downloadThumbnailQueue.operationCount == 0 else {
return false
}
The condition downloadThumbnailQueue.operationCount == 0 means searchMediaUI() is skipped whenever ANY thumbnails are being downloaded. When viewing a large photo library, thumbnails are always being fetched, so new file discovery never runs.
3. Delete bypasses the server fetch
In NCMedia+Command.swift:134:
self.dataSource.removeMetadata([ocId])
self.collectionView.deleteItems(at: [indexPath])
Delete directly modifies the dataSource without needing searchMediaUI(), which is why it works.
4. Full refresh only on cache clear
searchMediaUI(true) (which uses full date range) is only called on:
- Account change (
NCMedia.swift:138) - Cache clear (
NCMedia.swift:146)
Normal scrolling calls searchMediaUI() with distant=false, which only fetches within the visible date range.
Suggested fix
- Add
UIRefreshControlfor pull-to-refresh that callssearchMediaUI(true) - Remove or relax the
downloadThumbnailQueue.operationCount == 0condition - Periodically check for new files regardless of thumbnail queue status
Environment
- Nextcloud iOS app version: 7.2.2
- Server: Nextcloud 32.0.5
- iOS: 12.5.7 (iPhone 6) and iOS 17+ (iPhone 15) - same behavior on both
- Server confirms files exist with correct metadata indexed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading iOSClient/Media/NCMediaDataSource.swift, NCMedia.swift, and NCMedia+Command.swift, focusing on searchMediaUI(), the thumbnail queue guard, and the delete path. Reproduce the refresh behavior with new uploads and confirm that the count discovers them without clearing the cache, while deletes continue to update immediately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100