You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
Mobile: Add additional checks when updating sidebar state (#12428)
This commit is contained in:
@@ -326,7 +326,6 @@ const SideMenuComponent: React.FC<Props> = props => {
|
||||
const SideMenu = connect((state: State) => {
|
||||
return {
|
||||
themeId: state.settings.theme,
|
||||
isOpen: state.showSideMenu,
|
||||
};
|
||||
})(SideMenuComponent);
|
||||
|
||||
|
@@ -45,10 +45,12 @@ const useIcon = (iconName: string) => {
|
||||
const FloatingActionButton = (props: ActionButtonProps) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const onMenuToggled = useCallback(() => {
|
||||
props.dispatch({
|
||||
type: 'SIDE_MENU_CLOSE',
|
||||
});
|
||||
const newOpen = !open;
|
||||
if (newOpen) {
|
||||
props.dispatch({
|
||||
type: 'SIDE_MENU_CLOSE',
|
||||
});
|
||||
}
|
||||
setOpen(newOpen);
|
||||
}, [setOpen, open, props.dispatch]);
|
||||
|
||||
|
@@ -1243,13 +1243,16 @@ class AppComponent extends React.Component<AppComponentProps, AppComponentState>
|
||||
}
|
||||
}
|
||||
|
||||
private sideMenu_change(isOpen: boolean) {
|
||||
private sideMenu_change = (isOpen: boolean) => {
|
||||
// Make sure showSideMenu property of state is updated
|
||||
// when the menu is open/closed.
|
||||
this.props.dispatch({
|
||||
type: isOpen ? 'SIDE_MENU_OPEN' : 'SIDE_MENU_CLOSE',
|
||||
});
|
||||
}
|
||||
// Avoid dispatching unnecessarily. See https://github.com/laurent22/joplin/issues/12427
|
||||
if (isOpen !== this.props.showSideMenu) {
|
||||
this.props.dispatch({
|
||||
type: isOpen ? 'SIDE_MENU_OPEN' : 'SIDE_MENU_CLOSE',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private getSideMenuWidth = () => {
|
||||
const sideMenuWidth = getResponsiveValue({
|
||||
@@ -1339,7 +1342,8 @@ class AppComponent extends React.Component<AppComponentProps, AppComponentState>
|
||||
toleranceY={20}
|
||||
openMenuOffset={this.state.sideMenuWidth}
|
||||
menuPosition={menuPosition}
|
||||
onChange={(isOpen: boolean) => this.sideMenu_change(isOpen)}
|
||||
onChange={this.sideMenu_change}
|
||||
isOpen={this.props.showSideMenu}
|
||||
disableGestures={disableSideMenuGestures}
|
||||
>
|
||||
<StatusBar barStyle={statusBarStyle} />
|
||||
|
Reference in New Issue
Block a user