From d3cfb5d43bfcb781222e9c48f39c32778ab75b7e Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Sun, 17 Apr 2022 09:10:41 -0700 Subject: [PATCH] Automatically remove the `min_columns` property. --- src/components/gallery.ts | 2 -- src/config-mgmt.ts | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/gallery.ts b/src/components/gallery.ts index aa472d2b..3ab4f931 100644 --- a/src/components/gallery.ts +++ b/src/components/gallery.ts @@ -1,5 +1,3 @@ -// TODO: automatic remove of min_columns - /* eslint-disable @typescript-eslint/no-explicit-any */ import { CSSResultGroup, diff --git a/src/config-mgmt.ts b/src/config-mgmt.ts index 7bde7990..fd8c69d1 100644 --- a/src/config-mgmt.ts +++ b/src/config-mgmt.ts @@ -174,6 +174,12 @@ const createRangedTransform = function ( }; }; +/** + * Convert a value from 'XXpx' to XX (as a number). + * @param value Incoming value. + * @returns A number, null if the property should be deleted or undefined if it + * should be ignored. + */ const toPixelsOrDelete = function (value: unknown): number | null | undefined { // Ignore the value if it's a number. if (typeof value === 'number') { @@ -189,6 +195,16 @@ const toPixelsOrDelete = function (value: unknown): number | null | undefined { return isNaN(value as number) ? null : Number(value); }; +/** + * Request a property be deleted. + * @param _value Inbound value (not required). + * @returns `null` to request the property be deleted. + */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const deleteProperty = function (_value: unknown): number | null | undefined { + return null; +} + /** * Move a property from one location to another. * @param obj The configuration object in which the property resides. @@ -445,4 +461,8 @@ const UPGRADES = [ CONF_MENU_BUTTON_SIZE, createRangedTransform(toPixelsOrDelete, BUTTON_SIZE_MIN), ), + upgradeWithOverrides( + 'event_gallery.min_columns', + deleteProperty + ), ];