Repository Details Manager: Prevent making requests for empty arrays (#19731)

* fix: Prevent Repository Details Manager making requests for empty arrays

Fixes #19604

* Reworked to pass the `uniques` through to the `#requestNewDetails()` method

The unique values are included as a closure,
persisting after the `#init` promise is resolved.
Rather than call `getUniques()` to get an async'd value.

* Updated with Copilot suggestions

https://github.com/umbraco/Umbraco-CMS/pull/19731#discussion_r2221512463
This commit is contained in:
Lee Kelleher
2025-07-22 09:16:38 +01:00
committed by GitHub
parent 8cc6508b22
commit df9b387175

View File

@@ -88,7 +88,7 @@ export class UmbRepositoryDetailsManager<DetailType extends { unique: string }>
this.removeUmbControllerByAlias('observeEntry_' + entry);
});
this.#requestNewDetails();
this.#requestNewDetails(uniques);
},
null,
);
@@ -181,13 +181,13 @@ export class UmbRepositoryDetailsManager<DetailType extends { unique: string }>
return this.#entries.asObservablePart((items) => items.find((item) => item.unique === unique));
}
async #requestNewDetails(): Promise<void> {
async #requestNewDetails(uniques?: Array<DetailType['unique']>): Promise<void> {
if (!uniques?.length) return;
await this.#init;
if (!this.repository) throw new Error('Repository is not initialized');
const requestedUniques = this.getUniques();
const newRequestedUniques = requestedUniques.filter((unique) => {
const newRequestedUniques = uniques.filter((unique) => {
const item = this.#statuses.getValue().find((status) => status.unique === unique);
return !item;
});