Skip to content

Commit

Permalink
Fix missing cred proof grouping (#1012)
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 authored Oct 26, 2023
1 parent ecea2b9 commit 0e2e102
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
22 changes: 13 additions & 9 deletions packages/legacy/core/App/screens/ProofRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, route }) => {
const { start } = useTour()
const screenIsFocused = useIsFocused()

const hasMatchingCredDef = useMemo(() => activeCreds.some((cred) => cred.credDefId !== undefined), [activeCreds])

const styles = StyleSheet.create({
pageContainer: {
flex: 1,
Expand Down Expand Up @@ -458,7 +460,7 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, route }) => {
</View>
)}
</View>
{!hasAvailableCredentials && (
{!hasAvailableCredentials && hasMatchingCredDef && (
<Text
style={{
...TextTheme.title,
Expand Down Expand Up @@ -582,14 +584,16 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, route }) => {
<View style={styles.pageMargin}>
{!loading && (
<>
<View
style={{
width: 'auto',
borderWidth: 1,
borderColor: ColorPallet.grayscale.lightGrey,
marginTop: 20,
}}
></View>
{hasMatchingCredDef && (
<View
style={{
width: 'auto',
borderWidth: 1,
borderColor: ColorPallet.grayscale.lightGrey,
marginTop: 20,
}}
/>
)}
<Text
style={{
...TextTheme.title,
Expand Down
13 changes: 6 additions & 7 deletions packages/legacy/core/App/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ export const processProofAttributes = (

if (credentialList.length <= 0) {
const missingAttributes = addMissingDisplayAttributes(requestedProofAttributes[key])
if (!processedAttributes[key]) {
processedAttributes[key] = missingAttributes
if (!processedAttributes[missingAttributes.credName]) {
processedAttributes[missingAttributes.credName] = missingAttributes
} else {
processedAttributes[key].attributes?.push(...(missingAttributes.attributes ?? []))
processedAttributes[missingAttributes.credName].attributes?.push(...(missingAttributes.attributes ?? []))
}
}

Expand All @@ -494,7 +494,6 @@ export const processProofAttributes = (
} else {
continue
}

for (const attributeName of [...(names ?? (name && [name]) ?? [])]) {
if (!processedAttributes[credential?.credentialId]) {
// init processedAttributes object
Expand Down Expand Up @@ -600,10 +599,10 @@ export const processProofPredicates = (
const { name, p_type: pType, p_value: pValue, non_revoked } = requestedProofPredicates[key]
if (credentialList.length <= 0) {
const missingPredicates = addMissingDisplayPredicates(requestedProofPredicates[key])
if (!processedPredicates[key]) {
processedPredicates[key] = missingPredicates
if (!processedPredicates[missingPredicates.credName]) {
processedPredicates[missingPredicates.credName] = missingPredicates
} else {
processedPredicates[key].predicates?.push(...(missingPredicates.predicates ?? []))
processedPredicates[missingPredicates.credName].predicates?.push(...(missingPredicates.predicates ?? []))
}
}

Expand Down

0 comments on commit 0e2e102

Please sign in to comment.