Attempt to fix some crashes (#1860)
* Attempt to fix some crashes * remove unnecessary shareExtensionData middleware
This commit is contained in:
parent
cd5a6e5556
commit
8c066e0ba3
5 changed files with 33 additions and 38 deletions
|
|
@ -20,7 +20,7 @@ import {createSentryMiddleware} from 'app/utils/sentry/middleware';
|
|||
import mattermostBucket from 'app/mattermost_bucket';
|
||||
import Config from 'assets/config';
|
||||
|
||||
import {messageRetention, shareExtensionData} from './middleware';
|
||||
import {messageRetention} from './middleware';
|
||||
import {transformSet} from './utils';
|
||||
|
||||
function getAppReducer() {
|
||||
|
|
@ -208,6 +208,10 @@ export default function configureAppStore(initialState) {
|
|||
},
|
||||
]));
|
||||
|
||||
// When logging out remove the data stored in the bucket
|
||||
mattermostBucket.removePreference('emm', Config.AppGroupId);
|
||||
mattermostBucket.removeFile('entities', Config.AppGroupId);
|
||||
|
||||
setTimeout(() => {
|
||||
purging = false;
|
||||
}, 500);
|
||||
|
|
@ -267,7 +271,7 @@ export default function configureAppStore(initialState) {
|
|||
},
|
||||
};
|
||||
|
||||
const additionalMiddleware = [createSentryMiddleware(), messageRetention, shareExtensionData];
|
||||
const additionalMiddleware = [createSentryMiddleware(), messageRetention];
|
||||
return configureStore(initialState, appReducer, offlineOptions, getAppReducer, {
|
||||
additionalMiddleware,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,12 +3,8 @@
|
|||
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
|
||||
import {UserTypes} from 'mattermost-redux/action_types';
|
||||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import initialState from 'app/initial_state';
|
||||
import mattermostBucket from 'app/mattermost_bucket';
|
||||
import Config from 'assets/config';
|
||||
|
||||
import {
|
||||
captureException,
|
||||
|
|
@ -354,21 +350,6 @@ function cleanupState(action, keepCurrent = false) {
|
|||
};
|
||||
}
|
||||
|
||||
export function shareExtensionData() {
|
||||
return (next) => (action) => {
|
||||
// allow other middleware to do their things
|
||||
const nextAction = next(action);
|
||||
|
||||
switch (action.type) {
|
||||
case UserTypes.LOGOUT_SUCCESS:
|
||||
mattermostBucket.removePreference('emm', Config.AppGroupId);
|
||||
mattermostBucket.removeFile('entities', Config.AppGroupId);
|
||||
break;
|
||||
}
|
||||
return nextAction;
|
||||
};
|
||||
}
|
||||
|
||||
function removePendingPost(pendingPostIds, id) {
|
||||
const pendingIndex = pendingPostIds.indexOf(id);
|
||||
if (pendingIndex !== -1) {
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@ import {
|
|||
import {app, store} from 'app/mattermost';
|
||||
|
||||
const errorHandler = (e, isFatal) => {
|
||||
console.warn('Handling Javascript error ' + JSON.stringify(e)); // eslint-disable-line no-console
|
||||
const {dispatch, getState} = store;
|
||||
console.warn('Handling Javascript error ', e); // eslint-disable-line no-console
|
||||
const {dispatch} = store;
|
||||
|
||||
captureException(e, LOGGER_JAVASCRIPT, store);
|
||||
|
||||
const translations = app.getTranslations();
|
||||
closeWebSocket()(dispatch, getState);
|
||||
dispatch(closeWebSocket());
|
||||
|
||||
if (Client4.getUrl()) {
|
||||
logError(e)(dispatch, getState);
|
||||
dispatch(logError(e));
|
||||
}
|
||||
|
||||
if (isFatal) {
|
||||
|
|
@ -42,7 +42,7 @@ const errorHandler = (e, isFatal) => {
|
|||
text: translations['mobile.error_handler.button'],
|
||||
onPress: () => {
|
||||
// purge the store
|
||||
purgeOfflineStore()(dispatch, getState);
|
||||
dispatch(purgeOfflineStore());
|
||||
},
|
||||
}],
|
||||
{cancelable: false}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ function getDsn() {
|
|||
}
|
||||
|
||||
export function captureException(error, logger, store) {
|
||||
capture(() => {
|
||||
Sentry.captureException(error, {logger});
|
||||
}, store);
|
||||
if (error && logger && store) {
|
||||
capture(() => {
|
||||
Sentry.captureException(error, {logger});
|
||||
}, store);
|
||||
}
|
||||
}
|
||||
|
||||
export function captureExceptionWithoutState(err, logger) {
|
||||
|
|
@ -55,17 +57,21 @@ export function captureExceptionWithoutState(err, logger) {
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Sentry.captureException(err, {logger});
|
||||
} catch (error) {
|
||||
// do nothing...
|
||||
if (err && logger) {
|
||||
try {
|
||||
Sentry.captureException(err, {logger});
|
||||
} catch (error) {
|
||||
// do nothing...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function captureMessage(message, logger, store) {
|
||||
capture(() => {
|
||||
Sentry.captureMessage(message, {logger});
|
||||
}, store);
|
||||
if (message && logger && store) {
|
||||
capture(() => {
|
||||
Sentry.captureMessage(message, {logger});
|
||||
}, store);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapper function to any calls to Sentry so that we can gather any necessary extra data
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ RCT_EXPORT_METHOD(removePreference:(NSString *) key
|
|||
if(![fileManager fileExistsAtPath:filePath]) {
|
||||
[fileManager createFileAtPath:filePath contents:nil attributes:nil];
|
||||
}
|
||||
[content writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
if ([content length] > 0) {
|
||||
[content writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
-(NSString *)readFromFile:(NSString *)fileName appGroupId:(NSString *)appGroupId {
|
||||
|
|
@ -107,7 +109,9 @@ RCT_EXPORT_METHOD(removePreference:(NSString *) key
|
|||
|
||||
-(void) setPreference:(NSString *)key value:(NSString *) value appGroupId:(NSString*)appGroupId {
|
||||
NSUserDefaults* bucket = [self bucketByName: appGroupId];
|
||||
[bucket setObject:value forKey:key];
|
||||
if ([key length] > 0 && [value length] > 0) {
|
||||
[bucket setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
-(id) getPreference:(NSString *)key appGroupId:(NSString*)appGroupId {
|
||||
|
|
|
|||
Loading…
Reference in a new issue