Skip to content

Commit

Permalink
Top Toolbar: Move the preferences selection into the main useSelect (#…
Browse files Browse the repository at this point in the history
…52332)

* Top Toolbar: Move the preferences selection into the main useSelect

* also consolidate selectors for header mode

* also update the other uses of the preferences store
  • Loading branch information
scruffian authored Jul 7, 2023
1 parent ae5cc08 commit f093a91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ function HeaderToolbar() {
const inserterButton = useRef();
const { setIsInserterOpened, setIsListViewOpened } =
useDispatch( editPostStore );
const { get: getPreference } = useSelect( preferencesStore );
const hasFixedToolbar = getPreference( 'core/edit-post', 'fixedToolbar' );
const {
isInserterEnabled,
isInserterOpened,
isTextModeEnabled,
showIconLabels,
isListViewOpen,
listViewShortcut,
hasFixedToolbar,
} = useSelect( ( select ) => {
const { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =
select( blockEditorStore );
const { getEditorSettings } = select( editorStore );
const { getEditorMode, isFeatureActive, isListViewOpened } =
select( editPostStore );
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
const { get: getPreference } = select( preferencesStore );

return {
// This setting (richEditingEnabled) should not live in the block editor's setting.
Expand All @@ -69,6 +69,7 @@ function HeaderToolbar() {
listViewShortcut: getShortcutRepresentation(
'core/edit-post/toggle-list-view'
),
hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),
};
}, [] );

Expand Down
18 changes: 11 additions & 7 deletions packages/edit-site/src/components/header-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function HeaderEditMode() {
homeUrl,
showIconLabels,
editorCanvasView,
hasFixedToolbar,
} = useSelect( ( select ) => {
const {
__experimentalGetPreviewDeviceType,
Expand All @@ -83,6 +84,8 @@ export default function HeaderEditMode() {
getUnstableBase, // Site index.
} = select( coreStore );

const { get: getPreference } = select( preferencesStore );

return {
deviceType: __experimentalGetPreviewDeviceType(),
templateType: postType,
Expand All @@ -94,23 +97,24 @@ export default function HeaderEditMode() {
isVisualMode: getEditorMode() === 'visual',
blockEditorMode: __unstableGetEditorMode(),
homeUrl: getUnstableBase()?.home,
showIconLabels: select( preferencesStore ).get(
'core/edit-site',
showIconLabels: getPreference(
editSiteStore.name,
'showIconLabels'
),
editorCanvasView: unlock(
select( editSiteStore )
).getEditorCanvasContainerView(),
isDistractionFree: select( preferencesStore ).get(
'core/edit-site',
isDistractionFree: getPreference(
editSiteStore.name,
'distractionFree'
),
hasFixedToolbar: getPreference(
editSiteStore.name,
'fixedToolbar'
),
};
}, [] );

const { get: getPreference } = useSelect( preferencesStore );
const hasFixedToolbar = getPreference( editSiteStore.name, 'fixedToolbar' );

const {
__experimentalSetPreviewDeviceType: setPreviewDeviceType,
setIsInserterOpened,
Expand Down

1 comment on commit f093a91

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in f093a91.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5487360454
📝 Reported issues:

Please sign in to comment.