useDefaultEvents.js
2 years ago
useDynamicEvents.js
2 years ago
useEventsFromActions.js
2 years ago
useEventsFromGateways.js
2 years ago
useRequestEvents.js
2 years ago
useEventsFromActions.js
25 lines
| 1 | import useSelectPostMeta from '../../hooks/useSelectPostMeta'; |
| 2 | |
| 3 | function useEventsFromActions( { index } ) { |
| 4 | const actions = useSelectPostMeta( '_jf_actions' ); |
| 5 | |
| 6 | actions.splice( index, 1 ); |
| 7 | |
| 8 | const events = []; |
| 9 | |
| 10 | for ( const action of actions ) { |
| 11 | const { |
| 12 | [ action.type ]: current = {}, |
| 13 | } = action.settings; |
| 14 | |
| 15 | if ( !current.provideEvents?.length ) { |
| 16 | continue; |
| 17 | } |
| 18 | |
| 19 | events.push( ...current.provideEvents ); |
| 20 | } |
| 21 | |
| 22 | return [ ...new Set( events ) ]; |
| 23 | } |
| 24 | |
| 25 | export default useEventsFromActions; |