Skip to content

Conversation

@madsrasmussen
Copy link
Contributor

@madsrasmussen madsrasmussen commented Oct 16, 2025

Due to the extendable and async collection filter/orderBy initialization, multiple calls to the requestCollection method can occur within a very short period. This can result in several server calls, with combined arguments generated by the filters.

This PR replicates the solution from the tree context to prevent multiple load calls within a short timeframe. We achieve this by debouncing the load method.

I also noticed that the Media Collection Context both dispatched an event and called requestCollection after the upload was completed. This resulted in multiple server requests. I have removed the requestCollection call because the event covers both the collection and the sidebar menu.

The PR deprecates the public requestCollection method on the context and introduces a debounced loadCollection instead.

How to Test:

  • Ensure that a document with a collection no longer makes two requests to the collection endpoint upon loading.
  • Ensure that the media root/folder no longer makes two requests to the collection endpoint after an upload is complete.

@madsrasmussen madsrasmussen added the category/performance Fixes for performance (generally cpu or memory) fixes label Oct 16, 2025
@madsrasmussen madsrasmussen marked this pull request as ready for review October 16, 2025 13:16
@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 13:16
Copy link
Contributor

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 debounces collection loading to prevent multiple rapid server calls triggered by async filter/orderBy initialization, and deprecates the public requestCollection API in favor of a debounced loadCollection. It also removes a redundant collection reload after media upload completion.

  • Introduces debounced loadCollection on UmbDefaultCollectionContext and deprecates requestCollection.
  • Updates document/media collection contexts to forward deprecated calls to a new protected _requestCollection.
  • Removes an extra requestCollection invocation on media upload completion to avoid duplicate requests.

Reviewed Changes

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

Show a summary per file
File Description
src/Umbraco.Web.UI.Client/src/packages/media/media/collection/media-collection.element.ts Removes a redundant collection reload after upload completion to avoid duplicate requests.
src/Umbraco.Web.UI.Client/src/packages/media/media/collection/media-collection.context.ts Deprecates requestCollection and introduces protected _requestCollection; adds deprecation warning.
src/Umbraco.Web.UI.Client/src/packages/documents/documents/collection/document-collection.context.ts Deprecates requestCollection and forwards to protected _requestCollection; updates super call accordingly.
src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.element.ts Switches initial load from requestCollection to debounced loadCollection.
src/Umbraco.Web.UI.Client/src/packages/core/collection/default/collection-default.context.ts Adds debounced loadCollection, deprecates requestCollection, and routes internal calls to _requestCollection.

@madsrasmussen madsrasmussen changed the title Collection: prevent multiple load calls within a short time Collection: prevent multiple load calls within a very short time Oct 16, 2025
@madsrasmussen madsrasmussen merged commit bd6ab83 into release/17.0 Oct 23, 2025
23 checks passed
@madsrasmussen madsrasmussen deleted the v17/hotfix/debounce-context-load-collection-calls branch October 23, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category/performance Fixes for performance (generally cpu or memory) fixes release/17.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants