Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@
async getContentTypeProperties() {
return await this.observe(this.contentTypeProperties).asPromise();
}
readonly contentTypeDataTypeUniques = this.#contentTypes.asObservablePart((contentTypes) => {
return contentTypes
.flatMap((x) => x.properties?.map((p) => p.dataType.unique) ?? [])
.filter(UmbFilterDuplicateStrings);
});

/**
* Get an observable for the data type detail of a data type that is in use by this content type structure.
Expand All @@ -137,10 +132,28 @@
readonly contentTypeLoaded = mergeObservables(
[this.contentTypeCompositions, this.contentTypeUniques],
([comps, uniques]) => {
return comps.every((x) => uniques.includes(x.contentType.unique));
return uniques.length > 0 && comps.every((x) => uniques.includes(x.contentType.unique));
},
);

// Derived from #contentTypes (single source) and gated on contentTypeLoaded, so property
// changes re-emit and properties can't lag behind loaded across separate microtasks. [NL]
readonly contentTypeDataTypeUniques = mergeObservables(
[this.contentTypeLoaded, this.contentTypes],
([loaded, contentTypes]) => {
if (!loaded) return [];
return contentTypes
.flatMap((x) => x.properties?.map((p) => p.dataType.unique) ?? [])
.filter(UmbFilterDuplicateStrings);
},
);
getContentTypeDataTypeUniques() {
return this.#contentTypes
.getValue()
.flatMap((x) => x.properties?.map((p) => p.dataType.unique) ?? [])
.filter(UmbFilterDuplicateStrings);
}
Comment thread
nielslyngsoe marked this conversation as resolved.

readonly variesByCulture = createObservablePart(this.ownerContentType, (x) => x?.variesByCulture);
readonly variesBySegment = createObservablePart(this.ownerContentType, (x) => x?.variesBySegment);

Expand Down Expand Up @@ -200,11 +213,21 @@
// Observe data type uniques and bulk load their details.
// Uses nested observation: outer watches which data types are needed,
// inner subscribes to the store-backed observable for reactivity.

this.observe(
this.contentTypeDataTypeUniques,
async (dataTypeUniques) => {
if (dataTypeUniques.length > 0) {
if (dataTypeUniques && dataTypeUniques.length > 0) {
const { asObservable } = await this.#dataTypeDetailRepository.requestByUniques(dataTypeUniques);
// TODO: We should avoid this check, but architecturally, we currently lack a way to cancel previous requests. [NL]
// This is unlikely to happen, but we keep this check to avoid potential race conditions. [NL]
const currentDataTypeUniques = this.getContentTypeDataTypeUniques();
if (
dataTypeUniques.length !== currentDataTypeUniques.length ||
!dataTypeUniques.every((unique) => currentDataTypeUniques.includes(unique))
) {
return;
}

Check warning on line 230 in src/Umbraco.Web.UI.Client/src/packages/content/content-type/structure/content-type-structure-manager.class.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (release/17.4.1)

❌ New issue: Complex Method

UmbContentTypeStructureManager.constructor has a cyclomatic complexity of 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
if (asObservable) {
this.observe(
asObservable(),
Expand Down
Loading