From fce63f8eac0c151c779de0464713c77bf1cc05df Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:32:41 +0200 Subject: [PATCH] change all custom filters to 'extensionsOfType' --- .../src/content/content-dashboards.element.ts | 16 +++++----------- src/Umbraco.Web.UI.Client/src/section.context.ts | 11 +++-------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/content/content-dashboards.element.ts b/src/Umbraco.Web.UI.Client/src/content/content-dashboards.element.ts index 3cf8ef0f6e..564d94d0a9 100644 --- a/src/Umbraco.Web.UI.Client/src/content/content-dashboards.element.ts +++ b/src/Umbraco.Web.UI.Client/src/content/content-dashboards.element.ts @@ -4,7 +4,7 @@ import { customElement, state } from 'lit/decorators.js'; import { map, Subscription } from 'rxjs'; import { UmbContextConsumerMixin } from '../core/context'; -import { UmbExtensionManifest, UmbExtensionManifestDashboard, UmbExtensionRegistry } from '../core/extension'; +import { UmbExtensionManifestDashboard, UmbExtensionRegistry } from '../core/extension'; import { UmbRouteLocation, UmbRouter } from '../core/router'; @customElement('umb-content-dashboards') @@ -59,15 +59,9 @@ export class UmbContentDashboards extends UmbContextConsumerMixin(LitElement) { private _useDashboards() { this._dashboardsSubscription?.unsubscribe(); - this._dashboardsSubscription = this._extensionRegistry?.extensions - .pipe( - map((extensions) => - extensions - .filter((extension) => extension.type === 'dashboard') - .map((x) => x as UmbExtensionManifestDashboard) - .sort((a, b) => b.meta.weight - a.meta.weight) - ) - ) + this._dashboardsSubscription = this._extensionRegistry + ?.extensionsOfType('dashboard') + .pipe(map((extensions) => extensions.sort((a, b) => b.meta.weight - a.meta.weight))) .subscribe((dashboards) => { // TODO: What do we want to use as path? this._dashboards = dashboards; @@ -101,7 +95,7 @@ export class UmbContentDashboards extends UmbContextConsumerMixin(LitElement) { } // TODO: Temp outlet solution - private async _setCurrent(dashboard: UmbExtensionManifest) { + private async _setCurrent(dashboard: UmbExtensionManifestDashboard) { if (typeof dashboard.js === 'function') { await dashboard.js(); } diff --git a/src/Umbraco.Web.UI.Client/src/section.context.ts b/src/Umbraco.Web.UI.Client/src/section.context.ts index f0f51ab36c..d4c669a16c 100644 --- a/src/Umbraco.Web.UI.Client/src/section.context.ts +++ b/src/Umbraco.Web.UI.Client/src/section.context.ts @@ -13,14 +13,9 @@ export class UmbSectionContext { } getSections() { - return this._extensionRegistry.extensions.pipe( - map((extensions) => - extensions - .filter((extension) => extension.type === 'section') - .map((extension) => extension as UmbExtensionManifestSection) - .sort((a, b) => b.meta.weight - a.meta.weight) - ) - ); + return this._extensionRegistry + .extensionsOfType('section') + .pipe(map((extensions) => extensions.sort((a, b) => b.meta.weight - a.meta.weight))); } getCurrent() {