From 80b0bcf1445d78a376ef343234e566911d8cbde6 Mon Sep 17 00:00:00 2001 From: Luis Felix Date: Fri, 23 Aug 2024 09:39:58 -0400 Subject: [PATCH] OV-29: * remove as suggested in review all helpers of null and undefiend values --- .../bundles/common/helpers/array-helper/array-helper.ts | 1 - .../bundles/common/helpers/array-helper/is-empty-array.ts | 6 ------ frontend/src/bundles/common/helpers/helpers.ts | 3 --- .../helpers/is-null-or-undefined/is-null-or-undefined.ts | 5 ----- .../common/helpers/string-helpers/is-null-or-undefined.ts | 8 -------- .../common/helpers/string-helpers/string-helper.ts | 1 - .../src/bundles/video-editor/components/menu/menu.tsx | 8 ++------ 7 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 frontend/src/bundles/common/helpers/array-helper/array-helper.ts delete mode 100644 frontend/src/bundles/common/helpers/array-helper/is-empty-array.ts delete mode 100644 frontend/src/bundles/common/helpers/is-null-or-undefined/is-null-or-undefined.ts delete mode 100644 frontend/src/bundles/common/helpers/string-helpers/is-null-or-undefined.ts delete mode 100644 frontend/src/bundles/common/helpers/string-helpers/string-helper.ts diff --git a/frontend/src/bundles/common/helpers/array-helper/array-helper.ts b/frontend/src/bundles/common/helpers/array-helper/array-helper.ts deleted file mode 100644 index 751b3a9c4..000000000 --- a/frontend/src/bundles/common/helpers/array-helper/array-helper.ts +++ /dev/null @@ -1 +0,0 @@ -export { isEmptyArray } from './is-empty-array.js'; diff --git a/frontend/src/bundles/common/helpers/array-helper/is-empty-array.ts b/frontend/src/bundles/common/helpers/array-helper/is-empty-array.ts deleted file mode 100644 index 80f21391d..000000000 --- a/frontend/src/bundles/common/helpers/array-helper/is-empty-array.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { isNullOrUndefined } from '../helpers.js'; - -const isEmptyArray = (value: T[]): boolean => - isNullOrUndefined(value) || value.length === 0; - -export { isEmptyArray }; diff --git a/frontend/src/bundles/common/helpers/helpers.ts b/frontend/src/bundles/common/helpers/helpers.ts index 537329cd7..5acdb8642 100644 --- a/frontend/src/bundles/common/helpers/helpers.ts +++ b/frontend/src/bundles/common/helpers/helpers.ts @@ -1,4 +1 @@ -export { isEmptyArray } from './array-helper/array-helper.js'; -export { isNullOrUndefined } from './is-null-or-undefined/is-null-or-undefined.js'; -export { isStringNullOrEmpty } from './string-helpers/string-helper.js'; export { configureString } from 'shared'; diff --git a/frontend/src/bundles/common/helpers/is-null-or-undefined/is-null-or-undefined.ts b/frontend/src/bundles/common/helpers/is-null-or-undefined/is-null-or-undefined.ts deleted file mode 100644 index 835237306..000000000 --- a/frontend/src/bundles/common/helpers/is-null-or-undefined/is-null-or-undefined.ts +++ /dev/null @@ -1,5 +0,0 @@ -const isNullOrUndefined = ( - value: T | null | undefined, -): value is null | undefined => value === undefined || value === null; - -export { isNullOrUndefined }; diff --git a/frontend/src/bundles/common/helpers/string-helpers/is-null-or-undefined.ts b/frontend/src/bundles/common/helpers/string-helpers/is-null-or-undefined.ts deleted file mode 100644 index 4154a5eb6..000000000 --- a/frontend/src/bundles/common/helpers/string-helpers/is-null-or-undefined.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { isNullOrUndefined } from '../helpers.js'; - -const isStringNullOrEmpty = ( - value: string | null | undefined, -): value is null | undefined => - isNullOrUndefined(value) || value.trim().length === 0; - -export { isStringNullOrEmpty }; diff --git a/frontend/src/bundles/common/helpers/string-helpers/string-helper.ts b/frontend/src/bundles/common/helpers/string-helpers/string-helper.ts deleted file mode 100644 index a5ad63b66..000000000 --- a/frontend/src/bundles/common/helpers/string-helpers/string-helper.ts +++ /dev/null @@ -1 +0,0 @@ -export { isStringNullOrEmpty } from './is-null-or-undefined.js'; diff --git a/frontend/src/bundles/video-editor/components/menu/menu.tsx b/frontend/src/bundles/video-editor/components/menu/menu.tsx index 66f15260e..95e6038db 100644 --- a/frontend/src/bundles/video-editor/components/menu/menu.tsx +++ b/frontend/src/bundles/video-editor/components/menu/menu.tsx @@ -1,8 +1,4 @@ import { Box, Flex, VStack } from '~/bundles/common/components/components.js'; -import { - isEmptyArray, - isNullOrUndefined, -} from '~/bundles/common/helpers/helpers.js'; import { useCallback } from '~/bundles/common/hooks/hooks.js'; import { type MenuItem } from '../../types/types.js'; @@ -17,12 +13,12 @@ const Menu: React.FC = ({ items, activeIndex, setActiveIndex }) => { const handleClick = useCallback( (index: number) => { return () => { - if (isEmptyArray(items) || index >= items.length) { + if (!items || items.length === 0 || index >= items.length) { return; } const item = items[index]; - if (isNullOrUndefined(item)) { + if (!item) { return; }