Browse Source

[+Elena] - #87 WIP - Behaviour when credential already store

Jordi Coscolla 1 year ago
parent
commit
88ae12985b
2 changed files with 12 additions and 3 deletions
  1. 1 1
      apps/wallet/screens/AttributesSummary.js
  2. 11 2
      apps/wallet/screens/Home.js

+ 1 - 1
apps/wallet/screens/AttributesSummary.js

@@ -32,8 +32,8 @@ class AttributesSummary extends React.Component {
32 32
 
33 33
     this.props.addCredential(petition.attributes[0], walletId, url);
34 34
 
35
-    WebBrowser.dismissBrowser();
36 35
     this.props.goToPetitionSummary(this.props.petitionLink);
36
+    WebBrowser.dismissBrowser();
37 37
   };
38 38
 
39 39
   openPetitionInBrowser = () => {

+ 11 - 2
apps/wallet/screens/Home.js

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3 3
 import { Image, Text, TextInput, View, KeyboardAvoidingView } from 'react-native';
4 4
 import { SecureStore } from 'expo';
5 5
 import PropTypes from 'prop-types';
6
-import { goQRScannerIntro, goToAttributesSummary } from '../application/redux/actions/navigation';
6
+import { goQRScannerIntro, goToAttributesSummary, goToPetitionSummary } from '../application/redux/actions/navigation';
7 7
 import { onStartApp } from '../application/redux/actions/petitionLink';
8 8
 import { loadCredentials } from '../application/redux/actions/attributes';
9 9
 import { getWalletId } from '../application/redux/actions/wallet';
@@ -29,8 +29,11 @@ class Home extends React.Component {
29 29
   goToNextPage() {
30 30
     return this.props.doAuthorize(this.props.pinCode).then((action) => {
31 31
       if (action.pinCorrect) {
32
-        if (this.props.petitionLink) {
32
+        const isAttributeVerified = this.props.attributes.list.length > 0;
33
+        if (this.props.petitionLink && !isAttributeVerified) {
33 34
           this.props.goToAttributesSummary(this.props.petitionLink);
35
+        } else if (this.props.petitionLink) {
36
+          this.props.goToPetitionSummary(this.props.petitionLink);
34 37
         } else {
35 38
           this.props.goQRScannerIntro();
36 39
         }
@@ -81,11 +84,15 @@ class Home extends React.Component {
81 84
 Home.propTypes = {
82 85
   goQRScannerIntro: PropTypes.func.isRequired,
83 86
   goToAttributesSummary: PropTypes.func.isRequired,
87
+  goToPetitionSummary: PropTypes.func.isRequired,
84 88
   initializeState: PropTypes.func.isRequired,
85 89
   doAuthorize: PropTypes.func.isRequired,
86 90
   updatePin: PropTypes.func.isRequired,
87 91
   petitionLink: PropTypes.string,
88 92
   pinCode: PropTypes.string,
93
+  attributes: PropTypes.shape({
94
+    list: PropTypes.arrayOf(PropTypes.shape({})),
95
+  }).isRequired,
89 96
 };
90 97
 
91 98
 Home.defaultProps = {
@@ -96,11 +103,13 @@ Home.defaultProps = {
96 103
 const mapStateToProps = state => ({
97 104
   petitionLink: state.petitionLink.petitionLink,
98 105
   pinCode: state.authorization.pin,
106
+  attributes: state.attributes,
99 107
 });
100 108
 
101 109
 const mapDispatchToProps = dispatch => ({
102 110
   goQRScannerIntro: () => { dispatch(goQRScannerIntro()); },
103 111
   goToAttributesSummary: (petitionLink) => { dispatch(goToAttributesSummary(petitionLink)); },
112
+  goToPetitionSummary: (petitionLink) => { dispatch(goToPetitionSummary(petitionLink)); },
104 113
   doAuthorize: pin => dispatch(authorizationAction(pin, SecureStore.getItemAsync)),
105 114
   updatePin: (pin) => { dispatch(updatePin(pin)); },
106 115
   initializeState: async () => {