Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nzcovidtracer-dev committed Feb 3, 2021
1 parent ff9c283 commit e47c38b
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 54 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ APPCENTER_BUILD_ID=1
ENFServerUrl=

# Google's SafetynetKey for Device Attestation API
SafetynetKey=
SafetynetKey=

ENFCheckInterval=
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ PODS:
- react-native-config/App (= 1.3.3)
- react-native-config/App (1.3.3):
- React
- react-native-exposure-notification-service (1.1.44):
- react-native-exposure-notification-service (1.2.6):
- Alamofire (~> 5.2)
- KeychainSwift (~> 19.0)
- React
Expand Down Expand Up @@ -450,7 +450,7 @@ DEPENDENCIES:
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
https://cdn.cocoapods.org/:
trunk:
- Alamofire
- AppCenter
- AppCenterReactNativeShared
Expand Down Expand Up @@ -620,7 +620,7 @@ SPEC CHECKSUMS:
React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606
react-native-camera: 35854c4f764a4a6cf61c1c3525888b92f0fe4b31
react-native-config: 9a061347e0136fdb32d43a34d60999297d672361
react-native-exposure-notification-service: 32ca3fa42976b518bf0a8e2b0bf16810d75e41b9
react-native-exposure-notification-service: bc9fe5ece6048ac6eca17f5649367014a6bfbfc2
react-native-netinfo: 250dc0ca126512f618a8a2ca6a936577e1f66586
react-native-safe-area-context: 955ecfce672683b495d9294d2f154a9ad1d9796b
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
Expand Down Expand Up @@ -657,4 +657,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 9a46cbeb408836d3fa898d9ed314381af73a92d1

COCOAPODS: 1.9.3
COCOAPODS: 1.10.1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"react-native-config": "^1.3.3",
"react-native-country-picker-modal": "^2.0.0",
"react-native-device-info": "^6.0.2",
"react-native-exposure-notification-service": "^1.1.44",
"react-native-exposure-notification-service": "1.2.6",
"react-native-gesture-handler": "^1.8.0",
"react-native-google-safetynet": "^1.0.0",
"react-native-haptic-feedback": "^1.11.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ echo "APP_VERSION=${APP_VERSION}" >>.env
echo "APPCENTER_BUILD_ID=${APPCENTER_BUILD_ID}" >>.env
echo "ENFServerUrl=${ENFServerUrl}" >>.env
echo "SafetynetKey=${SafetynetKey}" >>.env
echo "ENFCheckInterval=${ENFCheckInterval}" >>.env


printf "\n.env created with contents:\n"
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/config.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Object {
"ContactAlertsUrl": "https://www.health.govt.nz/nz-covid-tracer-contact-alerts",
"ContactUsPageUrl": "https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-resources-and-tools/nz-covid-tracer-app/contact-nz-covid-tracer",
"DbEncryptionKey": "",
"ENFCheckInterval": 180,
"ENFServerUrl": "",
"ExposureEventsBaseUrl": "https://exposure-events.",
"Features": Set {},
Expand Down
13 changes: 13 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AppConfigRaw {
ANDROID_VERSION_CODE_OFFSET?: string;
ENFServerUrl?: string;
SafetynetKey?: string;
ENFCheckInterval?: string;
}

export interface AppConfig {
Expand Down Expand Up @@ -65,6 +66,7 @@ export interface AppConfig {
APPCENTER_BUILD_ID: string;
ENFServerUrl: string;
SafetynetKey: string;
ENFCheckInterval: number;
}

export let disableAnimations = false;
Expand Down Expand Up @@ -119,6 +121,16 @@ export const getBuildId = (offset?: string, buildId?: string) => {

export { buildUrl as _buildUrl };

const getENFCheckInterval = () => {
if (raw.ENFCheckInterval) {
const parsed = parseInt(raw.ENFCheckInterval);
if (!isNaN(parsed)) {
return Math.max(15, parsed);
}
}
return 180;
};

const config: AppConfig = {
APIServiceAddress: raw.APIServiceAddress || "",
AppAddress: raw.AppAddress || "",
Expand Down Expand Up @@ -169,6 +181,7 @@ const config: AppConfig = {
),
ENFServerUrl: raw.ENFServerUrl || "",
SafetynetKey: raw.SafetynetKey || "",
ENFCheckInterval: getENFCheckInterval(),
};

export default config;
2 changes: 1 addition & 1 deletion src/features/debugging/commands/enfCheckExposure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const enfCheckExposure = (
title: "Check Exposure",
async run() {
const { checkExposure } = exposure;
checkExposure(true, false);
checkExposure(false);
Alert.alert("checkExposure", "Done");
},
});
10 changes: 5 additions & 5 deletions src/features/debugging/commands/enfContacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const enfContacts = (exposure: ExposureContextValue): TestCommand => ({
const contacts = await getCloseContacts();

const latestExposureDate = contacts?.reduce<number>((max, contact) => {
const exposureDate = moment(parseInt(contact.exposureAlertDate, 10))
const exposureDate = moment(contact.exposureAlertDate)
.subtract(contact.daysSinceLastExposure, "days")
.valueOf();
return max > exposureDate ? max : exposureDate;
Expand All @@ -21,12 +21,12 @@ export const enfContacts = (exposure: ExposureContextValue): TestCommand => ({
(acc, contact, ix, array) =>
acc
.concat(
`Alert date: ${moment(
parseInt(contact.exposureAlertDate, 10),
).format("DD MMM HH:mm")}`,
`Alert date: ${moment(contact.exposureAlertDate).format(
"DD MMM HH:mm",
)}`,
)
.concat(
`\nExposure date: ${moment(parseInt(contact.exposureAlertDate, 10))
`\nExposure date: ${moment(contact.exposureAlertDate)
.subtract(contact.daysSinceLastExposure, "days")
.format("DD MMM HH:mm")}`,
)
Expand Down
2 changes: 1 addition & 1 deletion src/features/debugging/commands/enfSimulateExposure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export const enfSimulateExposure = (
return;
}
}
exposure.simulateExposure(0);
exposure.simulateExposure(0, 0);
},
});
2 changes: 1 addition & 1 deletion src/features/enf/components/ExposureProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ExposureProvider(props: ExposureProviderProps) {
keyServerUrl: config.ENFServerUrl,
keyServerType: KeyServerType.nearform,
traceConfiguration: {
exposureCheckInterval: 180,
exposureCheckInterval: config.ENFCheckInterval,
storeExposuresFor: 14,
fileLimit: 1,
fileLimitiOS: 3,
Expand Down
4 changes: 1 addition & 3 deletions src/features/enfExposure/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export const recordDismissENFAlert = (enfAlert: ENFAlertData) => {
export const recordDisplayENFAlert = (match: CloseContact) => {
recordAnalyticEvent(ENFEvent.ENFBannerDisplayed, {
attributes: {
alertDate: moment(parseInt(match.exposureAlertDate, 10)).format(
"DD MMM YYYY",
),
alertDate: moment(match.exposureAlertDate).format("DD MMM YYYY"),
},
metrics: {
riskScore: match.maxRiskScore,
Expand Down
30 changes: 17 additions & 13 deletions src/features/enfExposure/sagas/updateENFAlert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,33 @@ import {
import updateENFAlert from "./updateENFAlert";

const CONTACT1: CloseContact = {
exposureAlertDate: moment("2020-11-10T00:00:00.000Z").valueOf().toString(),
exposureAlertDate: moment("2020-11-10T00:00:00.000Z").valueOf(),
daysSinceLastExposure: 2,
attenuationDurations: [],
matchedKeyCount: 1,
maxRiskScore: 10,
summationRiskScore: 10,
riskScoreSumFullRange: 10,
maxRiskScoreFullRange: 10,
exposureDate: moment("2020-11-10T00:00:00.000Z").valueOf(),
};

// the most recent exposure date, alert date is between contact1 and 3
const CONTACT2 = {
const CONTACT2: CloseContact = {
maxRiskScore: 120,
exposureAlertDate: moment("2020-11-15T00:00:00.000Z").valueOf().toString(),
exposureAlertDate: moment("2020-11-15T00:00:00.000Z").valueOf(),
daysSinceLastExposure: 2,
attenuationDurations: [],
matchedKeyCount: 1,
summationRiskScore: 120,
riskScoreSumFullRange: 120,
maxRiskScoreFullRange: 120,
exposureDate: moment("2020-11-15T00:00:00.000Z").valueOf(),
};

// this one has the most recent alert date, but not recent exposure date
const CONTACT3 = {
const CONTACT3: CloseContact = {
...CONTACT1,
maxRiskScore: 10,
exposureAlertDate: moment("2020-11-20T00:00:00.000Z").valueOf().toString(),
exposureAlertDate: moment("2020-11-20T00:00:00.000Z").valueOf(),
daysSinceLastExposure: 10,
matchedKeyCount: 2,
};
Expand All @@ -47,8 +51,8 @@ const RESULT_FROM_CONTACT1_BUCKET0: ENFAlertData = {
alertTitle: enfConfig[0].alertTitle,
alertMessage: enfConfig[0].alertMessage,
linkUrl: enfConfig[0].linkUrl,
alertDate: parseInt(CONTACT1.exposureAlertDate, 10),
exposureDate: moment(parseInt(CONTACT1.exposureAlertDate, 10))
alertDate: CONTACT1.exposureAlertDate,
exposureDate: moment(CONTACT1.exposureAlertDate)
.subtract(CONTACT1.daysSinceLastExposure, "days")
.valueOf(),
exposureCount: 1,
Expand All @@ -58,8 +62,8 @@ const RESULT_FROM_CONTACT2_BUCKET2: ENFAlertData = {
alertTitle: enfConfig[2].alertTitle,
alertMessage: enfConfig[2].alertMessage,
linkUrl: enfConfig[2].linkUrl,
alertDate: parseInt(CONTACT2.exposureAlertDate, 10),
exposureDate: moment(parseInt(CONTACT2.exposureAlertDate, 10))
alertDate: CONTACT2.exposureAlertDate,
exposureDate: moment(CONTACT2.exposureAlertDate)
.subtract(CONTACT2.daysSinceLastExposure, "days")
.valueOf(),
exposureCount: 1,
Expand All @@ -69,8 +73,8 @@ const RESULT_FROM_CONTACT2_BUCKET2_1: ENFAlertData = {
alertTitle: enfConfig[2].alertTitle,
alertMessage: enfConfig[2].alertMessage,
linkUrl: enfConfig[2].linkUrl,
alertDate: parseInt(CONTACT2.exposureAlertDate, 10),
exposureDate: moment(parseInt(CONTACT2.exposureAlertDate, 10))
alertDate: CONTACT2.exposureAlertDate,
exposureDate: moment(CONTACT2.exposureAlertDate)
.subtract(CONTACT2.daysSinceLastExposure, "days")
.valueOf(),
exposureCount: 3,
Expand Down
6 changes: 3 additions & 3 deletions src/features/enfExposure/sagas/updateENFAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export default function* updateENFAlert(
const match = contacts.reduce<CloseContact | undefined>(
(current, contact) => {
const currentExposureDate = current
? moment(parseInt(contact.exposureAlertDate, 10))
? moment(contact.exposureAlertDate)
.subtract(contact.daysSinceLastExposure, "days")
.valueOf()
: 0;

const exposureDate = moment(parseInt(contact.exposureAlertDate, 10))
const exposureDate = moment(contact.exposureAlertDate)
.subtract(contact.daysSinceLastExposure, "days")
.valueOf();

Expand Down Expand Up @@ -87,7 +87,7 @@ export default function* updateENFAlert(
return;
}

const alertDate = parseInt(match.exposureAlertDate, 10);
const alertDate = match.exposureAlertDate;

const result: ENFAlertData = {
exposureCount,
Expand Down
29 changes: 12 additions & 17 deletions src/features/scan/views/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,28 +371,23 @@ export function Scan(props: Props) {
[canScanBarcode, currentUserId, isFocused, saveEntryAsync, showError, t],
);

const appState = useAppState();

const showCamera = useMemo(
() => isCameraMounted && cameraPermission === "granted",
[isCameraMounted, cameraPermission],
() =>
appState !== "background" &&
isCameraMounted &&
cameraPermission === "granted",
[isCameraMounted, cameraPermission, appState],
);

const appState = useAppState();

useEffect(() => {
if (cameraRef.current == null) {
return;
}
switch (appState) {
case "background":
logInfo("pause preview");
cameraRef.current.pausePreview();
break;
case "active":
logInfo("resume preview");
cameraRef.current.resumePreview();
break;
if (showCamera) {
logInfo("show camera");
} else {
logInfo("hide camera");
}
}, [appState]);
}, [showCamera]);

useAccessibleTitle();

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9387,10 +9387,10 @@ react-native-device-info@^6.0.2:
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-6.2.1.tgz#6b63faeef833d8959d636c0413ccd5066eada2bf"
integrity sha512-+9Li07jD+7IiSIn9VVmb1YWYfJtgERVMsgO/hG+aUzsFD6uFklpM2TOEBlfKPWP/8J6s8MZgpGfA/Dl1WZrn2g==

react-native-exposure-notification-service@^1.1.44:
version "1.1.44"
resolved "https://registry.yarnpkg.com/react-native-exposure-notification-service/-/react-native-exposure-notification-service-1.1.44.tgz#bf02c63efa98f61cff4c01b0a7eb150c094d6640"
integrity sha512-sL4+NnVcWSjh9l8S2oLHMJh5YPEJGGg0jKAqERoKlwS2lA51uWJGS7/DcHDQSTiiwp5y4EEvPF4ZJ4y5YjM4sA==
react-native-exposure-notification-service@1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/react-native-exposure-notification-service/-/react-native-exposure-notification-service-1.2.6.tgz#e0ba0b80352d243b7843ee01edd669a372198abd"
integrity sha512-BJwgj1G0iN+5vvJgCgN3z6tdEVz3xXzrKPqoTk6Z0BTl9bQ47VEhHsILvygc5aN5HKJM78eBsQezccgLNDrLpg==

react-native-flipper@^0.34.0:
version "0.34.0"
Expand Down

0 comments on commit e47c38b

Please sign in to comment.