MM-17693 Android fix close settings screen (#3108)

* MM-17693 Android fix close settings screen

* Fix unit tests
This commit is contained in:
Elias Nahum 2019-08-13 10:29:54 -04:00 committed by GitHub
parent f0a885865f
commit 32f329fca2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View file

@ -363,15 +363,21 @@ export function dismissOverlay(componentId) {
};
}
export function applyTheme(componentId) {
export function applyTheme(componentId, skipBackButtonStyle = false) {
return (dispatch, getState) => {
const theme = getTheme(getState());
let backButton = {
color: theme.sidebarHeaderTextColor,
};
if (skipBackButtonStyle && Platform.OS === 'android') {
backButton = null;
}
Navigation.mergeOptions(componentId, {
topBar: {
backButton: {
color: theme.sidebarHeaderTextColor,
},
backButton,
background: {
color: theme.sidebarHeaderBg,
},

View file

@ -28,6 +28,7 @@ import Config from 'assets/config';
class AdvancedSettings extends PureComponent {
static propTypes = {
actions: PropTypes.shape({
dismissAllModals: PropTypes.func.isRequired,
purgeOfflineStore: PropTypes.func.isRequired,
}).isRequired,
intl: intlShape.isRequired,
@ -74,6 +75,10 @@ class AdvancedSettings extends PureComponent {
await deleteFileCache();
this.setState({cacheSize: 0, cacheSizedFetched: true});
actions.purgeOfflineStore();
if (Platform.OS === 'android') {
actions.dismissAllModals();
}
});
renderCacheFileSize = () => {

View file

@ -4,6 +4,7 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {dismissAllModals} from 'app/actions/navigation';
import {purgeOfflineStore} from 'app/actions/views/root';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {isLandscape} from 'app/selectors/device';
@ -19,6 +20,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
dismissAllModals,
purgeOfflineStore,
}, dispatch),
};

View file

@ -54,7 +54,7 @@ class Settings extends PureComponent {
componentDidAppear() {
const {actions, componentId} = this.props;
actions.applyTheme(componentId);
actions.applyTheme(componentId, true);
}
navigationButtonPressed({buttonId}) {