Skip to content

Commit

Permalink
feat: getting oob label for connectionless proof (openwallet-foundati…
Browse files Browse the repository at this point in the history
…on#1171)

Signed-off-by: Caroline Lucas Calheirani <ccalheirani@gmail.com>
  • Loading branch information
CarolineLCa authored Jun 25, 2024
1 parent 7812f71 commit 001c6c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
16 changes: 16 additions & 0 deletions packages/legacy/core/App/hooks/oob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { OutOfBandRecord } from '@credo-ts/core'
import { useAgent } from '@credo-ts/react-hooks'
import { useState } from 'react'

export const useOutOfBandByReceivedInvitationId = (receivedInvitationId: string): OutOfBandRecord | undefined => {
const { agent } = useAgent()
const [oob, setOob] = useState<OutOfBandRecord | undefined>(undefined)
if (!oob) {
agent?.oob.findByReceivedInvitationId(receivedInvitationId).then((res) => {
if (res) {
setOob(res)
}
})
}
return oob
}
12 changes: 10 additions & 2 deletions packages/legacy/core/App/screens/ProofRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useStore } from '../contexts/store'
import { useTheme } from '../contexts/theme'
import { useTour } from '../contexts/tour/tour-context'
import { useOutOfBandByConnectionId } from '../hooks/connections'
import { useOutOfBandByReceivedInvitationId } from '../hooks/oob'
import { useAllCredentialsForProof } from '../hooks/proofs'
import { BifoldError } from '../types/error'
import { NotificationStackParams, Screens, Stacks, TabStacks } from '../types/navigators'
Expand Down Expand Up @@ -69,6 +70,9 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, route }) => {
const { ColorPallet, ListItems, TextTheme } = useTheme()
const { RecordLoading } = useAnimatedComponents()
const goalCode = useOutOfBandByConnectionId(proof?.connectionId ?? '')?.outOfBandInvitation.goalCode
const outOfBandInvitation = proof?.parentThreadId
? useOutOfBandByReceivedInvitationId(proof?.parentThreadId)?.outOfBandInvitation
: undefined
const { enableTours: enableToursConfig, useAttestation } = useConfiguration()
const [containsPI, setContainsPI] = useState(false)
const [activeCreds, setActiveCreds] = useState<ProofCredentialItems[]>([])
Expand Down Expand Up @@ -475,12 +479,16 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, route }) => {

<Text style={styles.headerText} testID={testIdWithKey('HeaderText')}>
{t('ProofRequest.YouDoNotHaveDataPredicate')}{' '}
<Text style={[TextTheme.title]}>{proofConnectionLabel || t('ContactDetails.AContact')}</Text>
<Text style={[TextTheme.title]}>
{proofConnectionLabel || outOfBandInvitation?.label || t('ContactDetails.AContact')}
</Text>
</Text>
</View>
) : (
<Text style={styles.headerText} testID={testIdWithKey('HeaderText')}>
<Text style={[TextTheme.title]}>{proofConnectionLabel || t('ContactDetails.AContact')}</Text>{' '}
<Text style={[TextTheme.title]}>
{proofConnectionLabel || outOfBandInvitation?.label || t('ContactDetails.AContact')}
</Text>{' '}
<Text>{t('ProofRequest.IsRequestingYouToShare')}</Text>
<Text style={[TextTheme.title]}>{` ${activeCreds?.length} `}</Text>
<Text>{activeCreds?.length > 1 ? t('ProofRequest.Credentials') : t('ProofRequest.Credential')}</Text>
Expand Down
2 changes: 2 additions & 0 deletions packages/legacy/core/App/utils/cred-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export function parseCredDefFromId(credDefId?: string, schemaId?: string): strin
if (schemaId) {
const parseIndySchema = parseIndySchemaId(schemaId)
name = parseIndySchema.schemaName
} else {
name = 'Credential'
}
}
return name
Expand Down

0 comments on commit 001c6c5

Please sign in to comment.