diff --git a/src/hooks/interactions/useAuthSubmit.ts b/src/hooks/interactions/useAuthSubmit.ts index 0a03d0f0e..7c1652c4d 100644 --- a/src/hooks/interactions/useAuthSubmit.ts +++ b/src/hooks/interactions/useAuthSubmit.ts @@ -2,19 +2,19 @@ import { useInteraction } from './handlers' import { useCompleteInteraction } from './useCompleteInteraction' import { useAgent } from '../sdk' import { ScreenNames } from '~/types/screens' +import { useRedirect } from '../navigation' const useAuthSubmit = () => { const getInteraction = useInteraction() const agent = useAgent() + const redirect = useRedirect() const { completeInteraction } = useCompleteInteraction(async () => { const interaction = await getInteraction() const authResponse = await interaction.createAuthenticationResponse() await agent.processJWT(authResponse) await interaction.send(authResponse) - return { - screenToNavigate: ScreenNames.History, - } + return redirect(ScreenNames.History, { id: interaction.id }) }) return completeInteraction diff --git a/src/hooks/interactions/useAuthzSubmit.ts b/src/hooks/interactions/useAuthzSubmit.ts index e165ffae5..875d68336 100644 --- a/src/hooks/interactions/useAuthzSubmit.ts +++ b/src/hooks/interactions/useAuthzSubmit.ts @@ -2,19 +2,19 @@ import { useInteraction } from './handlers' import { useCompleteInteraction } from './useCompleteInteraction' import { useAgent } from '../sdk' import { ScreenNames } from '~/types/screens' +import { useRedirect } from '../navigation' const useAuthzSubmit = () => { const getInteraction = useInteraction() const agent = useAgent() + const redirect = useRedirect() const { completeInteraction } = useCompleteInteraction(async () => { const interaction = await getInteraction() const authzResponse = await interaction.createAuthorizationResponse() await agent.processJWT(authzResponse) await interaction.send(authzResponse) - return { - screenToNavigate: ScreenNames.History, - } + return redirect(ScreenNames.History, { id: interaction.id }) }) return completeInteraction diff --git a/src/hooks/interactions/useCredentialShareSubmit.ts b/src/hooks/interactions/useCredentialShareSubmit.ts index 08203cb4c..0ab225ecf 100644 --- a/src/hooks/interactions/useCredentialShareSubmit.ts +++ b/src/hooks/interactions/useCredentialShareSubmit.ts @@ -1,15 +1,18 @@ import { useCredentialShareFlow } from './useCredentialShareFlow' import { useCompleteInteraction } from './useCompleteInteraction' import { ScreenNames } from '~/types/screens' +import { useInteraction } from './handlers' +import { useRedirect } from '../navigation' const useCredentialShareSubmit = () => { + const getInteraction = useInteraction() const { assembleShareResponseToken } = useCredentialShareFlow() + const redirect = useRedirect() const { completeInteraction } = useCompleteInteraction(async () => { + const interaction = await getInteraction() await assembleShareResponseToken() - return { - screenToNavigate: ScreenNames.History, - } + return redirect(ScreenNames.History, { id: interaction.id }) }) return completeInteraction diff --git a/src/screens/LoggedIn/History/RecordItemsList.tsx b/src/screens/LoggedIn/History/RecordItemsList.tsx index 6ae218393..7951e8a18 100644 --- a/src/screens/LoggedIn/History/RecordItemsList.tsx +++ b/src/screens/LoggedIn/History/RecordItemsList.tsx @@ -21,11 +21,22 @@ import { LoaderAnimation } from '~/components/LoaderAnimation/LoaderAnimation' const ITEMS_PER_PAGE = 5 -const RecordItemsList: React.FC = ({ id, flows }) => { +const RecordItemsList: React.FC = ({ + id, + itemId, + flows, +}) => { const { t } = useTranslation() const sectionListRef = useRef(null) const { updateActiveSection } = useRecord() + useEffect(() => { + itemId && setFocusedItem(itemId) + return () => { + setFocusedItem(null) + } + }, [itemId]) + const [activeSection, setActiveSection] = useState('') const [interactions, setInteractions] = useState([]) const [page, setPage] = useState(0) @@ -75,6 +86,7 @@ const RecordItemsList: React.FC = ({ id, flows }) => { useEffect(() => { getInteractionTokens(ITEMS_PER_PAGE, 0, flows) .then((tokens) => { + tokens.length && setFocusedItem(tokens[0].id) setTimeout(() => setLoaderType(LoaderTypes.empty), 200) setInteractions(tokens) }) diff --git a/src/screens/LoggedIn/History/index.tsx b/src/screens/LoggedIn/History/index.tsx index 8ce886523..61e6bfa2e 100644 --- a/src/screens/LoggedIn/History/index.tsx +++ b/src/screens/LoggedIn/History/index.tsx @@ -1,10 +1,13 @@ import { FlowType } from '@jolocom/sdk' +import { RouteProp, useRoute } from '@react-navigation/native' import React from 'react' import ScreenContainer from '~/components/ScreenContainer' import TabsContainer from '~/components/Tabs/Container' import Tabs from '~/components/Tabs/Tabs' import useTranslation from '~/hooks/useTranslation' +import { ScreenNames } from '~/types/screens' +import { MainTabsParamList } from '../MainTabs' import Record from './Record' export enum RecordTypes { @@ -15,6 +18,9 @@ export enum RecordTypes { const History = () => { const { t } = useTranslation() + const itemId = + useRoute>().params?.id + const SUBTABS = [ { id: 'all', value: t('History.allTab') }, { id: 'shared', value: t('History.sharedTab') }, @@ -43,7 +49,7 @@ const History = () => { {/* ItemsList should have a param type: should be added once there is a support for passing multiple interaction types to support all subtab usecase */} - +