mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-12-11 10:29:04 +01:00
ee771f5bad
Fixes #2238
Some call sites where missed in 382b2a506a
70 lines
1.6 KiB
JavaScript
70 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);
|