[FIX] Consecutive clear cache calls freezing app (#1851)

This commit is contained in:
Diego Mello 2020-03-10 08:49:54 -03:00 committed by GitHub
parent a1f842b009
commit 44e6660069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -32,7 +32,7 @@ export default React.memo(withTheme(({ theme, navigation }) => {
{text && (
<>
<ActivityIndicator color={themes[theme].auxiliaryText} size='large' />
<Text style={[styles.text, { color: themes[theme].bodyText }]}>{`${ text }.\n${ I18n.t('Please_wait') }`}</Text>
<Text style={[styles.text, { color: themes[theme].bodyText }]}>{`${ text }\n${ I18n.t('Please_wait') }`}</Text>
</>
)}
</View>

View File

@ -6,7 +6,8 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { SafeAreaView } from 'react-navigation';
import { logout as logoutAction, loginRequest as loginRequestAction } from '../../actions/login';
import { logout as logoutAction } from '../../actions/login';
import { selectServerRequest as selectServerRequestAction } from '../../actions/server';
import { toggleCrashReport as toggleCrashReportAction } from '../../actions/crashReport';
import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors';
import { DrawerButton, CloseModalButton } from '../../containers/HeaderButton';
@ -81,7 +82,7 @@ class SettingsView extends React.Component {
theme: PropTypes.string,
split: PropTypes.bool,
logout: PropTypes.func.isRequired,
loginRequest: PropTypes.func,
selectServerRequest: PropTypes.func,
token: PropTypes.string,
appStart: PropTypes.func
}
@ -106,11 +107,11 @@ class SettingsView extends React.Component {
callToAction: I18n.t('Clear'),
onPress: async() => {
const {
server: { server }, loginRequest, token, appStart
server: { server }, appStart, selectServerRequest
} = this.props;
await appStart('loading', I18n.t('Clear_cache_loading'));
await RocketChat.clearCache({ server });
await loginRequest({ resume: token }, true);
await selectServerRequest(server, null, true);
}
});
}
@ -348,7 +349,7 @@ const mapStateToProps = state => ({
const mapDispatchToProps = dispatch => ({
logout: () => dispatch(logoutAction()),
loginRequest: (...params) => dispatch(loginRequestAction(...params)),
selectServerRequest: params => dispatch(selectServerRequestAction(params)),
toggleCrashReport: params => dispatch(toggleCrashReportAction(params)),
appStart: (...params) => dispatch(appStartAction(...params))
});