RN-523 Added a try-catch when cleaning up state following a rehydrate (#1342)
This commit is contained in:
parent
cf9341406a
commit
84fdc24bc5
2 changed files with 18 additions and 2 deletions
|
|
@ -6,7 +6,12 @@ import DeviceInfo from 'react-native-device-info';
|
|||
import {ViewTypes} from 'app/constants';
|
||||
import initialState from 'app/initial_state';
|
||||
|
||||
export function messageRetention() {
|
||||
import {
|
||||
captureException,
|
||||
LOGGER_JAVASCRIPT_WARNING
|
||||
} from 'app/utils/sentry';
|
||||
|
||||
export function messageRetention(store) {
|
||||
return (next) => (action) => {
|
||||
if (action.type === 'persist/REHYDRATE') {
|
||||
const {app} = action.payload;
|
||||
|
|
@ -23,7 +28,17 @@ export function messageRetention() {
|
|||
|
||||
// Keep only the last 60 messages for the last 5 viewed channels in each team
|
||||
// and apply data retention on those posts if applies
|
||||
return next(cleanupState(action));
|
||||
let nextAction;
|
||||
try {
|
||||
nextAction = cleanupState(action);
|
||||
} catch (e) {
|
||||
// Sometimes, the payload is incomplete so log the error to Sentry and skip the cleanup
|
||||
console.warn(e); // eslint-disable-line no-console
|
||||
captureException(e, LOGGER_JAVASCRIPT_WARNING, store);
|
||||
nextAction = action;
|
||||
}
|
||||
|
||||
return next(nextAction);
|
||||
} else if (action.type === ViewTypes.DATA_CLEANUP) {
|
||||
const nextAction = cleanupState(action, true);
|
||||
return next(nextAction);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {getCurrentTeam, getCurrentTeamMembership} from 'mattermost-redux/selecto
|
|||
import {getCurrentChannel, getMyCurrentChannelMembership} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
export const LOGGER_JAVASCRIPT = 'javascript';
|
||||
export const LOGGER_JAVASCRIPT_WARNING = 'javascript_warning';
|
||||
export const LOGGER_NATIVE = 'native';
|
||||
export const LOGGER_REDUX = 'redux';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue