mastodon/app/javascript/flavours/glitch/features/local_settings/index.jsx
Claire ee771f5bad
Fix closeModal invocation (#2239)
Fixes #2238

Some call sites where missed in 382b2a506a
2023-06-04 22:05:45 +02:00

71 lines
1.6 KiB
JavaScript

// Package imports.
import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
// Our imports
import { changeLocalSetting } from 'flavours/glitch/actions/local_settings';
import { closeModal } from 'flavours/glitch/actions/modal';
import LocalSettingsNavigation from './navigation';
import LocalSettingsPage from './page';
const mapStateToProps = state => ({
settings: state.get('local_settings'),
});
const mapDispatchToProps = dispatch => ({
onChange (setting, value) {
dispatch(changeLocalSetting(setting, value));
},
onClose () {
dispatch(closeModal({
modalType: undefined,
ignoreFocus: false,
}));
},
});
class LocalSettings extends PureComponent {
static propTypes = {
onChange: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
settings: ImmutablePropTypes.map.isRequired,
};
state = {
currentIndex: 0,
};
navigateTo = (index) =>
this.setState({ currentIndex: +index });
render () {
const { navigateTo } = this;
const { onChange, onClose, settings } = this.props;
const { currentIndex } = this.state;
return (
<div className='glitch modal-root__modal local-settings'>
<LocalSettingsNavigation
index={currentIndex}
onClose={onClose}
onNavigate={navigateTo}
/>
<LocalSettingsPage
index={currentIndex}
onChange={onChange}
settings={settings}
/>
</div>
);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(LocalSettings);