Skip to content

Commit

Permalink
feat: store the block mode value inside attributes and remove from st…
Browse files Browse the repository at this point in the history
…ore api
  • Loading branch information
rezaelahidev committed Oct 24, 2024
1 parent 853f4ee commit 8226027
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { __ } from '@wordpress/i18n';
import { check } from '@wordpress/icons';
import type { MixedElement } from 'react';
import { dispatch } from '@wordpress/data';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';

/**
Expand All @@ -23,8 +22,6 @@ export const BlockDropdownAllMenu = ({
isActive: boolean,
setActive: (isActive: boolean) => void,
}): MixedElement => {
const { setBlockExtensionsStatus } = dispatch('blockera/extensions');

return (
<DropdownMenu
icon={<Icon icon="more-vertical" iconSize="24" />}
Expand All @@ -42,7 +39,6 @@ export const BlockDropdownAllMenu = ({
data-test={'advanced-mode-block'}
icon={isActive ? check : ''}
onClick={() => {
setBlockExtensionsStatus(!isActive);
setActive(!isActive);
onClose();
}}
Expand All @@ -65,7 +61,6 @@ export const BlockDropdownAllMenu = ({
data-test={'basic-mode-block'}
icon={isActive ? '' : check}
onClick={() => {
setBlockExtensionsStatus(!isActive);
setActive(!isActive);
onClose();
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const BlockFillPartials: ComponentType<any> = memo(
blockeraInnerBlocks,
updateBlockEditorSettings,
}): Element<any> => {
const { isActiveBlockExtensions } = select('blockera/extensions');

// prevent memory leak, componentDidMount.
useEffect(() => {
const others = select('blockera/controls').getControls();
Expand Down Expand Up @@ -79,7 +77,7 @@ export const BlockFillPartials: ComponentType<any> = memo(
/>
)}
</Fill>
{isActiveBlockExtensions() && (
{isActive && (
<Fill name={`blockera-block-edit-content-${clientId}`}>
<BlockEditComponent {...blockProps} />
</Fill>
Expand Down
7 changes: 0 additions & 7 deletions packages/editor/js/extensions/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ export function changeExtensionCurrentBlockStateBreakpoint(
};
}

export function setBlockExtensionsStatus(isActive: boolean): Object {
return {
isActive,
type: 'SET_EXTENSIONS_STATUS',
};
}

export function setExtensionsActiveBlockVariation(variation: Object): Object {
return {
variation,
Expand Down
5 changes: 0 additions & 5 deletions packages/editor/js/extensions/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ export function blockExtensions(state: Object = {}, action: Object): Object {
...state,
currentBreakpoint: action.currentBreakpoint,
};
case 'SET_EXTENSIONS_STATUS':
return {
...state,
isActiveExtensions: action.isActive,
};
case 'SET_EXTENSIONS_ACTIVE_VARIATION':
return {
...state,
Expand Down
13 changes: 0 additions & 13 deletions packages/editor/js/extensions/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,6 @@ export function getExtensionCurrentBlockStateBreakpoint({
return blockExtensions?.currentBreakpoint || getBaseBreakpoint();
}

/**
* Get current block is active extensions?
*
* @param {Object} blockExtensions the block extension details.
*
* @return {boolean} true on success,false on otherwise!
*/
export function isActiveBlockExtensions({ blockExtensions }: Object): boolean {
return 'undefined' === typeof blockExtensions?.isActiveExtensions
? true
: blockExtensions?.isActiveExtensions;
}

/**
* Get active block variation in extensions.
*
Expand Down

0 comments on commit 8226027

Please sign in to comment.