fix(toolbarButtons): Store all buttons in redux.

The previous version of getToolbarButtons function was actually adding the custom buttons on every call to the config toolbarButtons array, effectively creating dublicates of every custom button. The PR fixes this issue.

Also now we will be running the getToolbarButtons calculation only when needed.
This commit is contained in:
Hristo Terezov
2024-02-28 13:52:04 -06:00
parent 68f7448624
commit ea075d9bae
19 changed files with 175 additions and 135 deletions

View File

@@ -9,7 +9,6 @@ import { VISITORS_MODE_BUTTONS } from '../../../base/config/constants';
import {
getButtonNotifyMode,
getButtonsWithNotifyClick,
getToolbarButtons,
isToolbarButtonEnabled
} from '../../../base/config/functions.web';
import { isMobileBrowser } from '../../../base/environment/utils';
@@ -502,7 +501,7 @@ function _mapStateToProps(state: IReduxState, ownProps: any) {
overflowDrawer
} = state['features/toolbox'];
const { clientWidth } = state['features/base/responsive-ui'];
let toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
let toolbarButtons = ownProps.toolbarButtons || state['features/toolbox'].toolbarButtons;
if (iAmVisitor(state)) {
toolbarButtons = VISITORS_MODE_BUTTONS.filter(e => toolbarButtons.indexOf(e) > -1);