Download wp-calypso/client/dashboard/data/me-preferences.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/data/me-preferences.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/dashboard/data/me-preferences.ts
-
curl -L -o me-preferences.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/data/me-preferences.ts
1.03 kB
| import wpcom from 'calypso/lib/wp'; | |
| import type { ViewTable, ViewGrid } from '@wordpress/dataviews'; | |
| export type SitesView = ViewTable | ViewGrid; | |
| // The view preferences are a subset of the view object. | |
| // It includes the merged layout object of all view types ever explicitly set by the user. | |
| export type SitesViewPreferences = Partial< Omit< SitesView, 'type' | 'layout' > > & { | |
| type?: ViewTable[ 'type' ] | ViewGrid[ 'type' ]; | |
| layout?: Partial< ViewTable[ 'layout' ] & ViewGrid[ 'layout' ] >; | |
| }; | |
| export interface UserPreferences { | |
| 'sites-view'?: SitesViewPreferences; | |
| 'some-string'?: string; | |
| } | |
| export async function fetchPreferences(): Promise< UserPreferences > { | |
| const { calypso_preferences } = await wpcom.req.get( '/me/preferences' ); | |
| return calypso_preferences; | |
| } | |
| export async function updatePreferences( | |
| data: Partial< UserPreferences > | |
| ): Promise< UserPreferences > { | |
| const { calypso_preferences } = await wpcom.req.post( '/me/preferences', { | |
| calypso_preferences: data, | |
| } ); | |
| return calypso_preferences; | |
| } | |