Skip to content

Commit

Permalink
Merge pull request #1025 from jolocom/SW-621/user-sees-history-record…
Browse files Browse the repository at this point in the history
…-after-interaction

SW-621 - user sees record after interaction ends on History screen
  • Loading branch information
thwalln authored Nov 8, 2022
2 parents 4583faa + fc97675 commit 9285735
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/hooks/interactions/useAuthSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/interactions/useAuthzSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/hooks/interactions/useCredentialShareSubmit.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/screens/LoggedIn/History/RecordItemsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ import { LoaderAnimation } from '~/components/LoaderAnimation/LoaderAnimation'

const ITEMS_PER_PAGE = 5

const RecordItemsList: React.FC<IRecordItemsListProps> = ({ id, flows }) => {
const RecordItemsList: React.FC<IRecordItemsListProps> = ({
id,
itemId,
flows,
}) => {
const { t } = useTranslation()
const sectionListRef = useRef<SectionList | null>(null)
const { updateActiveSection } = useRecord()

useEffect(() => {
itemId && setFocusedItem(itemId)
return () => {
setFocusedItem(null)
}
}, [itemId])

const [activeSection, setActiveSection] = useState('')
const [interactions, setInteractions] = useState<IPreLoadedInteraction[]>([])
const [page, setPage] = useState(0)
Expand Down Expand Up @@ -75,6 +86,7 @@ const RecordItemsList: React.FC<IRecordItemsListProps> = ({ id, flows }) => {
useEffect(() => {
getInteractionTokens(ITEMS_PER_PAGE, 0, flows)
.then((tokens) => {
tokens.length && setFocusedItem(tokens[0].id)
setTimeout(() => setLoaderType(LoaderTypes.empty), 200)
setInteractions(tokens)
})
Expand Down
8 changes: 7 additions & 1 deletion src/screens/LoggedIn/History/index.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -15,6 +18,9 @@ export enum RecordTypes {

const History = () => {
const { t } = useTranslation()
const itemId =
useRoute<RouteProp<MainTabsParamList, ScreenNames.History>>().params?.id

const SUBTABS = [
{ id: 'all', value: t('History.allTab') },
{ id: 'shared', value: t('History.sharedTab') },
Expand Down Expand Up @@ -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
*/}
<Record.ItemsList id="all" />
<Record.ItemsList id="all" itemId={itemId} />
</Tabs.PersistChildren>
<Tabs.PersistChildren
isContentVisible={activeSubtab?.id === 'shared'}
Expand Down
1 change: 1 addition & 0 deletions src/screens/LoggedIn/History/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export interface IRecordItemProps {

export interface IRecordItemsListProps {
id: string
itemId?: string
flows?: FlowType[]
}
2 changes: 1 addition & 1 deletion src/screens/LoggedIn/MainTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getAusweisInteractionDetails } from '~/modules/interaction/selectors'
export type MainTabsParamList = {
[ScreenNames.Identity]: undefined
[ScreenNames.Documents]: undefined
[ScreenNames.History]: undefined
[ScreenNames.History]: { id?: string }
[ScreenNames.Settings]: undefined
}

Expand Down

0 comments on commit 9285735

Please sign in to comment.