diff --git a/src/Umbraco.Web.UI.Client/src/libs/observable-api/states/array-state.ts b/src/Umbraco.Web.UI.Client/src/libs/observable-api/states/array-state.ts index 2153a48618..00e6bd5eb7 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/observable-api/states/array-state.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/observable-api/states/array-state.ts @@ -12,12 +12,12 @@ import { UmbDeepState } from './deep-state.js'; * The ArrayState provides methods to append data when the data is an Object. */ export class UmbArrayState extends UmbDeepState { - readonly getUnique: (entry: T) => unknown; + readonly getUniqueMethod: (entry: T) => unknown; #sortMethod?: (a: T, b: T) => number; constructor(initialData: T[], getUniqueOfEntryMethod: (entry: T) => unknown) { super(initialData); - this.getUnique = getUniqueOfEntryMethod; + this.getUniqueMethod = getUniqueOfEntryMethod; } /** @@ -60,12 +60,12 @@ export class UmbArrayState extends UmbDeepState { */ remove(uniques: unknown[]) { let next = this.getValue(); - if (this.getUnique) { + if (this.getUniqueMethod) { uniques.forEach((unique) => { next = next.filter((x) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - return this.getUnique(x) !== unique; + return this.getUniqueMethod(x) !== unique; }); }); @@ -89,11 +89,11 @@ export class UmbArrayState extends UmbDeepState { */ removeOne(unique: unknown) { let next = this.getValue(); - if (this.getUnique) { + if (this.getUniqueMethod) { next = next.filter((x) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - return this.getUnique(x) !== unique; + return this.getUniqueMethod(x) !== unique; }); this.next(next); @@ -142,8 +142,8 @@ export class UmbArrayState extends UmbDeepState { */ appendOne(entry: T) { const next = [...this.getValue()]; - if (this.getUnique) { - pushToUniqueArray(next, entry, this.getUnique); + if (this.getUniqueMethod) { + pushToUniqueArray(next, entry, this.getUniqueMethod); } else { next.push(entry); } @@ -168,10 +168,10 @@ export class UmbArrayState extends UmbDeepState { * ]); */ append(entries: T[]) { - if (this.getUnique) { + if (this.getUniqueMethod) { const next = [...this.getValue()]; entries.forEach((entry) => { - pushToUniqueArray(next, entry, this.getUnique!); + pushToUniqueArray(next, entry, this.getUniqueMethod!); }); this.next(next); } else { @@ -195,10 +195,10 @@ export class UmbArrayState extends UmbDeepState { * myState.updateOne(2, {value: 'updated-bar'}); */ updateOne(unique: unknown, entry: Partial) { - if (!this.getUnique) { + if (!this.getUniqueMethod) { throw new Error("Can't partial update an ArrayState without a getUnique method provided when constructed."); } - this.next(partialUpdateFrozenArray(this.getValue(), entry, (x) => unique === this.getUnique!(x))); + this.next(partialUpdateFrozenArray(this.getValue(), entry, (x) => unique === this.getUniqueMethod!(x))); return this; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/store/store-base.ts b/src/Umbraco.Web.UI.Client/src/packages/core/store/store-base.ts index 856b498f79..c2ba2afaf0 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/store/store-base.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/store/store-base.ts @@ -31,7 +31,7 @@ export class UmbStoreBase extends EventTarget implements Um */ append(item: StoreItemType) { this._data.append([item]); - const unique = this._data.getUnique(item) as string; + const unique = this._data.getUniqueMethod(item) as string; this.dispatchEvent(new UmbStoreAppendEvent([unique])); } @@ -42,7 +42,7 @@ export class UmbStoreBase extends EventTarget implements Um */ appendItems(items: Array) { this._data.append(items); - const uniques = items.map((item) => this._data.getUnique(item)) as Array; + const uniques = items.map((item) => this._data.getUniqueMethod(item)) as Array; this.dispatchEvent(new UmbStoreAppendEvent(uniques)); } @@ -84,7 +84,7 @@ export class UmbStoreBase extends EventTarget implements Um * @memberof UmbStoreBase */ getItems(uniques: Array) { - return this._data.getValue().filter((item) => uniques.includes(this._data.getUnique(item) as string)); + return this._data.getValue().filter((item) => uniques.includes(this._data.getUniqueMethod(item) as string)); } /**