Skip to content

Conversation

iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented Aug 14, 2025

Description

Fixes #19830

This pull request introduces several improvements to the media imaging system, focusing on cache management, event-driven thumbnail updates, and API enhancements. The changes ensure that image thumbnails are refreshed when media items are updated, and that the cache is properly cleared after media modifications. Additionally, the imaging repository and store APIs have been expanded to support more flexible cache operations and improved type safety.

Event-driven thumbnail refresh and cache management:

  • The umb-imaging-thumbnail component now listens for media update events and refreshes its thumbnail automatically when the corresponding media item is updated. This ensures that users always see the latest image without manual refresh. [1] [2]
  • The UmbMediaDetailRepository now clears the image cache for a media item whenever it is saved or deleted, preventing stale thumbnails after media changes.

Imaging repository and store API enhancements:

  • The UmbImagingRepository class now supports asynchronous initialization, optional data store usage, and new methods for clearing the cache globally or by unique identifier. The requestThumbnailUrls method is now deprecated in favor of requestResizedItems, which provides more flexibility. [1] [2] [3]
  • The UmbImagingStore class now offers methods to clear all crops, clear crops by unique identifier, and clear crops by configuration, improving cache control and maintainability. Type annotations have been added for better type safety. [1] [2] [3]

Code quality and usage improvements:

  • Minor fixes to property binding in the media grid view and import ordering for clarity and correctness. [1] [2]

These updates collectively enhance the reliability and flexibility of media thumbnail management in the application.

How to test

  1. Create a media item with a file, fx an Image
  2. See that the thumbnail of the image loads in the collection view
  3. Click into the image so it opens in an overlay, and replace the file
  4. Click save
  5. Verify that a new thumbnail of the image is loaded

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where replacing media files doesn't update the preview by implementing event-driven thumbnail updates and comprehensive cache management. The changes ensure that image thumbnails are automatically refreshed when media items are updated.

  • Introduces automatic thumbnail refresh when media items are updated via event listeners
  • Adds cache clearing functionality to the imaging repository and store
  • Deprecates the old requestThumbnailUrls method in favor of the more flexible requestResizedItems

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
media-detail.repository.ts Adds cache clearing after save/delete operations
media-grid-collection-view.element.ts Fixes property binding and import ordering
imaging.store.ts Adds cache management methods and improves type safety
imaging.repository.ts Enhances API with async initialization and cache clearing methods
imaging-thumbnail.element.ts Implements event-driven thumbnail refresh and updates rendering logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@iOvergaard iOvergaard requested a review from leekelleher August 22, 2025 11:46
Copy link
Contributor

@madsrasmussen madsrasmussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works as expected 🥳

Would it be ok with you if we leave the caching part out of this PR? I would like to align it with the detail and item caching instead.

@iOvergaard iOvergaard merged commit 6a4c779 into main Aug 26, 2025
26 of 27 checks passed
@iOvergaard iOvergaard deleted the v16/bugfix/replacing-media-files-does-not-update-the-preview branch August 26, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replacing media files does not update the preview
2 participants