From 079b81085c83bfbad08c5cba6c213337f23e7839 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Fri, 19 Apr 2019 15:20:42 +0300 Subject: [PATCH 1/3] Handle exeptions in sagas --- lib/sagas/index.js | 53 ++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/lib/sagas/index.js b/lib/sagas/index.js index d61c002c..9eb44a49 100644 --- a/lib/sagas/index.js +++ b/lib/sagas/index.js @@ -15,7 +15,8 @@ // You should have received a copy of the GNU General Public License // along with uPort Mobile App. If not, see . // -import { all } from 'redux-saga/effects' +import { all, put } from 'redux-saga/effects' +import { saveError } from '../actions/processStatusActions' import startupSaga from './startupSaga' import handleRequestSaga from './requests' import identitySaga from './identitySaga' @@ -36,24 +37,34 @@ import migrationsSaga from './migrationsSaga' import debugSaga from './debugSaga' export default function* rootSaga() { - yield all([ - featureFlagsSaga(), - metricsSaga(), - startupSaga(), - stateSaver(), - identitySaga(), - networkState(), - handleRequestSaga(), - personaSaga(), - unnuSaga(), - blockchainSaga(), - notificationRegistrationSaga(), - recoverySaga(), - encryptionSaga(), - pututuSaga(), - keychainSaga(), - hubSaga(), - // migrationsSaga(), - debugSaga(), - ]) + try { + yield all([ + featureFlagsSaga(), + metricsSaga(), + startupSaga(), + stateSaver(), + identitySaga(), + networkState(), + handleRequestSaga(), + personaSaga(), + unnuSaga(), + blockchainSaga(), + notificationRegistrationSaga(), + recoverySaga(), + encryptionSaga(), + pututuSaga(), + keychainSaga(), + hubSaga(), + // migrationsSaga(), + debugSaga(), + ]) + } catch(e) { + console.log('ERROR IN SAGAS', e) + let stack = '' + if (e.stack) { + stack = '\n' + e.stack.split('\n')[1] + } + yield put(saveError(e.name, e.message + stack)) + } } + \ No newline at end of file From 7ad181bc5c5213bfc7f6fdcd6d7e8dd932d8f534 Mon Sep 17 00:00:00 2001 From: Jason Healy Date: Fri, 19 Apr 2019 15:37:21 +0100 Subject: [PATCH 2/3] Handle milliseconds in expiry (#126) * Add date check function * Add test and snapshots * Adding formatter to other screens * Change calculation to use number --- .../Types/AttestationNotification.js | 13 ++---- .../Verifications/ExpirationItem.js | 9 ++-- .../ExpirationItem-test.js | 16 +++---- .../__snapshots__/ExpirationItem-test.js.snap | 43 +++++++++++++++++++ lib/components/shared/NestedInfo.js | 6 +-- lib/utilities/dateChecker.ts | 12 ++++++ 6 files changed, 73 insertions(+), 26 deletions(-) rename lib/components/Verifications/{__deprecated__tests__ => __tests__}/ExpirationItem-test.js (74%) create mode 100644 lib/components/Verifications/__tests__/__snapshots__/ExpirationItem-test.js.snap create mode 100644 lib/utilities/dateChecker.ts diff --git a/lib/components/Notifications/Types/AttestationNotification.js b/lib/components/Notifications/Types/AttestationNotification.js index 2d560d23..f22a63da 100644 --- a/lib/components/Notifications/Types/AttestationNotification.js +++ b/lib/components/Notifications/Types/AttestationNotification.js @@ -21,8 +21,9 @@ import { Text } from 'react-native' import Notification from '../partials/Notification' import Avatar from 'uPortMobile/lib/components/shared/Avatar' import { textStyles, colors } from 'uPortMobile/lib/styles/globalStyles' +import dateChecker from 'uPortMobile/lib/utilities/dateChecker' -const AttestationNotification = (props) => { +const AttestationNotification = props => { const handleAuthorize = () => { props.authorize(props.activity) } @@ -48,14 +49,8 @@ const AttestationNotification = (props) => { noButtons={false} > - - {claimType} - - { exp - ? - Expires: {new Date(exp).toLocaleDateString()} - - : null } + {claimType} + {exp ? Expires: {dateChecker(exp)} : null} ) } diff --git a/lib/components/Verifications/ExpirationItem.js b/lib/components/Verifications/ExpirationItem.js index 945545b9..a7a7edcf 100644 --- a/lib/components/Verifications/ExpirationItem.js +++ b/lib/components/Verifications/ExpirationItem.js @@ -18,7 +18,7 @@ // Frameworks import React from 'react' import { Text, View, StyleSheet } from 'react-native' -import moment from 'moment' +import dateChecker from 'uPortMobile/lib/utilities/dateChecker' // Styles import { colors, fontLight } from 'uPortMobile/lib/styles/globalStyles' @@ -34,12 +34,11 @@ const styles = StyleSheet.create({ }) // Helpers const ExpirationItem = props => { - // let expirationDate = props.d && props.d >= JWT_MS_CUTOFF ? moment.unix(props.d) : moment.unix(props.d * 1000) - let formattedDate = moment.unix(props.d).format('MMM Do YYYY') + const formattedDate = dateChecker(props.d) return ( - {props.d ? ( - Exp: {props.testing ? props.d : formattedDate} + {!!props.d ? ( + Exp: {formattedDate} ) : ( Exp: No Expiration )} diff --git a/lib/components/Verifications/__deprecated__tests__/ExpirationItem-test.js b/lib/components/Verifications/__tests__/ExpirationItem-test.js similarity index 74% rename from lib/components/Verifications/__deprecated__tests__/ExpirationItem-test.js rename to lib/components/Verifications/__tests__/ExpirationItem-test.js index 09325538..42a3cb5e 100644 --- a/lib/components/Verifications/__deprecated__tests__/ExpirationItem-test.js +++ b/lib/components/Verifications/__tests__/ExpirationItem-test.js @@ -22,14 +22,14 @@ import ExpirationItem from '../ExpirationItem' import renderer from 'react-test-renderer' describe('ExpirationItem', () => { - it('renders ExpirationItem', () => { - const date = 'Thu Mar 06 2014 19:00:00 GMT-0500 (CST)' - const tree = renderer.create( - - ).toJSON() + it('renders ExpirationItem in seconds', () => { + const date = 1583020800 + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) + it('renders ExpirationItem in milliseconds', () => { + const date = 1583020800000 + const tree = renderer.create().toJSON() expect(tree).toMatchSnapshot() }) }) diff --git a/lib/components/Verifications/__tests__/__snapshots__/ExpirationItem-test.js.snap b/lib/components/Verifications/__tests__/__snapshots__/ExpirationItem-test.js.snap new file mode 100644 index 00000000..ab7f394f --- /dev/null +++ b/lib/components/Verifications/__tests__/__snapshots__/ExpirationItem-test.js.snap @@ -0,0 +1,43 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ExpirationItem renders ExpirationItem in milliseconds 1`] = ` + + + Exp: + Mar 1st 2020 + + +`; + +exports[`ExpirationItem renders ExpirationItem in seconds 1`] = ` + + + Exp: + Mar 1st 2020 + + +`; diff --git a/lib/components/shared/NestedInfo.js b/lib/components/shared/NestedInfo.js index 1db649ea..2f059062 100644 --- a/lib/components/shared/NestedInfo.js +++ b/lib/components/shared/NestedInfo.js @@ -26,6 +26,7 @@ import S from 'string' import Icon from 'react-native-vector-icons/Ionicons' import moment from 'moment' import { colors } from 'uPortMobile/lib/styles/globalStyles' +import dateChecker from 'uPortMobile/lib/utilities/dateChecker' const maxStringLength = 50 @@ -216,10 +217,7 @@ export class NestedInfo extends Component { {verification && verification.exp && ( -
+
)} diff --git a/lib/utilities/dateChecker.ts b/lib/utilities/dateChecker.ts new file mode 100644 index 00000000..bc2df66c --- /dev/null +++ b/lib/utilities/dateChecker.ts @@ -0,0 +1,12 @@ +import moment from 'moment' +/** + * Formats a timestamp into a readable date format regardless of seconds or milliseconds + * + */ +const dateChecker = (date: number) => { + const isMilliSeconds = date && date >= 1000000000000 + const formattedDate = isMilliSeconds ? moment(date).format('MMM Do YYYY') : moment.unix(date).format('MMM Do YYYY') + return formattedDate +} + +export default dateChecker From 8428b3e0cf58617da33ca5e894abbca7bdb6be36 Mon Sep 17 00:00:00 2001 From: Jason Healy Date: Fri, 19 Apr 2019 15:41:38 +0100 Subject: [PATCH 3/3] bump build version to 444 --- CHANGELOG.md | 8 ++++++++ android/version.properties | 4 ++-- ios/uPortMobile.xcodeproj/project.pbxproj | 4 ++-- ios/uPortMobile/Info.plist | 2 +- ios/uPortMobileTests/Info.plist | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91ca365..f15e1a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [v444](https://github.com/uport-project/uport-mobile/tree/v444) (2019-04-19) +[Full Changelog](https://github.com/uport-project/uport-mobile/compare/v443...v444) + +**Merged pull requests:** + +- Handle milliseconds in expiry [\#126](https://github.com/uport-project/uport-mobile/pull/126) ([jasonhealy](https://github.com/jasonhealy)) +- Handle exeptions in sagas [\#125](https://github.com/uport-project/uport-mobile/pull/125) ([simonas-notcat](https://github.com/simonas-notcat)) + ## [v443](https://github.com/uport-project/uport-mobile/tree/v443) (2019-04-18) [Full Changelog](https://github.com/uport-project/uport-mobile/compare/v442...v443) diff --git a/android/version.properties b/android/version.properties index 3d5efe3f..3d4375b7 100644 --- a/android/version.properties +++ b/android/version.properties @@ -1,5 +1,5 @@ #This is a generated file so things tend to get overwritten. #Use `gradlew bumpVersion` to increment the version by 1 #or `gradlew bumpVersion -P_BUILD_NUMBER=` to set it manually -#Thu Apr 18 17:32:13 IST 2019 -BUILD_NUMBER=443 +#Fri Apr 19 15:41:17 IST 2019 +BUILD_NUMBER=444 diff --git a/ios/uPortMobile.xcodeproj/project.pbxproj b/ios/uPortMobile.xcodeproj/project.pbxproj index 736f2970..2cd16432 100644 --- a/ios/uPortMobile.xcodeproj/project.pbxproj +++ b/ios/uPortMobile.xcodeproj/project.pbxproj @@ -2341,7 +2341,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; COPY_HEADERS_RUN_UNIFDEF = NO; - CURRENT_PROJECT_VERSION = 443; + CURRENT_PROJECT_VERSION = 444; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = 82SAVLYZ3K; ENABLE_BITCODE = NO; @@ -2410,7 +2410,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; COPY_HEADERS_RUN_UNIFDEF = NO; - CURRENT_PROJECT_VERSION = 443; + CURRENT_PROJECT_VERSION = 444; DEVELOPMENT_TEAM = 82SAVLYZ3K; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/uPortMobile/Info.plist b/ios/uPortMobile/Info.plist index 7554338b..72b9eafc 100644 --- a/ios/uPortMobile/Info.plist +++ b/ios/uPortMobile/Info.plist @@ -52,7 +52,7 @@ CFBundleVersion - 443 + 444 Fabric APIKey diff --git a/ios/uPortMobileTests/Info.plist b/ios/uPortMobileTests/Info.plist index e60a7f60..dd2cba46 100644 --- a/ios/uPortMobileTests/Info.plist +++ b/ios/uPortMobileTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 443 + 444