Remove unnecessary unlock of editor settings

The selector is public.
[MAILPOET-6319]
This commit is contained in:
Rostislav Wolny
2024-11-22 13:18:14 +01:00
committed by Oluwaseun Olorunsola
parent cac56f3563
commit d8a3289414
2 changed files with 8 additions and 12 deletions

View File

@ -21,8 +21,6 @@ import { SaveButton } from './save-button';
import { CampaignName } from './campaign-name'; import { CampaignName } from './campaign-name';
import { SendButton } from './send-button'; import { SendButton } from './send-button';
import { unlock } from '../../lock-unlock';
// Build type for ToolbarItem contains only "as" and "children" properties but it takes all props from // Build type for ToolbarItem contains only "as" and "children" properties but it takes all props from
// component passed to "as" property (in this case Button). So as fix for TS errors we need to pass all props from Button to ToolbarItem. // component passed to "as" property (in this case Button). So as fix for TS errors we need to pass all props from Button to ToolbarItem.
// We should be able to remove this fix when ToolbarItem will be fixed in Gutenberg. // We should be able to remove this fix when ToolbarItem will be fixed in Gutenberg.
@ -61,11 +59,8 @@ export function Header() {
hasRedo, hasRedo,
hasDocumentNavigationHistory, hasDocumentNavigationHistory,
} = useSelect( ( select ) => { } = useSelect( ( select ) => {
// eslint-disable-next-line @typescript-eslint/naming-convention const { getEditorSettings } = select( editorStore );
const { getEditorSettings: _getEditorSettings } = unlock( const editorSettings = getEditorSettings();
select( editorStore )
);
const editorSettings = _getEditorSettings();
return { return {
// @ts-expect-error missing types. // @ts-expect-error missing types.
@ -80,7 +75,9 @@ export function Header() {
!! select( blockEditorStore ).getBlockSelectionStart(), !! select( blockEditorStore ).getBlockSelectionStart(),
hasUndo: select( coreDataStore ).hasUndo(), hasUndo: select( coreDataStore ).hasUndo(),
hasRedo: select( coreDataStore ).hasRedo(), hasRedo: select( coreDataStore ).hasRedo(),
hasDocumentNavigationHistory: hasDocumentNavigationHistory:
// @ts-expect-error No types for this exist yet.
!! editorSettings.onNavigateToPreviousEntityRecord, !! editorSettings.onNavigateToPreviousEntityRecord,
}; };
}, [] ); }, [] );

View File

@ -14,7 +14,6 @@ import {
} from '@wordpress/blocks'; } from '@wordpress/blocks';
import { addQueryArgs } from '@wordpress/url'; import { addQueryArgs } from '@wordpress/url';
import { storeName } from '../../store'; import { storeName } from '../../store';
import { unlock } from '../../lock-unlock';
// Todo: This is not available yet. Replace when possible. // Todo: This is not available yet. Replace when possible.
async function revertTemplate( template ) { async function revertTemplate( template ) {
@ -56,13 +55,13 @@ export function TemplatesPanel() {
const { onNavigateToEntityRecord, template, hasHistory } = useSelect( const { onNavigateToEntityRecord, template, hasHistory } = useSelect(
( sel ) => { ( sel ) => {
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
const { getEditorSettings: _getEditorSettings } = unlock( const { getEditorSettings } = sel( editorStore );
sel( editorStore ) const editorSettings = getEditorSettings();
);
const editorSettings = _getEditorSettings();
return { return {
onNavigateToEntityRecord: onNavigateToEntityRecord:
// @ts-expect-error onNavigateToEntityRecord type is not defined
editorSettings.onNavigateToEntityRecord, editorSettings.onNavigateToEntityRecord,
// @ts-expect-error onNavigateToPreviousEntityRecord type is not defined
hasHistory: !! editorSettings.onNavigateToPreviousEntityRecord, hasHistory: !! editorSettings.onNavigateToPreviousEntityRecord,
template: sel( storeName ).getEditedPostTemplate(), template: sel( storeName ).getEditedPostTemplate(),
}; };