File size: 949 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import { createSelector } from '@automattic/state-utils';
import { last } from 'lodash';
import 'calypso/state/ui/init';
/**
* Returns a log of actions from certain types that have previously been
* dispatched for the current user.
*
* These actions are to be consumed by and inform Calypso's Guided Tours
* framework, but other components interested in listening to a log of Calypso
* actions are welcome to use and/or extend it.
* @param {Object} state Global state tree
* @returns {Array} Array of Redux actions, each with timestamp
*/
export function getActionLog( state ) {
return state.ui.actionLog;
}
/**
* Returns the last item from the action log.
* @param {Object} state Global state tree
* @returns {Object} The matching dispatched action
*/
export const getLastAction = createSelector(
( state ) => last( state.ui.actionLog ) || false,
( state ) => [ state.ui.actionLog ]
);
|