Skip to content

Commit

Permalink
Allowing implicit invites and reuse connections
Browse files Browse the repository at this point in the history
Signed-off-by: Thiago Romano <[email protected]>
  • Loading branch information
thiagoromanos committed Oct 27, 2023
1 parent deeefc2 commit 1f1ad3d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/legacy/core/App/defaultConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ export const defaultConfiguration: ConfigurationContext = {
useCustomNotifications: useNotifications,
proofRequestTemplates: useProofRequestTemplates,
enableTours: false,
enableImplicitInvitations: true,
}
10 changes: 8 additions & 2 deletions packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const RootStack: React.FC = () => {
const theme = useTheme()
const defaultStackOptions = createDefaultStackOptions(theme)
const OnboardingTheme = theme.OnboardingTheme
const { pages, terms, splash, useBiometry, developer } = useConfiguration()
const { pages, terms, splash, useBiometry, developer, enableImplicitInvitations, enableReuseConnections } =
useConfiguration()
useDeepLinks()

// remove connection on mobile verifier proofs if proof is rejected regardless of if it has been opened
Expand Down Expand Up @@ -96,7 +97,12 @@ const RootStack: React.FC = () => {

try {
// Try connection based
const receivedInvitation = await connectFromInvitation(deepLink, agent)
const receivedInvitation = await connectFromInvitation(
deepLink,
agent,
enableImplicitInvitations,
enableReuseConnections
)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { connectionId: receivedInvitation?.connectionRecord?.id },
Expand Down
10 changes: 8 additions & 2 deletions packages/legacy/core/App/navigators/TabStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import HomeStack from './HomeStack'

const TabStack: React.FC = () => {
const { width, height } = useWindowDimensions()
const { useCustomNotifications } = useConfiguration()
const { useCustomNotifications, enableReuseConnections, enableImplicitInvitations } = useConfiguration()
const { total } = useCustomNotifications()
const { t } = useTranslation()
const Tab = createBottomTabNavigator<TabStackParams>()
Expand Down Expand Up @@ -160,7 +160,13 @@ const TabStack: React.FC = () => {
if (!assertConnectedNetwork()) {
return
}
navigation.navigate(Stacks.ConnectStack, { screen: Screens.Scan })
navigation.navigate(Stacks.ConnectStack, {
screen: Screens.Scan,
params: {
implicitInvitations: enableImplicitInvitations,
reuseConnections: enableReuseConnections,
},
})
},
})}
>
Expand Down
10 changes: 9 additions & 1 deletion packages/legacy/core/App/screens/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ const Scan: React.FC<ScanProps> = ({ navigation, route }) => {
if (route?.params && route.params['defaultToConnect']) {
defaultToConnect = route.params['defaultToConnect']
}
let implicitInvitations = false
if (route?.params && route.params['implicitInvitations']) {
implicitInvitations = route.params['implicitInvitations']
}
let reuseConnections = false
if (route?.params && route.params['reuseConnections']) {
reuseConnections = route.params['reuseConnections']
}

const handleInvitation = async (value: string): Promise<void> => {
try {
const receivedInvitation = await connectFromInvitation(value, agent)
const receivedInvitation = await connectFromInvitation(value, agent, implicitInvitations, reuseConnections)
if (receivedInvitation?.connectionRecord?.id) {
// not connectionless
navigation.getParent()?.navigate(Stacks.ConnectionStack, {
Expand Down

0 comments on commit 1f1ad3d

Please sign in to comment.