Skip to content

Commit

Permalink
Lodash: Remove completely from notices package (WordPress#41834)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jun 24, 2022
1 parent a972672 commit ce461d8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/notices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"dependencies": {
"@babel/runtime": "^7.16.0",
"@wordpress/a11y": "file:../a11y",
"@wordpress/data": "file:../data",
"lodash": "^4.17.21"
"@wordpress/data": "file:../data"
},
"peerDependencies": {
"react": "^17.0.0"
Expand Down
9 changes: 3 additions & 6 deletions packages/notices/src/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { uniqueId } from 'lodash';

/**
* Internal dependencies
*/
Expand All @@ -19,6 +14,8 @@ import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';
*
*/

let uniqueId = 0;

/**
* Returns an action object used in signalling that a notice is to be created.
*
Expand Down Expand Up @@ -54,7 +51,7 @@ export function createNotice( status = DEFAULT_STATUS, content, options = {} ) {
speak = true,
isDismissible = true,
context = DEFAULT_CONTEXT,
id = uniqueId( context ),
id = `${ context }${ ++uniqueId }`,
actions = [],
type = 'default',
__unstableHTML,
Expand Down
9 changes: 2 additions & 7 deletions packages/notices/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { reject } from 'lodash';

/**
* Internal dependencies
*/
Expand All @@ -22,12 +17,12 @@ const notices = onSubKey( 'context' )( ( state = [], action ) => {
case 'CREATE_NOTICE':
// Avoid duplicates on ID.
return [
...reject( state, { id: action.notice.id } ),
...state.filter( ( { id } ) => id !== action.notice.id ),
action.notice,
];

case 'REMOVE_NOTICE':
return reject( state, { id: action.id } );
return state.filter( ( { id } ) => id !== action.id );
}

return state;
Expand Down

0 comments on commit ce461d8

Please sign in to comment.