From 13f380b7bf889354907892c2d3b6cff4cdaacce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 22 Jun 2023 14:48:09 +0200 Subject: [PATCH] stylesheet --- .../repository/stylesheet.repository.ts | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/stylesheet.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/stylesheet.repository.ts index 8f8bc13c6b..5e1a4e41b2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/stylesheet.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/stylesheet.repository.ts @@ -2,7 +2,6 @@ import { UmbStylesheetTreeStore, UMB_STYLESHEET_TREE_STORE_CONTEXT_TOKEN } from import { UmbStylesheetTreeServerDataSource } from './sources/stylesheet.tree.server.data.js'; import { UmbStylesheetServerDataSource } from './sources/stylesheet.server.data.js'; import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification'; import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; import { UmbTreeRepository } from '@umbraco-cms/backoffice/repository'; import { FileSystemTreeItemPresentationModel } from '@umbraco-cms/backoffice/backend-api'; @@ -15,9 +14,7 @@ export class UmbStylesheetRepository #dataSource; #treeDataSource; #treeStore?: UmbStylesheetTreeStore; - #notificationContext?: UmbNotificationContext; - #initResolver?: () => void; - #initialized = false; + #init; constructor(host: UmbControllerHostElement) { this.#host = host; @@ -26,26 +23,9 @@ export class UmbStylesheetRepository this.#dataSource = new UmbStylesheetServerDataSource(this.#host); this.#treeDataSource = new UmbStylesheetTreeServerDataSource(this.#host); - new UmbContextConsumerController(this.#host, UMB_STYLESHEET_TREE_STORE_CONTEXT_TOKEN, (instance) => { + this.#init = new UmbContextConsumerController(this.#host, UMB_STYLESHEET_TREE_STORE_CONTEXT_TOKEN, (instance) => { this.#treeStore = instance; - this.#checkIfInitialized(); - }); - - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { - this.#notificationContext = instance; - this.#checkIfInitialized(); - }); - } - - #init = new Promise((resolve) => { - this.#initialized ? resolve() : (this.#initResolver = resolve); - }); - - #checkIfInitialized() { - if (this.#treeStore && this.#notificationContext) { - this.#initialized = true; - this.#initResolver?.(); - } + }).asPromise(); } // TREE: