diff --git a/src/navigation/MainNavigator.tsx b/src/navigation/MainNavigator.tsx index 0944bc66e..0c56d2925 100644 --- a/src/navigation/MainNavigator.tsx +++ b/src/navigation/MainNavigator.tsx @@ -80,7 +80,7 @@ export interface MainStackParamList extends Record { Tutorial: undefined; QROnboard: undefined; RegionSelectExposedNoPT: {drawerMenu: boolean} | undefined; - RecentExposureScreen: {id: string; exposureType: ExposureType}; + RecentExposureScreen: {timestamp: number; exposureType: ExposureType}; } const LandingScreenWithNavBar = withDarkNav(LandingScreen); const HomeScreenWithNavBar = withDarkNav(HomeScreen); diff --git a/src/screens/exposureHistory/ExposureHistoryScreen.tsx b/src/screens/exposureHistory/ExposureHistoryScreen.tsx index 9e879e538..66933f205 100644 --- a/src/screens/exposureHistory/ExposureHistoryScreen.tsx +++ b/src/screens/exposureHistory/ExposureHistoryScreen.tsx @@ -39,8 +39,7 @@ const toOutbreakExposureHistoryData = ({ }): CombinedExposureHistoryData[] => { return history.map(outbreak => { return { - id: outbreak.locationId, - type: ExposureType.Outbreak, + exposureType: ExposureType.Outbreak, subtitle: severityText({severity: Number(outbreak.severity), i18n}), timestamp: outbreak.checkInTimestamp, }; @@ -48,18 +47,17 @@ const toOutbreakExposureHistoryData = ({ }; const toProximityExposureHistoryData = ({ - history, + proximityExposureTimestamps, i18n, }: { - history: number[]; + proximityExposureTimestamps: number[]; i18n: I18n; }): CombinedExposureHistoryData[] => { - return history.map(outbreak => { + return proximityExposureTimestamps.map(timestamp => { return { - id: outbreak, - type: ExposureType.Proximity, + exposureType: ExposureType.Proximity, subtitle: i18n.translate('QRCode.ProximityExposure'), - timestamp: outbreak, + timestamp, }; }); }; @@ -74,10 +72,10 @@ export const ExposureHistoryScreen = () => { const outbreaks = useOutbreakService(); const [clearExposedStatus] = useClearExposedStatus(); const currentOutbreakHistory = getCurrentOutbreakHistory(outbreaks.outbreakHistory); - const proximityExposure = useExposureHistory(); + const proximityExposureTimestamps = useExposureHistory(); const mergedArray = [ ...toOutbreakExposureHistoryData({history: currentOutbreakHistory, i18n}), - ...toProximityExposureHistoryData({history: proximityExposure, i18n}), + ...toProximityExposureHistoryData({proximityExposureTimestamps, i18n}), ]; const clearProximityExposure = useCallback(() => { clearExposedStatus(); diff --git a/src/screens/exposureHistory/RecentExposureView.tsx b/src/screens/exposureHistory/RecentExposureView.tsx index 09f82ed2d..5cdb44b7d 100644 --- a/src/screens/exposureHistory/RecentExposureView.tsx +++ b/src/screens/exposureHistory/RecentExposureView.tsx @@ -15,15 +15,11 @@ type RecentExposureScreenProps = RouteProp { const route = useRoute(); - if (!route.params?.id || !route.params?.exposureType) { - return null; - } - const id = route.params.id; if (route.params.exposureType === ExposureType.Outbreak) { - return ; + return ; } if (route.params.exposureType === ExposureType.Proximity) { - return ; + return ; } return null; }; diff --git a/src/screens/exposureHistory/views/ExposureList.tsx b/src/screens/exposureHistory/views/ExposureList.tsx index 2b5e9f106..6aaefaa56 100644 --- a/src/screens/exposureHistory/views/ExposureList.tsx +++ b/src/screens/exposureHistory/views/ExposureList.tsx @@ -11,7 +11,7 @@ export const ExposureList = ({exposureHistoryData}: {exposureHistoryData: Combin const dateLocale = i18n.locale === 'fr' ? 'fr-CA' : 'en-CA'; const navigation = useNavigation(); const onDetails = useCallback( - ({id, exposureType}) => navigation.navigate('RecentExposureScreen', {id, exposureType}), + ({timestamp, exposureType}) => navigation.navigate('RecentExposureScreen', {timestamp, exposureType}), [navigation], ); exposureHistoryData.sort(function (first, second) { @@ -28,14 +28,14 @@ export const ExposureList = ({exposureHistoryData}: {exposureHistoryData: Combin { - onDetails({id: `${item.id}-${item.timestamp}`, exposureType: item.type}); + onDetails({timestamp: item.timestamp, exposureType: item.exposureType}); }} > diff --git a/src/screens/home/views/ExposureDateView.tsx b/src/screens/home/views/ExposureDateView.tsx index 6860bd01f..837998c68 100644 --- a/src/screens/home/views/ExposureDateView.tsx +++ b/src/screens/home/views/ExposureDateView.tsx @@ -7,7 +7,7 @@ import {ForceScreen} from 'shared/ForceScreen'; import {useCachedStorage} from 'services/StorageService'; import {log} from 'shared/logging/config'; -export const ExposureDateView = () => { +export const ExposureDateView = ({timestamp}: {timestamp?: number}) => { const i18n = useI18n(); const dateLocale = i18n.locale === 'fr' ? 'fr-CA' : 'en-CA'; const {forceScreen} = useCachedStorage(); @@ -18,10 +18,13 @@ export const ExposureDateView = () => { if (forceScreen && forceScreen !== ForceScreen.None) { return [getCurrentDate()]; } + if (timestamp) { + return [new Date(timestamp)]; + } const _dates = exposureNotificationService.getExposureDetectedAt(); log.debug({message: '_dates', payload: {_dates}}); return _dates; - }, [exposureNotificationService, forceScreen]); + }, [exposureNotificationService, forceScreen, timestamp]); const formattedDates = dates.map(date => { return formatExposedDate(date, dateLocale); diff --git a/src/screens/home/views/OutbreakExposedView.tsx b/src/screens/home/views/OutbreakExposedView.tsx index e25f873a0..e1e6fdad1 100644 --- a/src/screens/home/views/OutbreakExposedView.tsx +++ b/src/screens/home/views/OutbreakExposedView.tsx @@ -10,7 +10,7 @@ import {HomeScreenTitle} from '../components/HomeScreenTitle'; import {NegativeOutbreakTestButton} from './ClearOutbreakExposureView'; -export const OutbreakExposedView = ({id}: {id?: string}) => { +export const OutbreakExposedView = ({timestamp}: {timestamp?: number}) => { const i18n = useI18n(); const {outbreakHistory} = useOutbreakService(); const currentOutbreakHistory = getCurrentOutbreakHistory(outbreakHistory); @@ -18,9 +18,9 @@ export const OutbreakExposedView = ({id}: {id?: string}) => { let historyItem: OutbreakHistoryItem = currentOutbreakHistory[0]; - if (id) { + if (timestamp) { currentOutbreakHistory.forEach(item => { - if (item.outbreakId === id) { + if (item.checkInTimestamp === timestamp) { historyItem = item; } }); @@ -28,11 +28,7 @@ export const OutbreakExposedView = ({id}: {id?: string}) => { const severity = historyItem?.severity; const exposureDate = formatExposedDate(new Date(historyItem?.checkInTimestamp), dateLocale); - let props = {}; - - if (id) { - props = {header: false}; - } + const props = timestamp ? {header: false} : {}; return ( diff --git a/src/screens/home/views/ProximityExposureView.tsx b/src/screens/home/views/ProximityExposureView.tsx index 4a7cafcc1..b5a773b77 100644 --- a/src/screens/home/views/ProximityExposureView.tsx +++ b/src/screens/home/views/ProximityExposureView.tsx @@ -19,7 +19,7 @@ const ActiveContent = ({text}: {text: string}) => { return {text}; }; -const ExposureText = () => { +const ExposureText = ({timestamp}: {timestamp?: number}) => { const {region} = useCachedStorage(); const regionalI18n = useRegionalI18n(); const regionActive = isRegionActive(region, regionalI18n.activeRegions); @@ -32,7 +32,7 @@ const ExposureText = () => { {i18n.translate('Home.ExposureDetected.Body1')} - + @@ -53,10 +53,11 @@ const ExposureText = () => { ); }; -export const ProximityExposureView = () => { +export const ProximityExposureView = ({timestamp}: {timestamp?: number}) => { + const props = timestamp ? {header: false} : {}; return ( - - + + ); }; diff --git a/src/shared/qr.ts b/src/shared/qr.ts index ea3426f49..e190b17f3 100644 --- a/src/shared/qr.ts +++ b/src/shared/qr.ts @@ -61,9 +61,8 @@ export interface OutbreakHistoryItem { } export interface CombinedExposureHistoryData { - id?: string | number; timestamp: number; - type: ExposureType; + exposureType: ExposureType; subtitle: string; }