diff --git a/app/navigators/RootStack.tsx b/app/navigators/RootStack.tsx index 2ec7db58..6899d576 100644 --- a/app/navigators/RootStack.tsx +++ b/app/navigators/RootStack.tsx @@ -114,10 +114,10 @@ const RootStack: React.FC = () => { } // Try connection based - const { connectionRecord } = await connectFromInvitation(agent, invitationUrl) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, invitationUrl) navigation.navigate(Stacks.ConnectionStack as any, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) } catch { try { @@ -146,11 +146,11 @@ const RootStack: React.FC = () => { return } - const { connectionRecord } = await connectFromInvitation(agent, urlData) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, urlData) navigation.getParent()?.navigate(Stacks.ConnectionStack, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) return } diff --git a/app/screens/Connection.tsx b/app/screens/Connection.tsx index b390f316..049c4481 100644 --- a/app/screens/Connection.tsx +++ b/app/screens/Connection.tsx @@ -11,7 +11,7 @@ import Button, { ButtonType } from '../components/buttons/Button' import { useAnimatedComponents } from '../contexts/animated-components' import { useConfiguration } from '../contexts/configuration' import { useTheme } from '../contexts/theme' -import { useOutOfBandByConnectionId } from '../hooks/connections' +import { useOutOfBandById } from '../hooks/connections' import { useNotifications } from '../hooks/notifications' import { Screens, TabStacks, DeliveryStackParams, Stacks } from '../types/navigators' import { useAppAgent } from '../utils/agent' @@ -35,7 +35,7 @@ const Connection: React.FC = ({ navigation, route }) => { // delay message, the user should be redirected to the home screen. const { connectionTimerDelay, autoRedirectConnectionToHome } = useConfiguration() const connTimerDelay = connectionTimerDelay ?? 10000 // in ms - const { connectionId, threadId } = route.params + const { connectionId, outOfBandId, threadId } = route.params const timerRef = useRef(null) const connection = connectionId ? useConnectionById(connectionId) : undefined const { t } = useTranslation() @@ -43,7 +43,7 @@ const Connection: React.FC = ({ navigation, route }) => { const { ColorPallet, TextTheme } = useTheme() const { ConnectionLoading } = useAnimatedComponents() const { agent } = useAppAgent() - const oobRecord = useOutOfBandByConnectionId(agent, connectionId ?? '') + const oobRecord = useOutOfBandById(agent, outOfBandId ?? '') const goalCode = oobRecord?.outOfBandInvitation.goalCode const merge: MergeFunction = (current, next) => ({ ...current, ...next }) const [state, dispatch] = useReducer(merge, { @@ -52,6 +52,7 @@ const Connection: React.FC = ({ navigation, route }) => { shouldShowDelayMessage: false, connectionIsActive: false, }) + const styles = StyleSheet.create({ container: { height: '100%', @@ -168,7 +169,7 @@ const Connection: React.FC = ({ navigation, route }) => { if (state.notificationRecord && goalCode) { goalCodeAction(goalCode)() } - }, [connection, goalCode, state.notificationRecord]) + }, [connection, oobRecord, goalCode, state.notificationRecord]) useMemo(() => { startTimer() diff --git a/app/screens/OrganizationDetails.tsx b/app/screens/OrganizationDetails.tsx index 13c74fb7..fd5b2bcf 100644 --- a/app/screens/OrganizationDetails.tsx +++ b/app/screens/OrganizationDetails.tsx @@ -155,11 +155,11 @@ const OrganizationDetails: React.FC = () => { const handleInvitation = async (value: string): Promise => { try { - const { connectionRecord } = await connectFromInvitation(agent, value) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, value) navigation.getParent()?.navigate(Stacks.ConnectionStack, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) } catch (err: unknown) { try { @@ -188,11 +188,11 @@ const OrganizationDetails: React.FC = () => { return } - const { connectionRecord } = await connectFromInvitation(agent, urlData) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, urlData) navigation.getParent()?.navigate(Stacks.ConnectionStack, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) return } diff --git a/app/screens/Scan.tsx b/app/screens/Scan.tsx index 32c79387..e65dcdbb 100644 --- a/app/screens/Scan.tsx +++ b/app/screens/Scan.tsx @@ -58,11 +58,11 @@ const Scan: React.FC = ({ navigation, route }) => { return } - const { connectionRecord } = await connectFromInvitation(agent, value) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, value) setLoading(false) navigation.getParent()?.navigate(Stacks.ConnectionStack, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) } catch (err: unknown) { try { @@ -95,12 +95,12 @@ const Scan: React.FC = ({ navigation, route }) => { return } - const { connectionRecord } = await connectFromInvitation(agent, urlData) + const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, urlData) setLoading(false) navigation.getParent()?.navigate(Stacks.ConnectionStack, { screen: Screens.Connection, - params: { connectionId: connectionRecord?.id }, + params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id }, }) return } diff --git a/app/types/navigators.ts b/app/types/navigators.ts index 4b4950d9..d8cb78f2 100644 --- a/app/types/navigators.ts +++ b/app/types/navigators.ts @@ -199,7 +199,7 @@ export type NotificationStackParams = { } export type DeliveryStackParams = { - [Screens.Connection]: { connectionId?: string; threadId?: string } + [Screens.Connection]: { connectionId?: string; threadId?: string; outOfBandId?: string } [Screens.CredentialOffer]: { credentialId: string } [Screens.ProofRequest]: { proofId: string } [Screens.OnTheWay]: { credentialId: string } diff --git a/app/utils/helpers.ts b/app/utils/helpers.ts index 74a611a3..0bb7f54a 100644 --- a/app/utils/helpers.ts +++ b/app/utils/helpers.ts @@ -1047,7 +1047,9 @@ export const checkIfAlreadyConnected = async (agent: AdeyaAgent, invitationUrl: * @returns a connection record from parsing and receiving the invitation */ export const connectFromInvitation = async (agent: AdeyaAgent, uri: string) => { - return await acceptInvitationFromUrl(agent, uri) + return await acceptInvitationFromUrl(agent, uri, { + reuseConnection: true, + }) } /**