Skip to content

Commit

Permalink
Fix 'Prevent duplicate DotTips from appearing' feedback (#8741)
Browse files Browse the repository at this point in the history
* Typo: s/dispathed/dispatched/

* NUX: Simplify REGISTER_TIP_INSTANCE reducer
  • Loading branch information
noisysocks authored and gziolo committed Aug 9, 2018
1 parent 0298cff commit 93b6ac7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/nux/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function triggerGuide( tipIds ) {
}

/**
* Returns an action object that, when dispathed, associates an instance of the
* Returns an action object that, when dispatched, associates an instance of the
* DotTip component with a tip. This is usually done when the component mounts.
* Tracking this lets us only show one DotTip at a time per tip.
*
Expand Down
8 changes: 5 additions & 3 deletions packages/nux/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { union, without } from 'lodash';
import { uniq, without } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -41,11 +41,13 @@ export function guides( state = [], action ) {
*/
export function tipInstanceIds( state = {}, action ) {
switch ( action.type ) {
case 'REGISTER_TIP_INSTANCE':
case 'REGISTER_TIP_INSTANCE': {
const existingInstanceIds = state[ action.tipId ] || [];
return {
...state,
[ action.tipId ]: union( state[ action.tipId ] || [], [ action.instanceId ] ),
[ action.tipId ]: uniq( [ ...existingInstanceIds, action.instanceId ] ),
};
}

case 'UNREGISTER_TIP_INSTANCE':
return {
Expand Down

0 comments on commit 93b6ac7

Please sign in to comment.