Download wp-calypso/client/state/ui/actions/set-sites.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/actions/set-sites.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/ui/actions/set-sites.js
-
curl -L -o set-sites.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/actions/set-sites.js
1.17 kB
| import { SELECTED_SITE_SET, MOST_RECENTLY_SELECTED_SITE_SET } from 'calypso/state/action-types'; | |
| import 'calypso/state/ui/init'; | |
| /** | |
| * Returns a thunk function that dispatches two actions related to the selected site ID. | |
| * The dispatched actions have type of MOST_RECENTLY_SELECTED_SITE_SET and SELECTED_SITE_SET where they both pass the new site ID to select. | |
| * Note that MOST_RECENTLY_SELECTED_SITE_SET is never be null since we can refer to the most recently selected site ID even when no site is selected. | |
| * @param {number | null} siteId - The ID of the site to be set as selected. | |
| * @returns {Function} A Redux thunk function. | |
| */ | |
| export const setSelectedSiteId = ( siteId ) => { | |
| return ( dispatch ) => { | |
| if ( siteId ) { | |
| dispatch( { | |
| type: MOST_RECENTLY_SELECTED_SITE_SET, | |
| siteId, | |
| } ); | |
| } | |
| dispatch( { | |
| type: SELECTED_SITE_SET, | |
| siteId, | |
| } ); | |
| }; | |
| }; | |
| /** | |
| * Returns an action object to be used in signalling that all sites have been | |
| * set as selected. | |
| * @returns {Object} Action object | |
| */ | |
| export const setAllSitesSelected = () => { | |
| return ( dispatch ) => { | |
| dispatch( { | |
| type: SELECTED_SITE_SET, | |
| siteId: null, | |
| } ); | |
| }; | |
| }; | |