Skip to content

refactor(media): move image cache window management into NCImageCache - #4207

Merged
marinofaggiana merged 5 commits into
masterfrom
ui-media-fix
Jul 27, 2026
Merged

refactor(media): move image cache window management into NCImageCache#4207
marinofaggiana merged 5 commits into
masterfrom
ui-media-fix

Conversation

@marinofaggiana

@marinofaggiana marinofaggiana commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR moves the image cache window management out of NCMedia and into NCImageCache, making the cache responsible for its own lifecycle and state.

Changes

  • Move cache window state (centerIndex, cache task, missing images, extension tracking) into NCImageCache.
  • Introduce ImageCacheWindowItem to decouple cache management from media metadata.
  • Move cache window update and preload logic into NCImageCache.
  • Build cache window items once in NCMediaDataSource instead of recreating them on every scroll.
  • Simplify NCMedia by delegating all cache window management to NCImageCache.
  • Clear the cache window state together with the image cache on memory warnings, background transitions, and layout changes.
  • Replace MainActor synchronization with an internal actor dedicated to cache window state, keeping cache management independent from the UI thread.

Benefits

  • Clear separation of responsibilities.
  • Less work performed during scrolling.
  • Reduced object allocations by reusing precomputed cache window items.
  • Better concurrency by isolating mutable cache state inside an actor instead of relying on the main thread.
  • Improved maintainability and easier future evolution of the media cache.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Resume interrupted cycles from the stored offset and skip completed cycles only until the weekly interval expires.

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Load avatars directly from disk while continuing background refreshes, and remove redundant preview cache preloading and cleanup.

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Move cache window state, loading, and invalidation into NCImageCache and precompute cache items in the media data source.

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Move media cache window state and loading into a dedicated actor to improve concurrency safety and remove main-actor restrictions.

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
@marinofaggiana marinofaggiana changed the title UI media fix refactor(media): move image cache window management into NCImageCache Jul 27, 2026
@marinofaggiana
marinofaggiana merged commit fe71097 into master Jul 27, 2026
3 of 4 checks passed
@marinofaggiana
marinofaggiana deleted the ui-media-fix branch July 27, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant