Skip to content

Commit

Permalink
chore: activity and issuer data
Browse files Browse the repository at this point in the history
  • Loading branch information
janrtvld committed Oct 30, 2024
1 parent d9dc0e4 commit 6c55189
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions apps/easypid/src/app/(app)/activity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FunkeActivityScreen } from '@easypid/features/activity/FunkeActivityScr
import { useLocalSearchParams } from 'expo-router'

export default function Screen() {
const { host } = useLocalSearchParams()
const { host, name } = useLocalSearchParams()

return <FunkeActivityScreen host={host as string} />
return <FunkeActivityScreen host={host as string} name={name as string} />
}
4 changes: 2 additions & 2 deletions apps/easypid/src/features/activity/FunkeActivityScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React, { useMemo } from 'react'
import { FadeInDown } from 'react-native-reanimated'
import { useActivities } from './activityRecord'

export function FunkeActivityScreen({ host }: { host?: string }) {
const { activities, isLoading: isLoadingActivities } = useActivities({ filters: { host } })
export function FunkeActivityScreen({ host, name }: { host?: string; name?: string }) {
const { activities, isLoading: isLoadingActivities } = useActivities({ filters: { host, name } })

const { handleScroll, isScrolledByOffset, scrollEventThrottle } = useScrollViewPosition()

Expand Down
10 changes: 5 additions & 5 deletions apps/easypid/src/features/activity/activityRecord.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { utils } from '@credo-ts/core'
import { type DisplayImage, type EasyPIDAppAgent, getWalletJsonStore, useWalletJsonRecord } from '@package/agent'
import { getHostNameFromUrl } from 'packages/utils/src'
import { useMemo } from 'react'

export type ActivityType = 'shared' | 'received'
Expand Down Expand Up @@ -63,7 +62,7 @@ export const activityStorage = {
},
}

export const useActivities = ({ filters }: { filters?: { host?: string } } = {}) => {
export const useActivities = ({ filters }: { filters?: { host?: string; name?: string } } = {}) => {
const { record, isLoading } = useWalletJsonRecord<ActivityRecord>(activityStorage.recordId)

const activities = useMemo(() => {
Expand All @@ -72,10 +71,11 @@ export const useActivities = ({ filters }: { filters?: { host?: string } } = {})
return [...record.activities]
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
.filter((activity) => {
if (filters?.host) return activity.entity.host === filters.host
return true
const hostMatch = !filters?.host || activity.entity.host === filters.host
const nameMatch = !filters?.name || activity.entity.name === filters.name
return hostMatch && nameMatch
})
}, [record?.activities, filters?.host])
}, [record?.activities, filters?.host, filters?.name])

return {
activities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ export function FunkeOpenIdCredentialNotificationScreen() {
void requestCredential(params)
}, [params, agent])

const issuerMetadata = useMemo(
() =>
credential?.display.issuer.domain ? getOpenIdFedIssuerMetadata(credential.display.issuer.domain) : undefined,
[credential]
)

const lastInteractionDate = useMemo(() => {
const activity = activities.find((activity) => activity.entity.host === credential?.display.issuer.domain)
const activity = activities.find((activity) => {
const hostMatch = activity.entity.host === credential?.display.issuer.domain
const nameMatch = activity.entity.name === credential?.display.issuer.name
return hostMatch && nameMatch
})
return activity?.date
}, [activities, credential])

Expand Down Expand Up @@ -120,12 +118,12 @@ export function FunkeOpenIdCredentialNotificationScreen() {
<VerifyPartySlide
key="verify-issuer"
type="offer"
name={issuerMetadata?.display.name ?? credential?.display.issuer.name}
logo={issuerMetadata?.display.logo ?? credential?.display.issuer.logo}
name={credential?.display.issuer.name}
logo={credential?.display.issuer.logo}
host={credential?.display.issuer.domain as string}
backgroundColor={credential?.display.backgroundColor}
lastInteractionDate={lastInteractionDate}
approvalsCount={issuerMetadata?.approvals.length}
approvalsCount={0}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const OfferCredentialSlide = ({
btw="$0.5"
px="$4"
mx="$-4"
borderColor={isScrolledByOffset ? '$grey-200' : '$background'}
borderColor={isScrolledByOffset && !isStoringOrCompleted ? '$grey-200' : '$background'}
onLayout={(event) => {
if (!scrollViewHeight) {
setScrollViewHeight(event.nativeEvent.layout.height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const VerifyPartySlide = ({
})

const onPressInteraction = withHaptics(() => {
router.push(`/activity?host=${host}`)
router.push(`/activity?host=${host}&name=${name}`)
})

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function FunkeRequestedAttributesDetailScreen({
headerTitle="Metadata"
borderStyle="large"
attributeWeight="medium"
subject={activeCredential?.metadata as Record<string, unknown>}
subject={activeCredential.metadataForDisplay ?? activeCredential?.metadata}
headerStyle="small"
showDevProps
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function FunkeCredentialDetailScreen() {
<Heading ta="center" variant="h1">
Card details
</Heading>
<Paragraph numberOfLines={1} ta="center">
<Paragraph numberOfLines={2} ta="center">
Issued by {credential.display.issuer.name}.
</Paragraph>
</Stack>
Expand Down
1 change: 0 additions & 1 deletion apps/easypid/src/utils/issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const DEFAULT_FUNKE_HOST = 'funke.animo.id'

const FUNKE_ISSUER_DATA = {
host: DEFAULT_FUNKE_HOST,
did: 'did:web:funke',
display: {
name: 'Animo',
logo: {
Expand Down

0 comments on commit 6c55189

Please sign in to comment.