observe expose with blocks variant id (#17482)

This commit is contained in:
Niels Lyngsø
2024-11-11 14:53:25 +01:00
committed by GitHub
parent de0ca49e0e
commit 21f82ab507
3 changed files with 7 additions and 8 deletions

View File

@@ -577,7 +577,7 @@ export abstract class UmbBlockEntryContext<
if (!variantId || !this.#contentKey) return;
// TODO: Handle variantId changes
this.observe(
this._manager?.hasExposeOf(this.#contentKey),
this._manager?.hasExposeOf(this.#contentKey, variantId),
(hasExpose) => {
this.#hasExpose.setValue(hasExpose);
},

View File

@@ -189,8 +189,7 @@ export abstract class UmbBlockManagerContext<
);
}
hasExposeOf(contentKey: string) {
const variantId = this.#variantId.getValue();
hasExposeOf(contentKey: string, variantId: UmbVariantId) {
if (!variantId) return;
return this.#exposes.asObservablePart((source) =>
source.some((x) => x.contentKey === contentKey && variantId.compare(x)),

View File

@@ -118,19 +118,19 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
);
this.observe(
this.contentKey,
(contentKey) => {
if (!contentKey) return;
observeMultiple([this.contentKey, this.variantId]),
([contentKey, variantId]) => {
if (!contentKey || !variantId) return;
this.observe(
manager.hasExposeOf(contentKey),
manager.hasExposeOf(contentKey, variantId),
(exposed) => {
this.#exposed.setValue(exposed);
},
'observeHasExpose',
);
},
'observeContentKey',
'observeContentKeyAndVariantId',
);
}).asPromise();