Skip to content

Commit

Permalink
Modularise legal state (#42717)
Browse files Browse the repository at this point in the history
Fixes #42455.
  • Loading branch information
sgomes authored Jun 16, 2020
1 parent 25d5220 commit c116cb0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/state/legal/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Internal dependencies
*/
import { LEGAL_REQUEST, LEGAL_SET, TOS_ACCEPT } from 'state/action-types';

import 'state/data-layer/wpcom/legal';
import 'state/legal/init';

export const requestLegalData = () => ( {
type: LEGAL_REQUEST,
Expand Down
7 changes: 7 additions & 0 deletions client/state/legal/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Internal dependencies
*/
import { registerReducer } from 'state/redux-store';
import legalReducer from './reducer';

registerReducer( [ 'legal' ], legalReducer );
5 changes: 5 additions & 0 deletions client/state/legal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sideEffects": [
"./init.js"
]
}
4 changes: 3 additions & 1 deletion client/state/legal/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
* Internal dependencies
*/
import { LEGAL_SET } from 'state/action-types';
import { withStorageKey } from 'state/utils';

export default ( state = {}, { type, legalData } ) => ( type === LEGAL_SET ? legalData : state );
const reducer = ( state = {}, { type, legalData } ) => ( type === LEGAL_SET ? legalData : state );
export default withStorageKey( 'legal', reducer );
2 changes: 0 additions & 2 deletions client/state/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import jetpackProductInstall from './jetpack-product-install/reducer';
import jetpackRemoteInstall from './jetpack-remote-install/reducer';
import jetpackSync from './jetpack-sync/reducer';
import jitm from './jitm/reducer';
import legal from './legal/reducer';
import media from './media/reducer';
import memberships from './memberships/reducer';
import mailchimp from './mailchimp/reducer';
Expand Down Expand Up @@ -124,7 +123,6 @@ const reducers = {
jetpackRemoteInstall,
jetpackSync,
jitm,
legal,
media,
memberships,
mySites,
Expand Down
5 changes: 5 additions & 0 deletions client/state/selectors/should-display-tos-update-banner.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Internal dependencies
*/
import 'state/legal/init';

/**
* Indicates if a Terms or Service update banner should be displayed.
*
Expand Down

0 comments on commit c116cb0

Please sign in to comment.