Skip to content

Commit

Permalink
fixed connection not deleted bug
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 committed Oct 12, 2023
1 parent 840a64b commit 6db067c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/legacy/core/App/screens/ProofDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ const ProofDetails: React.FC<ProofDetailsProps> = ({ route, navigation }) => {
if (!store.preferences.useDataRetention) {
agent?.proofs.deleteById(recordId)
}
if ((record?.metadata.get(ProofMetadata.customMetadata) as ProofCustomMetadata).delete_conn_after_seen) {
agent?.connections.deleteById(record?.connectionId ?? '')
}
}
}, [])

Expand Down
12 changes: 11 additions & 1 deletion packages/legacy/core/App/screens/ProofRequesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { useTranslation } from 'react-i18next'
import { BackHandler, DeviceEventEmitter, useWindowDimensions, ScrollView, StyleSheet, Text, View } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'

import { isPresentationFailed, isPresentationReceived, linkProofWithTemplate, sendProofRequest } from '../../verifier'
import {
ProofCustomMetadata,
ProofMetadata,
isPresentationFailed,
isPresentationReceived,
linkProofWithTemplate,
sendProofRequest,
} from '../../verifier'
import LoadingIndicator from '../components/animated/LoadingIndicator'
import Button, { ButtonType } from '../components/buttons/Button'
import QRRenderer from '../components/misc/QRRenderer'
Expand Down Expand Up @@ -154,6 +161,9 @@ const ProofRequesting: React.FC<ProofRequestingProps> = ({ route, navigation })
// send proof logic
const result = await sendProofRequest(agent, template, record.id, predicateValues)
if (result?.proofRecord) {
// verifier side doesn't have access to the goal code so we need to add metadata here
const metadata = result.proofRecord.metadata.get(ProofMetadata.customMetadata) as ProofCustomMetadata
result.proofRecord.metadata.set(ProofMetadata.customMetadata, { ...metadata, delete_conn_after_seen: true })
linkProofWithTemplate(agent, result.proofRecord, templateId)
}
setProofRecordId(result?.proofRecord.id)
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/verifier/types/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum ProofMetadata {
export interface ProofCustomMetadata {
details_seen?: boolean
proof_request_template_id?: string
delete_conn_after_seen?: boolean
}

0 comments on commit 6db067c

Please sign in to comment.