RN-66 Clear cache store (#727)
* RN-66 Clear cache store * Review feedback
This commit is contained in:
parent
458a2be333
commit
c017afb392
5 changed files with 42 additions and 5 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from 'app/actions/views/channel';
|
||||
import {handleTeamChange, selectFirstAvailableTeam} from 'app/actions/views/select_team';
|
||||
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {getClientConfig, getLicenseConfig, setServerVersion} from 'mattermost-redux/actions/general';
|
||||
import {markChannelAsRead, viewChannel} from 'mattermost-redux/actions/channels';
|
||||
|
||||
|
|
@ -71,6 +72,10 @@ export function setStatusBarHeight(height = 20) {
|
|||
};
|
||||
}
|
||||
|
||||
export function purgeOfflineStore() {
|
||||
return {type: General.OFFLINE_STORE_PURGE};
|
||||
}
|
||||
|
||||
export default {
|
||||
loadConfigAndLicense,
|
||||
queueNotification,
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ import {setJSExceptionHandler} from 'react-native-exception-handler';
|
|||
import StatusBarSizeIOS from 'react-native-status-bar-size';
|
||||
import semver from 'semver';
|
||||
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {setAppState, setDeviceToken, setServerVersion} from 'mattermost-redux/actions/general';
|
||||
import {markChannelAsRead} from 'mattermost-redux/actions/channels';
|
||||
import {logError} from 'mattermost-redux/actions/errors';
|
||||
import {logout} from 'mattermost-redux/actions/users';
|
||||
import {close as closeWebSocket} from 'mattermost-redux/actions/websocket';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import {goToNotification, loadConfigAndLicense, queueNotification, setStatusBarHeight} from 'app/actions/views/root';
|
||||
import {goToNotification, loadConfigAndLicense, queueNotification, setStatusBarHeight, purgeOfflineStore} from 'app/actions/views/root';
|
||||
import {setChannelDisplayName} from 'app/actions/views/channel';
|
||||
import {NavigationTypes, ViewTypes} from 'app/constants';
|
||||
import {getTranslations} from 'app/i18n';
|
||||
|
|
@ -80,7 +80,7 @@ export default class Mattermost {
|
|||
text: intl.formatMessage({id: 'mobile.error_handler.button', defaultMessage: 'Relaunch'}),
|
||||
onPress: () => {
|
||||
// purge the store
|
||||
store.dispatch({type: General.OFFLINE_STORE_PURGE});
|
||||
store.dispatch(purgeOfflineStore());
|
||||
}
|
||||
}],
|
||||
{cancelable: false}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {logout} from 'mattermost-redux/actions/users';
|
|||
import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getJoinableTeams} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import {purgeOfflineStore} from 'app/actions/views/root';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {removeProtocol} from 'app/utils/url';
|
||||
|
||||
|
|
@ -33,7 +34,8 @@ function mapDispatchToProps(dispatch) {
|
|||
return {
|
||||
actions: bindActionCreators({
|
||||
clearErrors,
|
||||
logout
|
||||
logout,
|
||||
purgeOfflineStore
|
||||
}, dispatch)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import React, {PureComponent} from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import {injectIntl, intlShape} from 'react-intl';
|
||||
import {
|
||||
Alert,
|
||||
InteractionManager,
|
||||
Linking,
|
||||
Platform,
|
||||
|
|
@ -24,7 +25,8 @@ class Settings extends PureComponent {
|
|||
static propTypes = {
|
||||
actions: PropTypes.shape({
|
||||
clearErrors: PropTypes.func.isRequired,
|
||||
logout: PropTypes.func.isRequired
|
||||
logout: PropTypes.func.isRequired,
|
||||
purgeOfflineStore: PropTypes.func.isRequired
|
||||
}).isRequired,
|
||||
config: PropTypes.object.isRequired,
|
||||
currentTeamId: PropTypes.string.isRequired,
|
||||
|
|
@ -153,6 +155,22 @@ class Settings extends PureComponent {
|
|||
Linking.openURL(config.HelpLink.toLowerCase());
|
||||
};
|
||||
|
||||
clearOfflineCache = () => {
|
||||
const {actions, intl} = this.props;
|
||||
|
||||
Alert.alert(
|
||||
intl.formatMessage({id: 'mobile.settings.clear', defaultMessage: 'Clear Offline Store'}),
|
||||
intl.formatMessage({id: 'mobile.settings.clear_message', defaultMessage: '\nThis will clear all offline data and restart the app. You will be automatically logged back in once the app restarts.\n'}),
|
||||
[{
|
||||
text: intl.formatMessage({id: 'mobile.settings.clear_button', defaultMessage: 'Clear'}),
|
||||
onPress: () => actions.purgeOfflineStore()
|
||||
}, {
|
||||
text: intl.formatMessage({id: 'channel_modal.cancel', defaultMessage: 'Cancel'}),
|
||||
onPress: () => true
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {config, joinableTeams, theme} = this.props;
|
||||
const style = getStyleSheet(theme);
|
||||
|
|
@ -203,6 +221,15 @@ class Settings extends PureComponent {
|
|||
separator={true}
|
||||
theme={theme}
|
||||
/>
|
||||
<SettingsItem
|
||||
defaultMessage='Clear Offline Store'
|
||||
i18nId='mobile.settings.clear'
|
||||
iconName='storage'
|
||||
iconType='material'
|
||||
onPress={() => this.handlePress(this.clearOfflineCache)}
|
||||
separator={true}
|
||||
theme={theme}
|
||||
/>
|
||||
<SettingsItem
|
||||
defaultMessage='About Mattermost'
|
||||
i18nId='about.title'
|
||||
|
|
|
|||
|
|
@ -1765,6 +1765,9 @@
|
|||
"mobile.server_url.invalid_format": "URL must start with http:// or https://",
|
||||
"mobile.session_expired": "Session Expired: Please log in to continue receiving notifications.",
|
||||
"mobile.settings.team_selection": "Team Selection",
|
||||
"mobile.settings.clear": "Clear Offline Store",
|
||||
"mobile.settings.clear_message": "\nThis will clear all offline data and restart the app. You will be automatically logged back in once the app restarts.\n",
|
||||
"mobile.settings.clear_button": "Clear",
|
||||
"modal.manaul_status.ask": "Do not ask me again",
|
||||
"modal.manaul_status.button": "Yes, set my status to \"Online\"",
|
||||
"modal.manaul_status.cancel": "No, keep it as \"{status}\"",
|
||||
|
|
|
|||
Loading…
Reference in a new issue