From 8c066e0ba37137ae1e588ab8937373cbe99e5d9f Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 3 Jul 2018 10:14:55 -0400 Subject: [PATCH 1/4] Attempt to fix some crashes (#1860) * Attempt to fix some crashes * remove unnecessary shareExtensionData middleware --- app/store/index.js | 8 ++++++-- app/store/middleware.js | 19 ------------------- app/utils/error_handling.js | 10 +++++----- app/utils/sentry/index.js | 26 ++++++++++++++++---------- ios/MattermostBucket.m | 8 ++++++-- 5 files changed, 33 insertions(+), 38 deletions(-) diff --git a/app/store/index.js b/app/store/index.js index 9c1b9983b..a6e18d7c2 100644 --- a/app/store/index.js +++ b/app/store/index.js @@ -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, }); diff --git a/app/store/middleware.js b/app/store/middleware.js index de8c53468..ce816700e 100644 --- a/app/store/middleware.js +++ b/app/store/middleware.js @@ -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) { diff --git a/app/utils/error_handling.js b/app/utils/error_handling.js index 620b533df..ad93f6013 100644 --- a/app/utils/error_handling.js +++ b/app/utils/error_handling.js @@ -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} diff --git a/app/utils/sentry/index.js b/app/utils/sentry/index.js index 069619bed..47678e74d 100644 --- a/app/utils/sentry/index.js +++ b/app/utils/sentry/index.js @@ -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 diff --git a/ios/MattermostBucket.m b/ios/MattermostBucket.m index 13358e70b..49ca7e403 100644 --- a/ios/MattermostBucket.m +++ b/ios/MattermostBucket.m @@ -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 { From 2ec26e2a0ab7690a34c2674e701163e7fa53b1b3 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 3 Jul 2018 10:29:33 -0400 Subject: [PATCH 2/4] Bump app version to 1.9.3 --- android/app/build.gradle | 4 ++-- ios/Mattermost.xcodeproj/project.pbxproj | 4 ++-- ios/Mattermost/Info.plist | 4 ++-- ios/MattermostShare/Info.plist | 4 ++-- ios/MattermostTests/Info.plist | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 833808547..acdfd7cb5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -113,8 +113,8 @@ android { applicationId "com.mattermost.rnbeta" minSdkVersion 21 targetSdkVersion 23 - versionCode 117 - versionName "1.9.2" + versionCode 118 + versionName "1.9.3" ndk { abiFilters "armeabi-v7a", "x86" } diff --git a/ios/Mattermost.xcodeproj/project.pbxproj b/ios/Mattermost.xcodeproj/project.pbxproj index a2ac0714f..6abf1a9bd 100644 --- a/ios/Mattermost.xcodeproj/project.pbxproj +++ b/ios/Mattermost.xcodeproj/project.pbxproj @@ -2516,7 +2516,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; @@ -2566,7 +2566,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; diff --git a/ios/Mattermost/Info.plist b/ios/Mattermost/Info.plist index 891224c1f..f47272445 100644 --- a/ios/Mattermost/Info.plist +++ b/ios/Mattermost/Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.9.2 + 1.9.3 CFBundleSignature ???? CFBundleURLTypes @@ -34,7 +34,7 @@ CFBundleVersion - 117 + 118 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/ios/MattermostShare/Info.plist b/ios/MattermostShare/Info.plist index 4bde0fc1b..ba06f605c 100644 --- a/ios/MattermostShare/Info.plist +++ b/ios/MattermostShare/Info.plist @@ -21,9 +21,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 1.9.2 + 1.9.3 CFBundleVersion - 117 + 118 NSAppTransportSecurity NSAllowsArbitraryLoads diff --git a/ios/MattermostTests/Info.plist b/ios/MattermostTests/Info.plist index 609e14aa6..96ef7ec9a 100644 --- a/ios/MattermostTests/Info.plist +++ b/ios/MattermostTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.9.2 + 1.9.3 CFBundleSignature ???? CFBundleVersion - 117 + 118 From 8a7b27de2fb272c14dc75acc56d0dd18fa2c9a1c Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 3 Jul 2018 10:45:36 -0400 Subject: [PATCH 3/4] Bump iOS build number to 119 (#1864) --- ios/Mattermost.xcodeproj/project.pbxproj | 4 ++-- ios/Mattermost/Info.plist | 2 +- ios/MattermostShare/Info.plist | 2 +- ios/MattermostTests/Info.plist | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Mattermost.xcodeproj/project.pbxproj b/ios/Mattermost.xcodeproj/project.pbxproj index 6abf1a9bd..3113298ad 100644 --- a/ios/Mattermost.xcodeproj/project.pbxproj +++ b/ios/Mattermost.xcodeproj/project.pbxproj @@ -2516,7 +2516,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; @@ -2566,7 +2566,7 @@ CODE_SIGN_ENTITLEMENTS = Mattermost/Mattermost.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = UQ8HT4Q2XM; ENABLE_BITCODE = NO; diff --git a/ios/Mattermost/Info.plist b/ios/Mattermost/Info.plist index f47272445..77bd25e36 100644 --- a/ios/Mattermost/Info.plist +++ b/ios/Mattermost/Info.plist @@ -34,7 +34,7 @@ CFBundleVersion - 118 + 119 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/ios/MattermostShare/Info.plist b/ios/MattermostShare/Info.plist index ba06f605c..77d42ace4 100644 --- a/ios/MattermostShare/Info.plist +++ b/ios/MattermostShare/Info.plist @@ -23,7 +23,7 @@ CFBundleShortVersionString 1.9.3 CFBundleVersion - 118 + 119 NSAppTransportSecurity NSAllowsArbitraryLoads diff --git a/ios/MattermostTests/Info.plist b/ios/MattermostTests/Info.plist index 96ef7ec9a..c1332a5e2 100644 --- a/ios/MattermostTests/Info.plist +++ b/ios/MattermostTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 118 + 119 From 952aeaf786c1d4f38e0bfd8c92a1d2dd8a559ab2 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 3 Jul 2018 10:56:47 -0400 Subject: [PATCH 4/4] Bump Android build number to 119 (#1865) --- android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index acdfd7cb5..0a6d02628 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -113,7 +113,7 @@ android { applicationId "com.mattermost.rnbeta" minSdkVersion 21 targetSdkVersion 23 - versionCode 118 + versionCode 119 versionName "1.9.3" ndk { abiFilters "armeabi-v7a", "x86"