Skip to content

Commit

Permalink
alter timing of markConsented
Browse files Browse the repository at this point in the history
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: e-mission/e-mission-docs#1006 (comment)
  • Loading branch information
Abby Wheelis committed Oct 18, 2023
1 parent bbb0f68 commit 18f384f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
6 changes: 3 additions & 3 deletions www/js/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const App = () => {
<AppContext.Provider value={appContextValue}>
{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) &&
<AppStatusModal permitVis={permissionsPopupVis} setPermitVis={setPermissionsPopupVis} />
}
</AppContext.Provider>
Expand Down
6 changes: 3 additions & 3 deletions www/js/onboarding/OnboardingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -19,8 +19,8 @@ const OnboardingStack = () => {
return <WelcomePage />;
} else if (onboardingState.route == OnboardingRoute.SUMMARY) {
return <SummaryPage />;
} else if (onboardingState.route == OnboardingRoute.CONSENT) {
return <ConsentPage />;
} else if (onboardingState.route == OnboardingRoute.PROTOCOL) {
return <ProtocolPage />;
} else if (onboardingState.route == OnboardingRoute.SAVE_QR) {
return <SaveQrPage />;
} else if (onboardingState.route == OnboardingRoute.SURVEY) {
Expand Down
11 changes: 5 additions & 6 deletions www/js/onboarding/ProtocolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -40,4 +39,4 @@ const ConsentPage = () => {
</>);
}

export default ConsentPage;
export default ProtocolPage;
15 changes: 9 additions & 6 deletions www/js/onboarding/SaveQrPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
17 changes: 10 additions & 7 deletions www/js/onboarding/onboardingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand All @@ -40,10 +43,10 @@ export function getPendingOnboardingState(): Promise<OnboardingState> {
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 {
Expand Down

0 comments on commit 18f384f

Please sign in to comment.