From fdb49deb54a01343f3f3311f425722fdd985e03a Mon Sep 17 00:00:00 2001 From: wadeking98 Date: Thu, 26 Oct 2023 09:59:08 -0700 Subject: [PATCH 1/2] fixed how missing credentials are grouped Signed-off-by: wadeking98 --- .../legacy/core/App/screens/ProofRequest.tsx | 32 ++++++++++--------- packages/legacy/core/App/utils/helpers.ts | 13 ++++---- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/legacy/core/App/screens/ProofRequest.tsx b/packages/legacy/core/App/screens/ProofRequest.tsx index e59f9f775c..830c1d3685 100644 --- a/packages/legacy/core/App/screens/ProofRequest.tsx +++ b/packages/legacy/core/App/screens/ProofRequest.tsx @@ -76,6 +76,8 @@ const ProofRequest: React.FC = ({ navigation, route }) => { const { start } = useTour() const screenIsFocused = useIsFocused() + const hasSomeCred = useMemo(() => activeCreds.some(cred => cred.credDefId !== undefined), [activeCreds]) + const styles = StyleSheet.create({ pageContainer: { flex: 1, @@ -232,16 +234,16 @@ const ProofRequest: React.FC = ({ navigation, route }) => { const selectRetrievedCredentials: AnonCredsCredentialsForProofRequest | undefined = retrievedCredentials ? { - ...retrievedCredentials, - attributes: formatCredentials(retrievedCredentials.attributes, credList) as Record< - string, - AnonCredsRequestedAttributeMatch[] - >, - predicates: formatCredentials(retrievedCredentials.predicates, credList) as Record< - string, - AnonCredsRequestedPredicateMatch[] - >, - } + ...retrievedCredentials, + attributes: formatCredentials(retrievedCredentials.attributes, credList) as Record< + string, + AnonCredsRequestedAttributeMatch[] + >, + predicates: formatCredentials(retrievedCredentials.predicates, credList) as Record< + string, + AnonCredsRequestedPredicateMatch[] + >, + } : undefined setRetrievedCredentials(selectRetrievedCredentials) @@ -458,7 +460,7 @@ const ProofRequest: React.FC = ({ navigation, route }) => { )} - {!hasAvailableCredentials && ( + {!hasAvailableCredentials && hasSomeCred && ( = ({ navigation, route }) => { handleAltCredChange={ item.altCredentials && item.altCredentials.length > 1 ? () => { - handleAltCredChange(item.credId, item.altCredentials ?? [item.credId]) - } + handleAltCredChange(item.credId, item.altCredentials ?? [item.credId]) + } : undefined } proof={true} @@ -582,14 +584,14 @@ const ProofRequest: React.FC = ({ navigation, route }) => { {!loading && ( <> - + >)} Date: Thu, 26 Oct 2023 14:16:59 -0700 Subject: [PATCH 2/2] fixed linting Signed-off-by: wadeking98 --- .../legacy/core/App/screens/ProofRequest.tsx | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/legacy/core/App/screens/ProofRequest.tsx b/packages/legacy/core/App/screens/ProofRequest.tsx index 830c1d3685..ebba6c121e 100644 --- a/packages/legacy/core/App/screens/ProofRequest.tsx +++ b/packages/legacy/core/App/screens/ProofRequest.tsx @@ -76,7 +76,7 @@ const ProofRequest: React.FC = ({ navigation, route }) => { const { start } = useTour() const screenIsFocused = useIsFocused() - const hasSomeCred = useMemo(() => activeCreds.some(cred => cred.credDefId !== undefined), [activeCreds]) + const hasMatchingCredDef = useMemo(() => activeCreds.some((cred) => cred.credDefId !== undefined), [activeCreds]) const styles = StyleSheet.create({ pageContainer: { @@ -234,16 +234,16 @@ const ProofRequest: React.FC = ({ navigation, route }) => { const selectRetrievedCredentials: AnonCredsCredentialsForProofRequest | undefined = retrievedCredentials ? { - ...retrievedCredentials, - attributes: formatCredentials(retrievedCredentials.attributes, credList) as Record< - string, - AnonCredsRequestedAttributeMatch[] - >, - predicates: formatCredentials(retrievedCredentials.predicates, credList) as Record< - string, - AnonCredsRequestedPredicateMatch[] - >, - } + ...retrievedCredentials, + attributes: formatCredentials(retrievedCredentials.attributes, credList) as Record< + string, + AnonCredsRequestedAttributeMatch[] + >, + predicates: formatCredentials(retrievedCredentials.predicates, credList) as Record< + string, + AnonCredsRequestedPredicateMatch[] + >, + } : undefined setRetrievedCredentials(selectRetrievedCredentials) @@ -460,7 +460,7 @@ const ProofRequest: React.FC = ({ navigation, route }) => { )} - {!hasAvailableCredentials && hasSomeCred && ( + {!hasAvailableCredentials && hasMatchingCredDef && ( = ({ navigation, route }) => { handleAltCredChange={ item.altCredentials && item.altCredentials.length > 1 ? () => { - handleAltCredChange(item.credId, item.altCredentials ?? [item.credId]) - } + handleAltCredChange(item.credId, item.altCredentials ?? [item.credId]) + } : undefined } proof={true} @@ -584,14 +584,16 @@ const ProofRequest: React.FC = ({ navigation, route }) => { {!loading && ( <> - {hasSomeCred && ()} + {hasMatchingCredDef && ( + + )}