From 8c61166504f467abbb2cccf4eeb1973574ace761 Mon Sep 17 00:00:00 2001 From: Guido Scialfa Date: Thu, 18 Apr 2024 22:21:09 +0200 Subject: [PATCH] Remove `UPDATE_CONTEXTUAL_ENTITIES_OPTIONS` action This action store a value to a variable in the store which is no longer consumed. --- @types/index.d.ts | 8 ------- .../src/hooks/use-entities-options-storage.ts | 4 ---- .../src/storage/entities/initial-state.ts | 1 - .../client/src/storage/entities/reducer.ts | 8 ------- .../use-entities-options-storage.test.tsx | 8 ------- .../client/unit/storage/initial-state.test.ts | 1 - tests/client/unit/storage/reducer.test.ts | 23 ------------------- 7 files changed, 53 deletions(-) diff --git a/@types/index.d.ts b/@types/index.d.ts index dddb2da..5ec4e72 100644 --- a/@types/index.d.ts +++ b/@types/index.d.ts @@ -117,7 +117,6 @@ declare namespace EntitiesSearch { > extends Readonly<{ entities: Entities; kind: Kind; - contextualEntitiesOptions: OptionSet; currentEntitiesOptions: OptionSet; selectedEntitiesOptions: OptionSet; searchPhrase: string; @@ -139,13 +138,6 @@ declare namespace EntitiesSearch { K >['currentEntitiesOptions']; } - | { - type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS'; - contextualEntitiesOptions: EntitiesState< - E, - K - >['contextualEntitiesOptions']; - } | { type: 'UPDATE_SELECTED_ENTITIES_OPTIONS'; selectedEntitiesOptions: EntitiesState< diff --git a/sources/client/src/hooks/use-entities-options-storage.ts b/sources/client/src/hooks/use-entities-options-storage.ts index a2c2ea0..9b0b330 100644 --- a/sources/client/src/hooks/use-entities-options-storage.ts +++ b/sources/client/src/hooks/use-entities-options-storage.ts @@ -63,10 +63,6 @@ export function useEntitiesOptionsStorage< E, K >( type: 'UPDATE_SELECTED_ENTITIES_OPTIONS', selectedEntitiesOptions, } ); - dispatch( { - type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS', - contextualEntitiesOptions: currentEntitiesOptions, - } ); dispatch( { type: 'UPDATE_CURRENT_ENTITIES_OPTIONS', currentEntitiesOptions, diff --git a/sources/client/src/storage/entities/initial-state.ts b/sources/client/src/storage/entities/initial-state.ts index 6901552..5d2bb60 100644 --- a/sources/client/src/storage/entities/initial-state.ts +++ b/sources/client/src/storage/entities/initial-state.ts @@ -20,7 +20,6 @@ export function makeInitialState< E, K >( return { entities: new Set< E >( [] ), kind: new Set< K >( [] ), - contextualEntitiesOptions: new Set< Options< E > >(), currentEntitiesOptions: new Set< Options< E > >(), selectedEntitiesOptions: new Set< Options< E > >(), searchPhrase: '', diff --git a/sources/client/src/storage/entities/reducer.ts b/sources/client/src/storage/entities/reducer.ts index 8f1e0c6..8283621 100644 --- a/sources/client/src/storage/entities/reducer.ts +++ b/sources/client/src/storage/entities/reducer.ts @@ -30,12 +30,6 @@ export function reducer< E, K >( kind: action.kind, }; - case 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS': - return { - ...state, - contextualEntitiesOptions: action.contextualEntitiesOptions, - }; - case 'UPDATE_CURRENT_ENTITIES_OPTIONS': return { ...state, @@ -56,14 +50,12 @@ export function reducer< E, K >( return { ...state, selectedEntitiesOptions: new Set(), - contextualEntitiesOptions: new Set(), currentEntitiesOptions: new Set(), }; case 'UPDATE_ENTITIES_OPTIONS_FOR_NEW_KIND': return { ...state, - contextualEntitiesOptions: action.entitiesOptions, currentEntitiesOptions: action.entitiesOptions, selectedEntitiesOptions: new Set(), entities: new Set(), diff --git a/tests/client/unit/hooks/use-entities-options-storage.test.tsx b/tests/client/unit/hooks/use-entities-options-storage.test.tsx index 18ac548..6836792 100644 --- a/tests/client/unit/hooks/use-entities-options-storage.test.tsx +++ b/tests/client/unit/hooks/use-entities-options-storage.test.tsx @@ -131,10 +131,6 @@ describe( 'Use Posts Options Storage', () => { type: 'UPDATE_SELECTED_ENTITIES_OPTIONS', selectedEntitiesOptions, } ); - expect( dispatch ).toHaveBeenCalledWith( { - type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS', - contextualEntitiesOptions: currentEntitiesOptions, - } ); expect( dispatch ).toHaveBeenCalledWith( { type: 'UPDATE_CURRENT_ENTITIES_OPTIONS', currentEntitiesOptions, @@ -175,10 +171,6 @@ describe( 'Use Posts Options Storage', () => { type: 'UPDATE_SELECTED_ENTITIES_OPTIONS', selectedEntitiesOptions: expectedSet, } ); - expect( dispatch ).toHaveBeenCalledWith( { - type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS', - contextualEntitiesOptions: expectedSet, - } ); expect( dispatch ).toHaveBeenCalledWith( { type: 'UPDATE_CURRENT_ENTITIES_OPTIONS', currentEntitiesOptions: expectedSet, diff --git a/tests/client/unit/storage/initial-state.test.ts b/tests/client/unit/storage/initial-state.test.ts index 7ccf28e..b47275f 100644 --- a/tests/client/unit/storage/initial-state.test.ts +++ b/tests/client/unit/storage/initial-state.test.ts @@ -11,7 +11,6 @@ import { makeInitialState } from '../../../../sources/client/src/storage/entitie describe( 'Initial state', () => { it( 'ensure all options are empty', () => { const initialState = makeInitialState( {} ); - expect( initialState.contextualEntitiesOptions.length() ).toBe( 0 ); expect( initialState.currentEntitiesOptions.length() ).toBe( 0 ); expect( initialState.selectedEntitiesOptions.length() ).toBe( 0 ); } ); diff --git a/tests/client/unit/storage/reducer.test.ts b/tests/client/unit/storage/reducer.test.ts index 0baaa28..2ef338d 100644 --- a/tests/client/unit/storage/reducer.test.ts +++ b/tests/client/unit/storage/reducer.test.ts @@ -36,27 +36,6 @@ describe( 'reducer', () => { expect( newState.kind ).toEqual( kind ); } ); - it( 'Update the Contextual Posts Options', () => { - const contextualPostsOptions = new Set( [ - { - value: faker.number.int( 10 ), - label: 'Post One', - }, - { - value: faker.number.int( { min: 11, max: 20 } ), - label: 'Post Two', - }, - ] ); - const newState = reducer( state, { - type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS', - contextualEntitiesOptions: contextualPostsOptions, - } ); - - expect( newState.contextualEntitiesOptions ).toEqual( - contextualPostsOptions - ); - } ); - it( 'Update the Posts Options', () => { const postsOptions = new Set( [ { @@ -120,7 +99,6 @@ describe( 'reducer', () => { } ); expect( newState.selectedEntitiesOptions ).toEqual( new Set() ); - expect( newState.contextualEntitiesOptions ).toEqual( new Set() ); expect( newState.currentEntitiesOptions ).toEqual( new Set() ); } ); @@ -142,7 +120,6 @@ describe( 'reducer', () => { entitiesOptions, } ); - expect( newState.contextualEntitiesOptions ).toEqual( entitiesOptions ); expect( newState.currentEntitiesOptions ).toEqual( entitiesOptions ); expect( newState.selectedEntitiesOptions ).toEqual( new Set() ); expect( newState.entities ).toEqual( new Set() );