Download wp-calypso/packages/data-stores/src/help-center/resolvers.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/help-center/resolvers.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/help-center/resolvers.ts
-
curl -L -o resolvers.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/help-center/resolvers.ts
1.11 kB
| import { apiFetch } from '@wordpress/data-controls'; | |
| import { canAccessWpcomApis } from 'wpcom-proxy-request'; | |
| import { wpcomRequest } from '../wpcom-request-controls'; | |
| import { setHelpCenterRouterHistory } from './actions'; | |
| import type { APIFetchOptions } from './types'; | |
| import type { Location } from 'history'; | |
| export function* isHelpCenterShown() { | |
| try { | |
| const preferences: { | |
| help_center_open: boolean; | |
| help_center_router_history: { | |
| entries: Location[]; | |
| index: number; | |
| }; | |
| } = canAccessWpcomApis() | |
| ? yield wpcomRequest( { | |
| path: '/me/preferences', | |
| apiNamespace: 'wpcom/v2', | |
| } ) | |
| : yield apiFetch( { | |
| global: true, | |
| path: '/help-center/open-state', | |
| } as APIFetchOptions ); | |
| if ( preferences.help_center_router_history ) { | |
| yield setHelpCenterRouterHistory( preferences.help_center_router_history ); | |
| } | |
| // We only want to auto-open, we don't want to auto-close (and potentially overrule the user's action). | |
| if ( preferences.help_center_open ) { | |
| return { | |
| type: 'HELP_CENTER_SET_SHOW', | |
| show: true, | |
| } as const; | |
| } | |
| } catch {} | |
| } | |