From 18f384f224a377381ce53743050ecc91d4a62044 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 18 Oct 2023 12:37:51 -0600 Subject: [PATCH] alter timing of markConsented in order to fix the bug, we're changing when we mark the consent in storage. Moving the call to after the user has agreed to both parts -- protocol AND permissions, prevents the early popup. For more discussion see: https://github.com/e-mission/e-mission-docs/issues/1006#issuecomment-1769073063 --- www/js/App.tsx | 6 +++--- www/js/onboarding/OnboardingStack.tsx | 6 +++--- www/js/onboarding/ProtocolPage.tsx | 11 +++++------ www/js/onboarding/SaveQrPage.tsx | 15 +++++++++------ www/js/onboarding/onboardingHelper.ts | 17 ++++++++++------- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/www/js/App.tsx b/www/js/App.tsx index 2187118fa..3c6c8bec9 100644 --- a/www/js/App.tsx +++ b/www/js/App.tsx @@ -91,9 +91,9 @@ const App = () => { {appContent} - { /* If we are past the consent page (route > CONSENT), the permissions popup can show if needed. - This also includes if onboarding is DONE altogether (because "DONE" is > "CONSENT") */ } - {(onboardingState && onboardingState.route > OnboardingRoute.CONSENT) && + { /* If we are fully consented, (route > PROTOCOL), the permissions popup can show if needed. + This also includes if onboarding is DONE altogether (because "DONE" is > "PROTOCOL") */ } + {(onboardingState && onboardingState.route > OnboardingRoute.PROTOCOL) && } diff --git a/www/js/onboarding/OnboardingStack.tsx b/www/js/onboarding/OnboardingStack.tsx index a49bde3ab..c547fd074 100644 --- a/www/js/onboarding/OnboardingStack.tsx +++ b/www/js/onboarding/OnboardingStack.tsx @@ -2,7 +2,7 @@ import React, { useContext } from "react"; import { StyleSheet } from "react-native"; import { AppContext } from "../App"; import WelcomePage from "./WelcomePage"; -import ConsentPage from "./ConsentPage"; +import ProtocolPage from "./ProtocolPage"; import SurveyPage from "./SurveyPage"; import SaveQrPage from "./SaveQrPage"; import SummaryPage from "./SummaryPage"; @@ -19,8 +19,8 @@ const OnboardingStack = () => { return ; } else if (onboardingState.route == OnboardingRoute.SUMMARY) { return ; - } else if (onboardingState.route == OnboardingRoute.CONSENT) { - return ; + } else if (onboardingState.route == OnboardingRoute.PROTOCOL) { + return ; } else if (onboardingState.route == OnboardingRoute.SAVE_QR) { return ; } else if (onboardingState.route == OnboardingRoute.SURVEY) { diff --git a/www/js/onboarding/ProtocolPage.tsx b/www/js/onboarding/ProtocolPage.tsx index 08aa3ab48..73961245a 100644 --- a/www/js/onboarding/ProtocolPage.tsx +++ b/www/js/onboarding/ProtocolPage.tsx @@ -7,8 +7,9 @@ import { AppContext } from '../App'; import { getAngularService } from '../angular-react-helper'; import PrivacyPolicy from './PrivacyPolicy'; import { onboardingStyles } from './OnboardingStack'; +import { setProtocolDone } from './onboardingHelper'; -const ConsentPage = () => { +const ProtocolPage = () => { const { t } = useTranslation(); const context = useContext(AppContext); @@ -20,10 +21,8 @@ const ConsentPage = () => { }; function agree() { - const StartPrefs = getAngularService('StartPrefs'); - StartPrefs.markConsented().then((response) => { - refreshOnboardingState(); - }); + setProtocolDone(true); + refreshOnboardingState(); }; // privacy policy and data collection info, followed by accept/reject buttons @@ -40,4 +39,4 @@ const ConsentPage = () => { ); } -export default ConsentPage; +export default ProtocolPage; diff --git a/www/js/onboarding/SaveQrPage.tsx b/www/js/onboarding/SaveQrPage.tsx index 51f884886..658c66993 100644 --- a/www/js/onboarding/SaveQrPage.tsx +++ b/www/js/onboarding/SaveQrPage.tsx @@ -20,12 +20,15 @@ const SaveQrPage = ({ }) => { useEffect(() => { if (overallStatus == true && !registerUserDone) { - logDebug('permissions done, going to log in'); - login(onboardingState.opcode).then((response) => { - logDebug('login done, refreshing onboarding state'); - setRegisterUserDone(true); - preloadDemoSurveyResponse(); - refreshOnboardingState(); + const StartPrefs = getAngularService('StartPrefs'); + StartPrefs.markConsented().then((response) => { + logDebug('permissions done, going to log in'); + login(onboardingState.opcode).then((response) => { + logDebug('login done, refreshing onboarding state'); + setRegisterUserDone(true); + preloadDemoSurveyResponse(); + refreshOnboardingState(); + }); }); } else { logDebug('permissions not done, waiting'); diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index cfbebb40b..4a6ec202c 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -6,12 +6,12 @@ import { logDebug } from "../plugin/logger"; export const INTRO_DONE_KEY = 'intro_done'; // route = WELCOME if no config present -// route = SUMMARY if config present, but not consented and summary not done -// route = CONSENT if config present, but not consented and summary done -// route = SAVE_QR if config present, consented, but save qr not done +// route = SUMMARY if config present, but protocol not done and summary not done +// route = PROTOCOL if config present, but protocol not done and summary done +// route = SAVE_QR if config present, protocol done, but save qr not done // route = SURVEY if config present, consented and save qr done // route = DONE if onboarding is finished (intro_done marked) -export enum OnboardingRoute { WELCOME, SUMMARY, CONSENT, SAVE_QR, SURVEY, DONE }; +export enum OnboardingRoute { WELCOME, SUMMARY, PROTOCOL, SAVE_QR, SURVEY, DONE }; export type OnboardingState = { opcode: string, route: OnboardingRoute, @@ -20,6 +20,9 @@ export type OnboardingState = { export let summaryDone = false; export const setSummaryDone = (b) => summaryDone = b; +export let protocolDone = false; +export const setProtocolDone = (b) => protocolDone = b; + export let saveQrDone = false; export const setSaveQrDone = (b) => saveQrDone = b; @@ -40,10 +43,10 @@ export function getPendingOnboardingState(): Promise { route = OnboardingRoute.DONE; } else if (!config) { route = OnboardingRoute.WELCOME; - } else if (!isConsented && !summaryDone) { + } else if (!protocolDone && !summaryDone) { route = OnboardingRoute.SUMMARY; - } else if (!isConsented) { - route = OnboardingRoute.CONSENT; + } else if (!protocolDone) { + route = OnboardingRoute.PROTOCOL; } else if (!saveQrDone) { route = OnboardingRoute.SAVE_QR; } else {