Skip to content

Commit

Permalink
Remove UPDATE_CONTEXTUAL_ENTITIES_OPTIONS action (#50)
Browse files Browse the repository at this point in the history
This action store a value to a variable in the store which is no longer
consumed.
  • Loading branch information
widoz authored Apr 18, 2024
1 parent 2bc8ee4 commit 6e0cff0
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 53 deletions.
8 changes: 0 additions & 8 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ declare namespace EntitiesSearch {
> extends Readonly<{
entities: Entities<E>;
kind: Kind<K>;
contextualEntitiesOptions: OptionSet;
currentEntitiesOptions: OptionSet;
selectedEntitiesOptions: OptionSet;
searchPhrase: string;
Expand All @@ -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<
Expand Down
4 changes: 0 additions & 4 deletions sources/client/src/hooks/use-entities-options-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion sources/client/src/storage/entities/initial-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
8 changes: 0 additions & 8 deletions sources/client/src/storage/entities/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
Expand Down
8 changes: 0 additions & 8 deletions tests/client/unit/hooks/use-entities-options-storage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion tests/client/unit/storage/initial-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
} );
Expand Down
23 changes: 0 additions & 23 deletions tests/client/unit/storage/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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( [
{
Expand Down Expand Up @@ -120,7 +99,6 @@ describe( 'reducer', () => {
} );

expect( newState.selectedEntitiesOptions ).toEqual( new Set() );
expect( newState.contextualEntitiesOptions ).toEqual( new Set() );
expect( newState.currentEntitiesOptions ).toEqual( new Set() );
} );

Expand All @@ -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() );
Expand Down

0 comments on commit 6e0cff0

Please sign in to comment.