From f31f1e82fa0cda9a5f48e47e4f0af6ab81af20d4 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Mon, 5 Aug 2024 15:05:52 +0200 Subject: [PATCH] check if unique is already in the array --- .../src/packages/core/utils/state-manager/state.manager.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/utils/state-manager/state.manager.ts b/src/Umbraco.Web.UI.Client/src/packages/core/utils/state-manager/state.manager.ts index 345012485a..1660220985 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/utils/state-manager/state.manager.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/utils/state-manager/state.manager.ts @@ -22,7 +22,9 @@ export class UmbStateManager extends UmbC */ addState(state: StateType) { if (!state.unique) throw new Error('State must have a unique property'); - // TODO: check if unique is already in the array + if (this._states.getValue().find((x) => x.unique === state.unique)) { + throw new Error('State with unique already exists'); + } this._states.setValue([...this._states.getValue(), state]); }