Skip to content

Commit

Permalink
add backwards-compat for old versions blank config
Browse files Browse the repository at this point in the history
the old "Logout" functionality cleared the UI config but not other storage keys, such as those for marking consented and marking intro done.
A backwards-compat check is needed: if the UI config is blank but intro done or consented are marked true, we need to clear everything.
  • Loading branch information
JGreenlee committed Oct 5, 2023
1 parent 22880c8 commit 26bd469
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion www/js/config/dynamicConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export function getConfig() {
if (storedConfig) return Promise.resolve(storedConfig);
const KVStore = getAngularService('KVStore');
return KVStore.get(CONFIG_PHONE_UI_KVSTORE).then((config) => {
if (config) {
if (config && Object.keys(config).length) {
storedConfig = config;
return config;
}
Expand Down
9 changes: 8 additions & 1 deletion www/js/onboarding/onboardingHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DateTime } from "luxon";
import { getAngularService } from "../angular-react-helper";
import { getConfig } from "../config/dynamicConfig";
import { getConfig, resetDataAndRefresh } from "../config/dynamicConfig";

export const INTRO_DONE_KEY = 'intro_done';

Expand Down Expand Up @@ -28,6 +28,13 @@ export const setRegisterUserDone = (b) => registerUserDone = b;
export function getPendingOnboardingState(): Promise<OnboardingState> {
return Promise.all([getConfig(), readConsented(), readIntroDone()]).then(([config, isConsented, isIntroDone]) => {
let route: OnboardingRoute;

// backwards compat - prev. versions might have config cleared but still have intro_done set
if (!config && (isIntroDone || isConsented)) {
resetDataAndRefresh(); // if there's no config, we need to reset everything
return null;
}

if (isIntroDone) {
route = OnboardingRoute.DONE;
} else if (!config) {
Expand Down

0 comments on commit 26bd469

Please sign in to comment.