nextcloud / nextcloud/ios

Media view count doesn't update for new files - blocked by thumbnail download queue

Open
#3,974 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Open Nextcloud iOS app, go to Media view
  2. Note the count (e.g., "5207 Images • 630 Videos")
  3. Upload new photos from another device (or same device via auto-upload)
  4. Pull down to refresh / scroll around / close and reopen app
  5. Count remains unchanged
  6. Delete one photo from Media view
  7. Count decrements immediately (5206 Images)
  8. 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

  1. Add UIRefreshControl for pull-to-refresh that calls searchMediaUI(true)
  2. Remove or relax the downloadThumbnailQueue.operationCount == 0 condition
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.