-
-
Notifications
You must be signed in to change notification settings - Fork 989
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