Skip to content

Commit

Permalink
feat: show oob label when no connection (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoGlastra authored Nov 15, 2023
1 parent e79cbbb commit 04e37b3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/agent/src/hooks/useInboxNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ export const usePreFetchInboxDisplayMetadata = () => {
? connections.find((connection) => record.connectionId === connection.id)
: undefined

// Extract label from out-of-band invitation if no connection associated
const outOfBandRecord =
!connection && record.parentThreadId
? await agent.oob.findByReceivedInvitationId(record.parentThreadId)
: undefined

const formatData = await agent.credentials.getFormatData(record.id)
const offer = formatData.offer?.anoncreds ?? formatData.offer?.indy
// We just return here, so the rest can still continue
if (!offer) return

const schemaId = offer.schema_id

const issuerName = connection?.theirLabel
const issuerName = connection?.theirLabel ?? outOfBandRecord?.outOfBandInvitation.label
const schemaResult = await agent.modules.anoncreds.getSchema(schemaId)
const schemaName = schemaResult.schema?.name

Expand All @@ -75,13 +81,19 @@ export const usePreFetchInboxDisplayMetadata = () => {
? connections.find((connection) => record.connectionId === connection.id)
: undefined

// Extract label from out-of-band invitation if no connection associated
const outOfBandRecord =
!connection && record.parentThreadId
? await agent.oob.findByReceivedInvitationId(record.parentThreadId)
: undefined

const formatData = await agent.proofs.getFormatData(record.id)
const request = formatData.request?.anoncreds ?? formatData.request?.indy

// We just return here, so the rest can still continue
if (!request) return

const verifierName = connection?.theirLabel
const verifierName = connection?.theirLabel ?? outOfBandRecord?.outOfBandInvitation.label
const proofName = request.name

// Update the metadata on the record for future use
Expand Down

0 comments on commit 04e37b3

Please sign in to comment.