From 0e31d1549159114e542d70a6f16f6bdbe1b1b232 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Tue, 17 Oct 2023 16:18:26 -0600 Subject: [PATCH 01/28] remove unused imports from startprefts.js --- www/js/splash/startprefs.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/www/js/splash/startprefs.js b/www/js/splash/startprefs.js index 92a07e624..1bc01af3d 100644 --- a/www/js/splash/startprefs.js +++ b/www/js/splash/startprefs.js @@ -2,11 +2,10 @@ import angular from 'angular'; import { getConfig } from '../config/dynamicConfig'; import { storageGet, storageSet } from '../plugin/storage'; -angular.module('emission.splash.startprefs', ['emission.plugin.logger', - 'emission.splash.referral']) +angular.module('emission.splash.startprefs', ['emission.plugin.logger']) -.factory('StartPrefs', function($window, $state, $interval, $rootScope, $ionicPlatform, - $ionicPopup, $http, Logger, ReferralHandler) { +.factory('StartPrefs', function($window, $state, $rootScope, + $ionicPopup, $http, Logger) { var logger = Logger; var startprefs = {}; // Boolean: represents that the "intro" - the one page summary From 4fc39827f8260b32abaaa66f7dc203f44ab1fb87 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Tue, 17 Oct 2023 17:53:33 -0600 Subject: [PATCH 02/28] convert startprefs from .js to .ts first attempt at converting to a ts file, not fully functional, but did find several functions that were no longer used and so have been removed --- www/js/splash/startprefs.js | 170 ------------------------------------ www/js/splash/startprefs.ts | 119 +++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 170 deletions(-) delete mode 100644 www/js/splash/startprefs.js create mode 100644 www/js/splash/startprefs.ts diff --git a/www/js/splash/startprefs.js b/www/js/splash/startprefs.js deleted file mode 100644 index 1bc01af3d..000000000 --- a/www/js/splash/startprefs.js +++ /dev/null @@ -1,170 +0,0 @@ -import angular from 'angular'; -import { getConfig } from '../config/dynamicConfig'; -import { storageGet, storageSet } from '../plugin/storage'; - -angular.module('emission.splash.startprefs', ['emission.plugin.logger']) - -.factory('StartPrefs', function($window, $state, $rootScope, - $ionicPopup, $http, Logger) { - var logger = Logger; - var startprefs = {}; - // Boolean: represents that the "intro" - the one page summary - // and the login are done - var INTRO_DONE_KEY = 'intro_done'; - // data collection consented protocol: string, represents the date on - // which the consented protocol was approved by the IRB - var DATA_COLLECTION_CONSENTED_PROTOCOL = 'data_collection_consented_protocol'; - - var CONSENTED_KEY = "config/consent"; - - startprefs.CONSENTED_EVENT = "data_collection_consented"; - startprefs.INTRO_DONE_EVENT = "intro_done"; - - var writeConsentToNative = function() { - return $window.cordova.plugins.BEMDataCollection.markConsented($rootScope.req_consent); - }; - - startprefs.markConsented = function() { - logger.log("changing consent from "+ - $rootScope.curr_consented+" -> "+JSON.stringify($rootScope.req_consent)); - // mark in native storage - return startprefs.readConsentState().then(writeConsentToNative).then(function(response) { - // mark in local storage - storageSet(DATA_COLLECTION_CONSENTED_PROTOCOL, - $rootScope.req_consent); - // mark in local variable as well - $rootScope.curr_consented = angular.copy($rootScope.req_consent); - $rootScope.$emit(startprefs.CONSENTED_EVENT, $rootScope.req_consent); - }); - }; - - startprefs.markIntroDone = function() { - var currTime = moment().format(); - storageSet(INTRO_DONE_KEY, currTime); - $rootScope.$emit(startprefs.INTRO_DONE_EVENT, currTime); - } - - // returns boolean - startprefs.readIntroDone = function() { - return storageGet(INTRO_DONE_KEY).then(function(read_val) { - logger.log("in readIntroDone, read_val = "+JSON.stringify(read_val)); - $rootScope.intro_done = read_val; - }); - } - - startprefs.isIntroDone = function() { - if ($rootScope.intro_done == null || $rootScope.intro_done == "") { - logger.log("in isIntroDone, returning false"); - $rootScope.is_intro_done = false; - return false; - } else { - logger.log("in isIntroDone, returning true"); - $rootScope.is_intro_done = true; - return true; - } - } - - startprefs.isConsented = function() { - if ($rootScope.curr_consented == null || $rootScope.curr_consented == "" || - $rootScope.curr_consented.approval_date != $rootScope.req_consent.approval_date) { - console.log("Not consented in local storage, need to show consent"); - $rootScope.is_consented = false; - return false; - } else { - console.log("Consented in local storage, no need to show consent"); - $rootScope.is_consented = true; - return true; - } - } - - startprefs.readConsentState = function() { - // read consent state from the file and populate it - return $http.get("json/startupConfig.json") - .then(function(startupConfigResult) { - $rootScope.req_consent = startupConfigResult.data.emSensorDataCollectionProtocol; - logger.log("required consent version = " + JSON.stringify($rootScope.req_consent)); - return storageGet(DATA_COLLECTION_CONSENTED_PROTOCOL); - }).then(function(kv_store_consent) { - $rootScope.curr_consented = kv_store_consent; - console.assert(angular.isDefined($rootScope.req_consent), "in readConsentState $rootScope.req_consent", JSON.stringify($rootScope.req_consent)); - // we can just launch this, we don't need to wait for it - startprefs.checkNativeConsent(); - }); - } - - startprefs.readConfig = function() { - return getConfig().then((savedConfig) => $rootScope.app_ui_label = savedConfig); - } - - startprefs.hasConfig = function() { - if ($rootScope.app_ui_label == undefined || - $rootScope.app_ui_label == null || - $rootScope.app_ui_label == "") { - logger.log("Config not downloaded, need to show join screen"); - $rootScope.has_config = false; - return false; - } else { - $rootScope.has_config = true; - logger.log("Config downloaded, skipping join screen"); - return true; - } - } - - /* - * Read the intro_done and consent_done variables into the $rootScope so that - * we can use them without making multiple native calls - */ - startprefs.readStartupState = function() { - console.log("STARTPREFS: about to read startup state"); - var readIntroPromise = startprefs.readIntroDone() - .then(startprefs.isIntroDone); - var readConsentPromise = startprefs.readConsentState() - .then(startprefs.isConsented); - var readConfigPromise = startprefs.readConfig() - .then(startprefs.hasConfig); - return Promise.all([readIntroPromise, readConsentPromise, readConfigPromise]); - }; - - startprefs.getConsentDocument = function() { - return $window.cordova.plugins.BEMUserCache.getDocument("config/consent", false) - .then(function(resultDoc) { - if ($window.cordova.plugins.BEMUserCache.isEmptyDoc(resultDoc)) { - return null; - } else { - return resultDoc; - } - }); - }; - - startprefs.checkNativeConsent = function() { - startprefs.getConsentDocument().then(function(resultDoc) { - if (resultDoc == null) { - if(startprefs.isConsented()) { - logger.log("Local consent found, native consent missing, writing consent to native"); - $ionicPopup.alert({template: "Local consent found, native consent missing, writing consent to native"}); - return writeConsentToNative(); - } else { - logger.log("Both local and native consent not found, nothing to sync"); - } - } - }); - } - - var changeState = function(destState) { - logger.log('changing state to '+destState); - console.log("loading "+destState); - // TODO: Fix this the right way when we fix the FSM - // https://github.com/e-mission/e-mission-phone/issues/146#issuecomment-251061736 - var reload = false; - if (($state.$current == destState.state) && ($state.$current.name == 'root.main.goals')) { - reload = true; - } - $state.go(destState.state, destState.params).then(function() { - if (reload) { - $rootScope.$broadcast("RELOAD_GOAL_PAGE_FOR_REFERRAL") - } - }); - }; - - return startprefs; -}); diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts new file mode 100644 index 000000000..d8c422568 --- /dev/null +++ b/www/js/splash/startprefs.ts @@ -0,0 +1,119 @@ +import { storageGet, storageSet } from '../plugin/storage'; +import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; + +type StartPrefs = { + CONSENTED_EVENT: string, + INTRO_DONE_EVENT: string, +} + +export const startPrefs: StartPrefs = { + CONSENTED_EVENT: "data_collection_consented", + INTRO_DONE_EVENT: "intro_done", +}; +// Boolean: represents that the "intro" - the one page summary +// and the login are done +const INTRO_DONE_KEY = 'intro_done'; +// data collection consented protocol: string, represents the date on +// which the consented protocol was approved by the IRB +const DATA_COLLECTION_CONSENTED_PROTOCOL = 'data_collection_consented_protocol'; + +const CONSENTED_KEY = "config/consent"; + +let _req_consent; +let _curr_consented; + +function writeConsentToNative() { + return window['cordiva'].plugins.BEMDataCollection.markConsented(_req_consent); +}; + +//used in ConsentPage +export function markConsented() { + logInfo("changing consent from " + + _curr_consented + " -> " + JSON.stringify(_req_consent)); + // mark in native storage + return readConsentState().then(writeConsentToNative).then(function (response) { + // mark in local storage + storageSet(DATA_COLLECTION_CONSENTED_PROTOCOL, + _req_consent); + // mark in local variable as well + //TODO - make a copy here + _curr_consented = _req_consent; + //TODO - find out how this is used and how to replace + //emit(startPrefs.CONSENTED_EVENT, _req_consent); + }); +}; + +//used in several places - storedevice, pushnotify -- onboardingHelper has other style... +let _intro_done = null; +let _is_intro_done; +export function isIntroDone() { + if (_intro_done == null || _intro_done == "") { + logDebug("in isIntroDone, returning false"); + _is_intro_done = false; + return false; + } else { + logDebug("in isIntroDone, returning true"); + _is_intro_done = true; + return true; + } +} + +let _is_consented; +//used in onboardingHelper +export function isConsented() { + if (_curr_consented == null || _curr_consented == "" || + _curr_consented.approval_date != _req_consent.approval_date) { + console.log("Not consented in local storage, need to show consent"); + _is_consented = false; + return false; + } else { + console.log("Consented in local storage, no need to show consent"); + _is_consented = true; + return true; + } +} + +//used in onboardingHelper +export function readConsentState() { + // read consent state from the file and populate it + return fetch("json/startupConfig.json") + .then(response => response.json()) + .then(function (startupConfigResult) { + // let startupConfigJson = await startupConfigResult.json(); + console.log(startupConfigResult); + _req_consent = startupConfigResult.emSensorDataCollectionProtocol; + logInfo("required consent version = " + JSON.stringify(_req_consent)); + return storageGet(DATA_COLLECTION_CONSENTED_PROTOCOL); + }).then(function (kv_store_consent) { + _curr_consented = kv_store_consent; + console.assert(((_req_consent != undefined) && (_req_consent != null)), "in readConsentState $rootScope.req_consent", JSON.stringify(_req_consent)); + // we can just launch this, we don't need to wait for it + checkNativeConsent(); + }); +} + +//used in ProfileSettings +export function getConsentDocument() { + return window['cordova'].plugins.BEMUserCache.getDocument("config/consent", false) + .then(function (resultDoc) { + if (window['cordova'].plugins.BEMUserCache.isEmptyDoc(resultDoc)) { + return null; + } else { + return resultDoc; + } + }); +}; + +function checkNativeConsent() { + getConsentDocument().then(function (resultDoc) { + if (resultDoc == null) { + if (isConsented()) { + logDebug("Local consent found, native consent missing, writing consent to native"); + displayErrorMsg("Local consent found, native consent missing, writing consent to native"); + return writeConsentToNative(); + } else { + logDebug("Both local and native consent not found, nothing to sync"); + } + } + }); +} From 416a111b05d3c749e47dd025d771514ef7bab029 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Tue, 17 Oct 2023 17:54:29 -0600 Subject: [PATCH 03/28] remove all references to angular service, replace with imports we are now not using the angular service anymore, so should access everything from the new ts file --- www/index.js | 1 - www/js/App.tsx | 2 -- www/js/control/ProfileSettings.jsx | 4 ++-- www/js/controllers.js | 8 ++++---- www/js/onboarding/ConsentPage.tsx | 5 ++--- www/js/onboarding/onboardingHelper.ts | 5 ++--- www/js/splash/localnotify.js | 1 - www/js/splash/pushnotify.js | 16 ++++++++-------- www/js/splash/remotenotify.js | 3 +-- www/js/splash/storedevicesettings.js | 16 ++++++++-------- 10 files changed, 27 insertions(+), 34 deletions(-) diff --git a/www/index.js b/www/index.js index 89c3a5e26..b4dd4da3d 100644 --- a/www/index.js +++ b/www/index.js @@ -6,7 +6,6 @@ import 'leaflet/dist/leaflet.css'; import './js/ngApp.js'; import './js/splash/referral.js'; import './js/splash/customURL.js'; -import './js/splash/startprefs.js'; import './js/splash/pushnotify.js'; import './js/splash/storedevicesettings.js'; import './js/splash/localnotify.js'; diff --git a/www/js/App.tsx b/www/js/App.tsx index 2187118fa..b3d823b5b 100644 --- a/www/js/App.tsx +++ b/www/js/App.tsx @@ -31,8 +31,6 @@ const App = () => { const { colors } = useTheme(); const { t } = useTranslation(); - const StartPrefs = getAngularService('StartPrefs'); - const routes = useMemo(() => { const showMetrics = appConfig?.survey_info?.['trip-labels'] == 'MULTILABEL'; return showMetrics ? defaultRoutes(t) : defaultRoutes(t).filter(r => r.key != 'metrics'); diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 4a263acc5..ceebe586c 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -24,6 +24,7 @@ import { AppContext } from "../App"; import { shareQR } from "../components/QrCode"; import { storageClear } from "../plugin/storage"; import { getAppVersion } from "../plugin/clientStats"; +import { getConsentDocument } from "../splash/startprefs"; //any pure functions can go outside const ProfileSettings = () => { @@ -39,7 +40,6 @@ const ProfileSettings = () => { const EmailHelper = getAngularService('EmailHelper'); const NotificationScheduler = getAngularService('NotificationScheduler'); const ControlHelper = getAngularService('ControlHelper'); - const StartPrefs = getAngularService('StartPrefs'); //functions that come directly from an Angular service const editCollectionConfig = () => setEditCollection(true); @@ -301,7 +301,7 @@ const ProfileSettings = () => { //in ProfileSettings in DevZone (above two functions are helpers) async function checkConsent() { - StartPrefs.getConsentDocument().then(function(resultDoc){ + getConsentDocument().then(function(resultDoc){ setConsentDoc(resultDoc); if (resultDoc == null) { setNoConsentVis(true); diff --git a/www/js/controllers.js b/www/js/controllers.js index 75124efce..5a4de0cb4 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -2,9 +2,9 @@ import angular from 'angular'; import { addStatError, addStatReading, statKeys } from './plugin/clientStats'; +import { getPendingOnboardingState } from './onboarding/onboardingHelper'; -angular.module('emission.controllers', ['emission.splash.startprefs', - 'emission.splash.pushnotify', +angular.module('emission.controllers', ['emission.splash.pushnotify', 'emission.splash.storedevicesettings', 'emission.splash.localnotify', 'emission.splash.remotenotify']) @@ -14,7 +14,7 @@ angular.module('emission.controllers', ['emission.splash.startprefs', .controller('DashCtrl', function($scope) {}) .controller('SplashCtrl', function($scope, $state, $interval, $rootScope, - StartPrefs, PushNotify, StoreDeviceSettings, + PushNotify, StoreDeviceSettings, LocalNotify, RemoteNotify) { console.log('SplashCtrl invoked'); // alert("attach debugger!"); @@ -49,7 +49,7 @@ angular.module('emission.controllers', ['emission.splash.startprefs', 'root.main.metrics'] if (isInList(toState.name, personalTabs)) { // toState is in the personalTabs list - StartPrefs.getPendingOnboardingState().then(function(result) { + getPendingOnboardingState().then(function(result) { if (result != null) { event.preventDefault(); $state.go(result); diff --git a/www/js/onboarding/ConsentPage.tsx b/www/js/onboarding/ConsentPage.tsx index 08aa3ab48..2a098b3a9 100644 --- a/www/js/onboarding/ConsentPage.tsx +++ b/www/js/onboarding/ConsentPage.tsx @@ -4,9 +4,9 @@ import { View, ScrollView } from 'react-native'; import { Button, Surface } from 'react-native-paper'; import { resetDataAndRefresh } from '../config/dynamicConfig'; import { AppContext } from '../App'; -import { getAngularService } from '../angular-react-helper'; import PrivacyPolicy from './PrivacyPolicy'; import { onboardingStyles } from './OnboardingStack'; +import { markConsented } from '../splash/startprefs'; const ConsentPage = () => { @@ -20,8 +20,7 @@ const ConsentPage = () => { }; function agree() { - const StartPrefs = getAngularService('StartPrefs'); - StartPrefs.markConsented().then((response) => { + markConsented().then((response) => { refreshOnboardingState(); }); }; diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index 40fb15155..78f5aa4d1 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -1,8 +1,8 @@ import { DateTime } from "luxon"; -import { getAngularService } from "../angular-react-helper"; import { getConfig, resetDataAndRefresh } from "../config/dynamicConfig"; import { storageGet, storageSet } from "../plugin/storage"; import { logDebug } from "../plugin/logger"; +import { readConsentState, isConsented, isIntroDone } from "../splash/startprefs"; export const INTRO_DONE_KEY = 'intro_done'; @@ -58,8 +58,7 @@ export function getPendingOnboardingState(): Promise { }; async function readConsented() { - const StartPrefs = getAngularService('StartPrefs'); - return StartPrefs.readConsentState().then(StartPrefs.isConsented) as Promise; + return readConsentState().then(isConsented) as Promise; } async function readIntroDone() { diff --git a/www/js/splash/localnotify.js b/www/js/splash/localnotify.js index 6a4241f2c..c96ba827d 100644 --- a/www/js/splash/localnotify.js +++ b/www/js/splash/localnotify.js @@ -8,7 +8,6 @@ import angular from 'angular'; angular.module('emission.splash.localnotify', ['emission.plugin.logger', - 'emission.splash.startprefs', 'ionic-toast']) .factory('LocalNotify', function($window, $ionicPlatform, $ionicPopup, $state, $rootScope, ionicToast, Logger) { diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index 40d859f09..874a539a5 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -15,12 +15,12 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; +import { readConsentState, isIntroDone, isConsented, startPrefs } from './startprefs'; angular.module('emission.splash.pushnotify', ['emission.plugin.logger', - 'emission.services', - 'emission.splash.startprefs']) + 'emission.services']) .factory('PushNotify', function($window, $state, $rootScope, $ionicPlatform, - $ionicPopup, Logger, StartPrefs) { + $ionicPopup, Logger) { var pushnotify = {}; var push = null; @@ -159,8 +159,8 @@ angular.module('emission.splash.pushnotify', ['emission.plugin.logger', $ionicPlatform.ready().then(function() { pushnotify.datacollect = $window.cordova.plugins.BEMDataCollection; - StartPrefs.readConsentState() - .then(StartPrefs.isConsented) + readConsentState() + .then(isConsented) .then(function(consentState) { if (consentState == true) { pushnotify.registerPush(); @@ -172,16 +172,16 @@ angular.module('emission.splash.pushnotify', ['emission.plugin.logger', Logger.log("pushnotify startup done"); }); - $rootScope.$on(StartPrefs.CONSENTED_EVENT, function(event, data) { + $rootScope.$on(startPrefs.CONSENTED_EVENT, function(event, data) { console.log("got consented event "+JSON.stringify(event.name) +" with data "+ JSON.stringify(data)); - if (StartPrefs.isIntroDone()) { + if (isIntroDone()) { console.log("intro is done -> reconsent situation, we already have a token -> register"); pushnotify.registerPush(); } }); - $rootScope.$on(StartPrefs.INTRO_DONE_EVENT, function(event, data) { + $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); pushnotify.registerPush(); }); diff --git a/www/js/splash/remotenotify.js b/www/js/splash/remotenotify.js index 3e43b6f9f..f08921fdd 100644 --- a/www/js/splash/remotenotify.js +++ b/www/js/splash/remotenotify.js @@ -15,8 +15,7 @@ import angular from 'angular'; import { addStatEvent, statKeys } from '../plugin/clientStats'; -angular.module('emission.splash.remotenotify', ['emission.plugin.logger', - 'emission.splash.startprefs']) +angular.module('emission.splash.remotenotify', ['emission.plugin.logger']) .factory('RemoteNotify', function($http, $window, $ionicPopup, $rootScope, Logger) { diff --git a/www/js/splash/storedevicesettings.js b/www/js/splash/storedevicesettings.js index d307feaa7..2b60fbee4 100644 --- a/www/js/splash/storedevicesettings.js +++ b/www/js/splash/storedevicesettings.js @@ -1,11 +1,11 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; +import { isConsented, readConsentState, startPrefs, isIntroDone } from "./startprefs"; angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', - 'emission.services', - 'emission.splash.startprefs']) + 'emission.services']) .factory('StoreDeviceSettings', function($window, $state, $rootScope, $ionicPlatform, - $ionicPopup, Logger, StartPrefs) { + $ionicPopup, Logger ) { var storedevicesettings = {}; @@ -32,8 +32,8 @@ angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', $ionicPlatform.ready().then(function() { storedevicesettings.datacollect = $window.cordova.plugins.BEMDataCollection; - StartPrefs.readConsentState() - .then(StartPrefs.isConsented) + readConsentState() + .then(isConsented) .then(function(consentState) { if (consentState == true) { storedevicesettings.storeDeviceSettings(); @@ -44,16 +44,16 @@ angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', Logger.log("storedevicesettings startup done"); }); - $rootScope.$on(StartPrefs.CONSENTED_EVENT, function(event, data) { + $rootScope.$on(startPrefs.CONSENTED_EVENT, function(event, data) { console.log("got consented event "+JSON.stringify(event.name) +" with data "+ JSON.stringify(data)); - if (StartPrefs.isIntroDone()) { + if (isIntroDone()) { console.log("intro is done -> reconsent situation, we already have a token -> register"); storedevicesettings.storeDeviceSettings(); } }); - $rootScope.$on(StartPrefs.INTRO_DONE_EVENT, function(event, data) { + $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); storedevicesettings.storeDeviceSettings(); }); From 0584278c258326cdadc17199fa40258030a20de8 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 18 Oct 2023 16:45:19 -0600 Subject: [PATCH 04/28] add a comment about the notifications we had a bug related to this call, so adding a note to future development to make sure we're aware of the ramifications that this can cause. --- www/js/splash/startprefs.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index d8c422568..a89b9aec8 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -23,6 +23,9 @@ let _req_consent; let _curr_consented; function writeConsentToNative() { + //note that this calls to the notification API, + //so should not be called until we have notification permissions + //see https://github.com/e-mission/e-mission-docs/issues/1006 return window['cordiva'].plugins.BEMDataCollection.markConsented(_req_consent); }; From 1d4752d58d65b189b3c0f944d0fd83736a8cbc51 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 18 Oct 2023 16:58:34 -0600 Subject: [PATCH 05/28] remove extra line --- www/js/splash/startprefs.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index a89b9aec8..3b0455c19 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -82,7 +82,6 @@ export function readConsentState() { return fetch("json/startupConfig.json") .then(response => response.json()) .then(function (startupConfigResult) { - // let startupConfigJson = await startupConfigResult.json(); console.log(startupConfigResult); _req_consent = startupConfigResult.emSensorDataCollectionProtocol; logInfo("required consent version = " + JSON.stringify(_req_consent)); From e0dc3bb0419aa3a8470db597ab444d3ba94f0847 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 18 Oct 2023 16:58:58 -0600 Subject: [PATCH 06/28] correct typo was breaking because I spelled cordova wrong --- www/js/splash/startprefs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 3b0455c19..0b8580e16 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -26,7 +26,7 @@ function writeConsentToNative() { //note that this calls to the notification API, //so should not be called until we have notification permissions //see https://github.com/e-mission/e-mission-docs/issues/1006 - return window['cordiva'].plugins.BEMDataCollection.markConsented(_req_consent); + return window['cordova'].plugins.BEMDataCollection.markConsented(_req_consent); }; //used in ConsentPage From 8a3320d84b59e14174d912b6501282360e5cad9e Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Thu, 19 Oct 2023 09:15:10 -0600 Subject: [PATCH 07/28] make a deep copy for storage --- www/js/splash/startprefs.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 0b8580e16..71490f499 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -39,8 +39,7 @@ export function markConsented() { storageSet(DATA_COLLECTION_CONSENTED_PROTOCOL, _req_consent); // mark in local variable as well - //TODO - make a copy here - _curr_consented = _req_consent; + _curr_consented = {..._req_consent}; //TODO - find out how this is used and how to replace //emit(startPrefs.CONSENTED_EVENT, _req_consent); }); From a26536c0d422d229e871da91bae3222220a9a9c5 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Thu, 19 Oct 2023 14:39:47 -0600 Subject: [PATCH 08/28] updating "keys" remove unused key, update to single source of truth for INTRO_DONE_KEY --- www/js/splash/startprefs.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 71490f499..a69a970ec 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -1,5 +1,6 @@ import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; +import { INTRO_DONE_KEY } from '../onboarding/onboardingHelper'; type StartPrefs = { CONSENTED_EVENT: string, @@ -10,15 +11,11 @@ export const startPrefs: StartPrefs = { CONSENTED_EVENT: "data_collection_consented", INTRO_DONE_EVENT: "intro_done", }; -// Boolean: represents that the "intro" - the one page summary -// and the login are done -const INTRO_DONE_KEY = 'intro_done'; + // data collection consented protocol: string, represents the date on // which the consented protocol was approved by the IRB const DATA_COLLECTION_CONSENTED_PROTOCOL = 'data_collection_consented_protocol'; -const CONSENTED_KEY = "config/consent"; - let _req_consent; let _curr_consented; From d8d1a3779a2fcf56c99a4d0c112a93a269948a93 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Thu, 19 Oct 2023 14:43:05 -0600 Subject: [PATCH 09/28] update event protocol Pre-migration, there was a "consent done" event broadcasted from startprefs whenever the user marked consent. However, Reach and typescript does not handle events like this. Instead, we are extracting the code into a function, retrieving it from the plugin (for now), and then calling those functions when consent is marked. As a part of this, unify the reading of "isIntroDone" to the method in onboardingHelper, rather than storing a variable in startPrefs --- www/js/onboarding/onboardingHelper.ts | 4 ++-- www/js/splash/pushnotify.js | 17 ++++++++++------- www/js/splash/startprefs.ts | 24 +++++++----------------- www/js/splash/storedevicesettings.js | 14 ++++++++------ 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index 78f5aa4d1..daec90cb1 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -2,7 +2,7 @@ import { DateTime } from "luxon"; import { getConfig, resetDataAndRefresh } from "../config/dynamicConfig"; import { storageGet, storageSet } from "../plugin/storage"; import { logDebug } from "../plugin/logger"; -import { readConsentState, isConsented, isIntroDone } from "../splash/startprefs"; +import { readConsentState, isConsented } from "../splash/startprefs"; export const INTRO_DONE_KEY = 'intro_done'; @@ -61,7 +61,7 @@ async function readConsented() { return readConsentState().then(isConsented) as Promise; } -async function readIntroDone() { +export async function readIntroDone() { return storageGet(INTRO_DONE_KEY).then((read_val) => !!read_val) as Promise; } diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index 874a539a5..0a5f9f18e 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -15,7 +15,8 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; -import { readConsentState, isIntroDone, isConsented, startPrefs } from './startprefs'; +import { readConsentState, isConsented, startPrefs } from './startprefs'; +import { readIntroDone } from '../onboarding/onboardingHelper'; angular.module('emission.splash.pushnotify', ['emission.plugin.logger', 'emission.services']) @@ -172,14 +173,16 @@ angular.module('emission.splash.pushnotify', ['emission.plugin.logger', Logger.log("pushnotify startup done"); }); - $rootScope.$on(startPrefs.CONSENTED_EVENT, function(event, data) { - console.log("got consented event "+JSON.stringify(event.name) - +" with data "+ JSON.stringify(data)); - if (isIntroDone()) { + //new way of handling this, called in startprefs by markConsent + pushnotify.afterConsent = function () { + console.log("in pushnotify, executing after consent is received"); + readIntroDone().then((intro_done) => { + if (intro_done) { console.log("intro is done -> reconsent situation, we already have a token -> register"); pushnotify.registerPush(); - } - }); + } + }) + } $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index a69a970ec..5bcfac39a 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -1,6 +1,7 @@ import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; import { INTRO_DONE_KEY } from '../onboarding/onboardingHelper'; +import { getAngularService } from "../angular-react-helper"; type StartPrefs = { CONSENTED_EVENT: string, @@ -37,26 +38,15 @@ export function markConsented() { _req_consent); // mark in local variable as well _curr_consented = {..._req_consent}; - //TODO - find out how this is used and how to replace - //emit(startPrefs.CONSENTED_EVENT, _req_consent); + + //handle consent in other plugins - previously used $emit + const PushNotify = getAngularService("PushNotify"); + PushNotify.afterConsent(); + const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); + StoreSeviceSettings.afterConsent(); }); }; -//used in several places - storedevice, pushnotify -- onboardingHelper has other style... -let _intro_done = null; -let _is_intro_done; -export function isIntroDone() { - if (_intro_done == null || _intro_done == "") { - logDebug("in isIntroDone, returning false"); - _is_intro_done = false; - return false; - } else { - logDebug("in isIntroDone, returning true"); - _is_intro_done = true; - return true; - } -} - let _is_consented; //used in onboardingHelper export function isConsented() { diff --git a/www/js/splash/storedevicesettings.js b/www/js/splash/storedevicesettings.js index 2b60fbee4..f9ff0e00c 100644 --- a/www/js/splash/storedevicesettings.js +++ b/www/js/splash/storedevicesettings.js @@ -1,6 +1,7 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; -import { isConsented, readConsentState, startPrefs, isIntroDone } from "./startprefs"; +import { isConsented, readConsentState, startPrefs } from "./startprefs"; +import { readIntroDone } from '../onboarding/onboardingHelper'; angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', 'emission.services']) @@ -44,14 +45,15 @@ angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', Logger.log("storedevicesettings startup done"); }); - $rootScope.$on(startPrefs.CONSENTED_EVENT, function(event, data) { - console.log("got consented event "+JSON.stringify(event.name) - +" with data "+ JSON.stringify(data)); - if (isIntroDone()) { + storedevicesettings.afterConsent = function() { + console.log("in storedevicesettings, executing after consent is received"); + readIntroDone().then((intro_done) => { + if (intro_done) { console.log("intro is done -> reconsent situation, we already have a token -> register"); storedevicesettings.storeDeviceSettings(); } - }); + }) + } $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); From 8a99ba93f74345b97942983a4dd27b178fa7ee9c Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Thu, 19 Oct 2023 15:23:18 -0600 Subject: [PATCH 10/28] move plugin calls we actually need to wait until fully consented, and the user registered before we can take the actions in the plugins I noticed this because of an error message that appeared when logging in, indicating that the user was not registered, so the device settings could not be stored moving these calls to after the user has FULLY consented, resolved that issue --- www/js/onboarding/SaveQrPage.tsx | 7 +++++++ www/js/splash/startprefs.ts | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/www/js/onboarding/SaveQrPage.tsx b/www/js/onboarding/SaveQrPage.tsx index 406376cfa..387ee4dc3 100644 --- a/www/js/onboarding/SaveQrPage.tsx +++ b/www/js/onboarding/SaveQrPage.tsx @@ -28,6 +28,13 @@ const SaveQrPage = ({ }) => { setRegisterUserDone(true); preloadDemoSurveyResponse(); refreshOnboardingState(); + + //fully consented, so can handle other aspects + //other plugins - previously used $emit + const PushNotify = getAngularService("PushNotify"); + PushNotify.afterConsent(); + const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); + StoreSeviceSettings.afterConsent(); }); } else { logDebug('permissions not done, waiting'); diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 5bcfac39a..cb48b9769 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -38,12 +38,6 @@ export function markConsented() { _req_consent); // mark in local variable as well _curr_consented = {..._req_consent}; - - //handle consent in other plugins - previously used $emit - const PushNotify = getAngularService("PushNotify"); - PushNotify.afterConsent(); - const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); - StoreSeviceSettings.afterConsent(); }); }; From 1edfc8c70c058a2e6ca64a367681ddfb2dc33115 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Thu, 19 Oct 2023 15:56:32 -0600 Subject: [PATCH 11/28] add docstrings for functions adding descriptions to the functions, and removed some unused imports --- www/js/splash/startprefs.ts | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index cb48b9769..f8626b9e8 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -1,7 +1,5 @@ import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; -import { INTRO_DONE_KEY } from '../onboarding/onboardingHelper'; -import { getAngularService } from "../angular-react-helper"; type StartPrefs = { CONSENTED_EVENT: string, @@ -20,6 +18,10 @@ const DATA_COLLECTION_CONSENTED_PROTOCOL = 'data_collection_consented_protocol'; let _req_consent; let _curr_consented; +/** + * @function writes the consent document to native storage + * @returns Promise to execute the write to storage +*/ function writeConsentToNative() { //note that this calls to the notification API, //so should not be called until we have notification permissions @@ -27,7 +29,10 @@ function writeConsentToNative() { return window['cordova'].plugins.BEMDataCollection.markConsented(_req_consent); }; -//used in ConsentPage +/** + * @function marks consent in native storage, local storage, and local var + * @returns Promise for marking the consent in native and local storage + */ export function markConsented() { logInfo("changing consent from " + _curr_consented + " -> " + JSON.stringify(_req_consent)); @@ -42,7 +47,11 @@ export function markConsented() { }; let _is_consented; -//used in onboardingHelper + +/** + * @function checking for consent locally + * @returns {boolean} if the consent is marked in the local var + */ export function isConsented() { if (_curr_consented == null || _curr_consented == "" || _curr_consented.approval_date != _req_consent.approval_date) { @@ -56,9 +65,11 @@ export function isConsented() { } } -//used in onboardingHelper +/** + * @function reads the consent state from the file and populates it + * @returns Promise for the stored consent file + */ export function readConsentState() { - // read consent state from the file and populate it return fetch("json/startupConfig.json") .then(response => response.json()) .then(function (startupConfigResult) { @@ -74,6 +85,10 @@ export function readConsentState() { }); } +/** + * @function gets the consent document from storage + * @returns Promise for the consent document or null if the doc is empty + */ //used in ProfileSettings export function getConsentDocument() { return window['cordova'].plugins.BEMUserCache.getDocument("config/consent", false) @@ -86,6 +101,10 @@ export function getConsentDocument() { }); }; +/** + * @function checks the consent doc in native storage + * @returns if doc not stored in native, a promise to write it there + */ function checkNativeConsent() { getConsentDocument().then(function (resultDoc) { if (resultDoc == null) { From d4a29b1f1e8b23d67b00af39eb2708867c8d661a Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 20 Oct 2023 10:16:02 -0600 Subject: [PATCH 12/28] first test for startprefs after adding more mocked functions, the startprefs now have one test, for getting the consent doc from storage --- www/__mocks__/cordovaMocks.ts | 20 ++++++++++++++++ www/__tests__/startprefs.test.ts | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 www/__tests__/startprefs.test.ts diff --git a/www/__mocks__/cordovaMocks.ts b/www/__mocks__/cordovaMocks.ts index 4a9189ecd..424d4f424 100644 --- a/www/__mocks__/cordovaMocks.ts +++ b/www/__mocks__/cordovaMocks.ts @@ -87,6 +87,26 @@ export const mockBEMUserCache = () => { rs(messages.filter(m => m.key == key).map(m => m.value)); }, 100) ); + }, + getDocument: (key: string, withMetadata?: boolean) => { + return new Promise((rs, rj) => + setTimeout(() => { + rs(_cache[key]); + }, 100) + ); + }, + markConsented: (consentDoc) => { + _cache['config/consent'] = consentDoc; + }, + isEmptyDoc: (doc) => { + console.log(doc); + if (doc == undefined) { return true } + let string = doc.toString(); + if (string.length == 0) { + return true; + } else { + return false; + } } } window['cordova'] ||= {}; diff --git a/www/__tests__/startprefs.test.ts b/www/__tests__/startprefs.test.ts new file mode 100644 index 000000000..765637dc2 --- /dev/null +++ b/www/__tests__/startprefs.test.ts @@ -0,0 +1,39 @@ +import { markConsented, isConsented, readConsentState, getConsentDocument } from '../js/splash/startprefs'; + +import { mockBEMUserCache } from "../__mocks__/cordovaMocks"; +import { mockLogger } from "../__mocks__/globalMocks"; + +mockBEMUserCache(); +mockLogger(); + +global.fetch = (url: string) => new Promise((rs, rj) => { + setTimeout(() => rs({ + json: () => new Promise((rs, rj) => { + let jsonString = '{ "emSensorDataCollectionProtocol": { "protocol_id": "2014-04-6267", "approval_date": "2016-07-14" } }'; + setTimeout(() => rs(jsonString), 100); + }) + })); +}) as any; + +it('marks consent in local and native storage', async () => { + +}); + +it('checks local vars for consent, returns boolean', async () => { + +}); + +it('reads the required and current consent', async () => { + //gets the info from the json file + //then sets the local req_consent variable + //then storageGets the data_collection_consented_protocol + //then uses that to store in local curr_consent var + //and launches checkNativeConsent + //let consentFile = await readConsentState(); + //expect(consentFile).toBeUndefined(); +}); + +it('gets the consent document from storage', async () => { + let consentDoc = await getConsentDocument(); + expect(consentDoc).toBeNull(); +}); \ No newline at end of file From 40f6b93a7ca29b99383dcde84f977120f1a9e714 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 20 Oct 2023 10:49:23 -0600 Subject: [PATCH 13/28] test markConsented this test needed a mock of markConsented in the BEMDataCollection plugin, I have added _storage so that when the document is written in, it can also be retrieved -- even though that happens in two different plugins --- www/__mocks__/cordovaMocks.ts | 19 ++++++++++++++----- www/__tests__/startprefs.test.ts | 16 +++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/www/__mocks__/cordovaMocks.ts b/www/__mocks__/cordovaMocks.ts index 424d4f424..3e66cb163 100644 --- a/www/__mocks__/cordovaMocks.ts +++ b/www/__mocks__/cordovaMocks.ts @@ -24,6 +24,9 @@ export const mockGetAppVersion = () => { window['cordova'].getAppVersion = mockGetAppVersion; } +//for consent document +const _storage = {}; + export const mockBEMUserCache = () => { const _cache = {}; const messages = []; @@ -91,15 +94,11 @@ export const mockBEMUserCache = () => { getDocument: (key: string, withMetadata?: boolean) => { return new Promise((rs, rj) => setTimeout(() => { - rs(_cache[key]); + rs(_storage[key]); }, 100) ); }, - markConsented: (consentDoc) => { - _cache['config/consent'] = consentDoc; - }, isEmptyDoc: (doc) => { - console.log(doc); if (doc == undefined) { return true } let string = doc.toString(); if (string.length == 0) { @@ -113,3 +112,13 @@ export const mockBEMUserCache = () => { window['cordova'].plugins ||= {}; window['cordova'].plugins.BEMUserCache = mockBEMUserCache; } + +export const mockBEMDataCollection = () => { + const mockBEMDataCollection = { + markConsented: (consentDoc) => { + _storage['config/consent'] = consentDoc; + } + } + window['cordova'] ||= {}; + window['cordova'].plugins.BEMDataCollection = mockBEMDataCollection; +} diff --git a/www/__tests__/startprefs.test.ts b/www/__tests__/startprefs.test.ts index 765637dc2..994cfb284 100644 --- a/www/__tests__/startprefs.test.ts +++ b/www/__tests__/startprefs.test.ts @@ -1,9 +1,10 @@ import { markConsented, isConsented, readConsentState, getConsentDocument } from '../js/splash/startprefs'; -import { mockBEMUserCache } from "../__mocks__/cordovaMocks"; +import { mockBEMUserCache, mockBEMDataCollection } from "../__mocks__/cordovaMocks"; import { mockLogger } from "../__mocks__/globalMocks"; mockBEMUserCache(); +mockBEMDataCollection(); mockLogger(); global.fetch = (url: string) => new Promise((rs, rj) => { @@ -16,11 +17,12 @@ global.fetch = (url: string) => new Promise((rs, rj) => { }) as any; it('marks consent in local and native storage', async () => { - + let marked = markConsented(); + console.log("marked is", marked); }); it('checks local vars for consent, returns boolean', async () => { - + expect(isConsented()).toBeFalsy(); }); it('reads the required and current consent', async () => { @@ -29,11 +31,11 @@ it('reads the required and current consent', async () => { //then storageGets the data_collection_consented_protocol //then uses that to store in local curr_consent var //and launches checkNativeConsent - //let consentFile = await readConsentState(); - //expect(consentFile).toBeUndefined(); + // let consentFile = await readConsentState(); + expect(await readConsentState()).toBeUndefined(); }); it('gets the consent document from storage', async () => { - let consentDoc = await getConsentDocument(); - expect(consentDoc).toBeNull(); +// let consentDoc = await getConsentDocument(); + expect(await getConsentDocument()).toBeNull(); }); \ No newline at end of file From 9849fa21530c5f13ce6042e1776f7b27c23daaca Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 20 Oct 2023 12:09:16 -0600 Subject: [PATCH 14/28] test all functions in sequence since testing separately affects the local storage, testing in sequence allows for easier testing. return json from fetch rather than string to make it parseable in storage, had to check for the string undefined, since that was returned in one of the tests --- www/__tests__/startprefs.test.ts | 31 +++++++------------------------ www/js/plugin/storage.ts | 2 +- www/js/splash/startprefs.ts | 3 ++- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/www/__tests__/startprefs.test.ts b/www/__tests__/startprefs.test.ts index 994cfb284..1e62e7b5e 100644 --- a/www/__tests__/startprefs.test.ts +++ b/www/__tests__/startprefs.test.ts @@ -10,32 +10,15 @@ mockLogger(); global.fetch = (url: string) => new Promise((rs, rj) => { setTimeout(() => rs({ json: () => new Promise((rs, rj) => { - let jsonString = '{ "emSensorDataCollectionProtocol": { "protocol_id": "2014-04-6267", "approval_date": "2016-07-14" } }'; - setTimeout(() => rs(jsonString), 100); + let myJSON = { "emSensorDataCollectionProtocol": { "protocol_id": "2014-04-6267", "approval_date": "2016-07-14" } }; + setTimeout(() => rs(myJSON), 100); }) })); }) as any; -it('marks consent in local and native storage', async () => { - let marked = markConsented(); - console.log("marked is", marked); -}); - -it('checks local vars for consent, returns boolean', async () => { - expect(isConsented()).toBeFalsy(); -}); - -it('reads the required and current consent', async () => { - //gets the info from the json file - //then sets the local req_consent variable - //then storageGets the data_collection_consented_protocol - //then uses that to store in local curr_consent var - //and launches checkNativeConsent - // let consentFile = await readConsentState(); - expect(await readConsentState()).toBeUndefined(); -}); - -it('gets the consent document from storage', async () => { -// let consentDoc = await getConsentDocument(); - expect(await getConsentDocument()).toBeNull(); +it('checks state of consent before and after marking consent', async () => { + expect(await readConsentState().then(isConsented)).toBeFalsy(); + let marked = await markConsented(); + expect(await readConsentState().then(isConsented)).toBeTruthy(); + expect(await getConsentDocument()).toEqual({"approval_date": "2016-07-14", "protocol_id": "2014-04-6267"}); }); \ No newline at end of file diff --git a/www/js/plugin/storage.ts b/www/js/plugin/storage.ts index 59e535b6e..e649d504d 100644 --- a/www/js/plugin/storage.ts +++ b/www/js/plugin/storage.ts @@ -30,7 +30,7 @@ const localStorageSet = (key: string, value: {[k: string]: any}) => { const localStorageGet = (key: string) => { const value = localStorage.getItem(key); - if (value) { + if (value && value != "undefined") { return JSON.parse(value); } else { return null; diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index f8626b9e8..2acda39b1 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -53,6 +53,7 @@ let _is_consented; * @returns {boolean} if the consent is marked in the local var */ export function isConsented() { + console.log("curr consented is", _curr_consented); if (_curr_consented == null || _curr_consented == "" || _curr_consented.approval_date != _req_consent.approval_date) { console.log("Not consented in local storage, need to show consent"); @@ -67,7 +68,7 @@ export function isConsented() { /** * @function reads the consent state from the file and populates it - * @returns Promise for the stored consent file + * @returns nothing, just reads into local variables */ export function readConsentState() { return fetch("json/startupConfig.json") From 8ab5bf1099c40a3fd6d09715350dc595bac3c782 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 20 Oct 2023 13:56:58 -0600 Subject: [PATCH 15/28] add timeout for consistency, since this is also a function that is async --- www/__mocks__/cordovaMocks.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/__mocks__/cordovaMocks.ts b/www/__mocks__/cordovaMocks.ts index 3e66cb163..2ac50e229 100644 --- a/www/__mocks__/cordovaMocks.ts +++ b/www/__mocks__/cordovaMocks.ts @@ -116,7 +116,9 @@ export const mockBEMUserCache = () => { export const mockBEMDataCollection = () => { const mockBEMDataCollection = { markConsented: (consentDoc) => { - _storage['config/consent'] = consentDoc; + setTimeout(() => { + _storage['config/consent'] = consentDoc; + }, 100) } } window['cordova'] ||= {}; From 60caee5ab2a7a598110e79ef2f294d7e66868b8c Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Mon, 23 Oct 2023 09:06:47 -0600 Subject: [PATCH 16/28] remove "protocol id" since we no longer work with the IRB protocol within the app, we don't need to present it to the user --- www/i18n/en.json | 2 +- www/js/control/ProfileSettings.jsx | 2 +- www/json/startupConfig.json | 1 - www/json/startupConfig.json.sample | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/www/i18n/en.json b/www/i18n/en.json index 9217339f7..ed4ea2d2e 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -66,7 +66,7 @@ "consent-not-found": "Consent for data collection not found, consent now?", "no-consent-message": "OK! Note that you won't get any personalized stats until you do!", "consent-found": "Consent found!", - "consented-to": "Consented to protocol {{protocol_id}}, {{approval_date}}", + "consented-to": "Consented on {{approval_date}}", "consented-ok": "OK", "qrcode": "My OPcode", "qrcode-share-title": "You can save your OPcode to login easily in the future!" diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index de5469519..32e4c2a8d 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -496,7 +496,7 @@ const ProfileSettings = () => { setConsentVis(false)} style={settingStyles.dialog(colors.elevation.level3)}> - {t('general-settings.consented-to', {protocol_id: consentDoc.protocol_id, approval_date: consentDoc.approval_date})} + {t('general-settings.consented-to', {approval_date: consentDoc.approval_date})} - From 313074123bf6c9e5b0470ef210eece70ebd97c41 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 25 Oct 2023 15:42:06 -0600 Subject: [PATCH 18/28] remove unneeded type declaration https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1372324523 --- www/js/splash/startprefs.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 2acda39b1..d085289ff 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -1,12 +1,7 @@ import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; -type StartPrefs = { - CONSENTED_EVENT: string, - INTRO_DONE_EVENT: string, -} - -export const startPrefs: StartPrefs = { +export const startPrefs = { CONSENTED_EVENT: "data_collection_consented", INTRO_DONE_EVENT: "intro_done", }; From 39aa2f254c7d3e6b928887ee9ed9e47e5aea88ff Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 25 Oct 2023 16:32:57 -0600 Subject: [PATCH 19/28] move "after consent" saveQR was a bad place to handle this, moving to markConsented As Jack pointed out, on a reconsent (mark consent after intro done) we want to call registerPush and storeDeviceSettings - that is what is done here centralizing the logic to markConsented eliminated the need for the functions in the other files, since we check for consent done just once --- www/js/onboarding/SaveQrPage.tsx | 7 ------- www/js/splash/pushnotify.js | 11 ----------- www/js/splash/startprefs.ts | 29 +++++++++++++++++++++------- www/js/splash/storedevicesettings.js | 10 ---------- 4 files changed, 22 insertions(+), 35 deletions(-) diff --git a/www/js/onboarding/SaveQrPage.tsx b/www/js/onboarding/SaveQrPage.tsx index 3c5c0b954..3bfc93bb4 100644 --- a/www/js/onboarding/SaveQrPage.tsx +++ b/www/js/onboarding/SaveQrPage.tsx @@ -31,13 +31,6 @@ const SaveQrPage = ({ }) => { setRegisterUserDone(true); preloadDemoSurveyResponse(); refreshOnboardingState(); - - //fully consented, so can handle other aspects - //other plugins - previously used $emit - const PushNotify = getAngularService("PushNotify"); - PushNotify.afterConsent(); - const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); - StoreSeviceSettings.afterConsent(); }) ); } else { diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index 0a5f9f18e..06bf433f8 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -173,17 +173,6 @@ angular.module('emission.splash.pushnotify', ['emission.plugin.logger', Logger.log("pushnotify startup done"); }); - //new way of handling this, called in startprefs by markConsent - pushnotify.afterConsent = function () { - console.log("in pushnotify, executing after consent is received"); - readIntroDone().then((intro_done) => { - if (intro_done) { - console.log("intro is done -> reconsent situation, we already have a token -> register"); - pushnotify.registerPush(); - } - }) - } - $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); pushnotify.registerPush(); diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index d085289ff..ec3bd9a14 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -1,5 +1,7 @@ +import { getAngularService } from "../angular-react-helper"; import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; +import { readIntroDone } from "../onboarding/onboardingHelper"; export const startPrefs = { CONSENTED_EVENT: "data_collection_consented", @@ -32,13 +34,26 @@ export function markConsented() { logInfo("changing consent from " + _curr_consented + " -> " + JSON.stringify(_req_consent)); // mark in native storage - return readConsentState().then(writeConsentToNative).then(function (response) { - // mark in local storage - storageSet(DATA_COLLECTION_CONSENTED_PROTOCOL, - _req_consent); - // mark in local variable as well - _curr_consented = {..._req_consent}; - }); + return readConsentState() + .then(writeConsentToNative) + .then(function (response) { + // mark in local storage + storageSet(DATA_COLLECTION_CONSENTED_PROTOCOL, + _req_consent); + // mark in local variable as well + _curr_consented = { ..._req_consent }; + }) + //check for reconsent + .then(readIntroDone) + .then((isIntroDone) => { + if(isIntroDone) { + console.debug("reconsent scenario - marked consent after intro done - registering pushnoify and storing device settings") + const PushNotify = getAngularService("PushNotify"); + const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); + PushNotify.registerPush(); + StoreSeviceSettings.storeDeviceSettings(); + } + }); }; let _is_consented; diff --git a/www/js/splash/storedevicesettings.js b/www/js/splash/storedevicesettings.js index f9ff0e00c..a53f7b76e 100644 --- a/www/js/splash/storedevicesettings.js +++ b/www/js/splash/storedevicesettings.js @@ -45,16 +45,6 @@ angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', Logger.log("storedevicesettings startup done"); }); - storedevicesettings.afterConsent = function() { - console.log("in storedevicesettings, executing after consent is received"); - readIntroDone().then((intro_done) => { - if (intro_done) { - console.log("intro is done -> reconsent situation, we already have a token -> register"); - storedevicesettings.storeDeviceSettings(); - } - }) - } - $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { console.log("intro is done -> original consent situation, we should have a token by now -> register"); storedevicesettings.storeDeviceSettings(); From 657ae34b1c65cb7ae204b81038bb11ea2056cfe0 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 25 Oct 2023 16:37:40 -0600 Subject: [PATCH 20/28] rework "intro done event" We no longer emit this event, but still need to handle the logic On marking intro done, we will registerPush and storeDeviceSettings https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1372339180 --- www/js/onboarding/onboardingHelper.ts | 11 ++++++++++- www/js/splash/pushnotify.js | 5 ----- www/js/splash/storedevicesettings.js | 5 ----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index 9bca0fdd5..b73810ee5 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -3,6 +3,7 @@ import { getConfig, resetDataAndRefresh } from "../config/dynamicConfig"; import { storageGet, storageSet } from "../plugin/storage"; import { logDebug } from "../plugin/logger"; import { readConsentState, isConsented } from "../splash/startprefs"; +import { getAngularService } from "../angular-react-helper"; export const INTRO_DONE_KEY = 'intro_done'; @@ -70,5 +71,13 @@ export async function readIntroDone() { export async function markIntroDone() { const currDateTime = DateTime.now().toISO(); - return storageSet(INTRO_DONE_KEY, currDateTime); + return storageSet(INTRO_DONE_KEY, currDateTime) + .then(() => { + //handle "on intro" events + console.log("intro done, calling registerPush and storeDeviceSettings"); + const PushNotify = getAngularService("PushNotify"); + const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); + PushNotify.registerPush(); + StoreSeviceSettings.storeDeviceSettings(); + }); } diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index 06bf433f8..dd31811ab 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -173,10 +173,5 @@ angular.module('emission.splash.pushnotify', ['emission.plugin.logger', Logger.log("pushnotify startup done"); }); - $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { - console.log("intro is done -> original consent situation, we should have a token by now -> register"); - pushnotify.registerPush(); - }); - return pushnotify; }); diff --git a/www/js/splash/storedevicesettings.js b/www/js/splash/storedevicesettings.js index a53f7b76e..c32083295 100644 --- a/www/js/splash/storedevicesettings.js +++ b/www/js/splash/storedevicesettings.js @@ -45,10 +45,5 @@ angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', Logger.log("storedevicesettings startup done"); }); - $rootScope.$on(startPrefs.INTRO_DONE_EVENT, function(event, data) { - console.log("intro is done -> original consent situation, we should have a token by now -> register"); - storedevicesettings.storeDeviceSettings(); - }); - return storedevicesettings; }); From a7a75d1dde7f5621074a514b9ec9c0a71235e732 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 25 Oct 2023 16:38:06 -0600 Subject: [PATCH 21/28] remove unneeded object --- www/js/splash/startprefs.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index ec3bd9a14..277946629 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -3,11 +3,6 @@ import { storageGet, storageSet } from '../plugin/storage'; import { logInfo, logDebug, displayErrorMsg } from '../plugin/logger'; import { readIntroDone } from "../onboarding/onboardingHelper"; -export const startPrefs = { - CONSENTED_EVENT: "data_collection_consented", - INTRO_DONE_EVENT: "intro_done", -}; - // data collection consented protocol: string, represents the date on // which the consented protocol was approved by the IRB const DATA_COLLECTION_CONSENTED_PROTOCOL = 'data_collection_consented_protocol'; From c54f939f467ca43c3a2fc45796dd3bf5e2cc9f4b Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 27 Oct 2023 08:51:40 -0600 Subject: [PATCH 22/28] console.log -> logDebug There were several places where I had other log statements, but logDebug was more appropriate, see review for details https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1373749123 --- www/js/control/ProfileSettings.jsx | 3 ++- www/js/onboarding/onboardingHelper.ts | 2 +- www/js/splash/startprefs.ts | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 8c7510618..cecc4f84c 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -26,6 +26,7 @@ import { shareQR } from "../components/QrCode"; import { storageClear } from "../plugin/storage"; import { getAppVersion } from "../plugin/clientStats"; import { getConsentDocument } from "../splash/startprefs"; +import { logDebug } from "../plugin/logger"; //any pure functions can go outside const ProfileSettings = () => { @@ -309,7 +310,7 @@ const ProfileSettings = () => { async function checkConsent() { getConsentDocument().then(function(resultDoc){ setConsentDoc(resultDoc); - console.debug("In profile settings, consent doc found", resultDoc); + logDebug("In profile settings, consent doc found", resultDoc); if (resultDoc == null) { setNoConsentVis(true); } else { diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index b73810ee5..4110c2394 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -74,7 +74,7 @@ export async function markIntroDone() { return storageSet(INTRO_DONE_KEY, currDateTime) .then(() => { //handle "on intro" events - console.log("intro done, calling registerPush and storeDeviceSettings"); + logDebug("intro done, calling registerPush and storeDeviceSettings"); const PushNotify = getAngularService("PushNotify"); const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); PushNotify.registerPush(); diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 277946629..8a0b28415 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -42,7 +42,7 @@ export function markConsented() { .then(readIntroDone) .then((isIntroDone) => { if(isIntroDone) { - console.debug("reconsent scenario - marked consent after intro done - registering pushnoify and storing device settings") + logDebug("reconsent scenario - marked consent after intro done - registering pushnoify and storing device settings") const PushNotify = getAngularService("PushNotify"); const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); PushNotify.registerPush(); @@ -58,14 +58,14 @@ let _is_consented; * @returns {boolean} if the consent is marked in the local var */ export function isConsented() { - console.log("curr consented is", _curr_consented); + logDebug("curr consented is" + JSON.stringify(_curr_consented)); if (_curr_consented == null || _curr_consented == "" || _curr_consented.approval_date != _req_consent.approval_date) { - console.log("Not consented in local storage, need to show consent"); + logDebug("Not consented in local storage, need to show consent"); _is_consented = false; return false; } else { - console.log("Consented in local storage, no need to show consent"); + logDebug("Consented in local storage, no need to show consent"); _is_consented = true; return true; } @@ -81,7 +81,7 @@ export function readConsentState() { .then(function (startupConfigResult) { console.log(startupConfigResult); _req_consent = startupConfigResult.emSensorDataCollectionProtocol; - logInfo("required consent version = " + JSON.stringify(_req_consent)); + logDebug("required consent version = " + JSON.stringify(_req_consent)); return storageGet(DATA_COLLECTION_CONSENTED_PROTOCOL); }).then(function (kv_store_consent) { _curr_consented = kv_store_consent; From 2516b2dfea0acb264f1946b3251ef4198a4282e8 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 27 Oct 2023 08:55:53 -0600 Subject: [PATCH 23/28] _is_consented assigned but never used https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1373756101 --- www/js/splash/startprefs.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 8a0b28415..4feccdb4a 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -51,8 +51,6 @@ export function markConsented() { }); }; -let _is_consented; - /** * @function checking for consent locally * @returns {boolean} if the consent is marked in the local var @@ -62,11 +60,9 @@ export function isConsented() { if (_curr_consented == null || _curr_consented == "" || _curr_consented.approval_date != _req_consent.approval_date) { logDebug("Not consented in local storage, need to show consent"); - _is_consented = false; return false; } else { logDebug("Consented in local storage, no need to show consent"); - _is_consented = true; return true; } } From 8bbfb82bad6d1aee88a046e7f7c89c8c73a73af8 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 27 Oct 2023 09:53:36 -0600 Subject: [PATCH 24/28] add a catch block https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1373739450 --- www/js/splash/startprefs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/js/splash/startprefs.ts b/www/js/splash/startprefs.ts index 4feccdb4a..43f29c692 100644 --- a/www/js/splash/startprefs.ts +++ b/www/js/splash/startprefs.ts @@ -41,13 +41,16 @@ export function markConsented() { //check for reconsent .then(readIntroDone) .then((isIntroDone) => { - if(isIntroDone) { + if (isIntroDone) { logDebug("reconsent scenario - marked consent after intro done - registering pushnoify and storing device settings") const PushNotify = getAngularService("PushNotify"); const StoreSeviceSettings = getAngularService("StoreDeviceSettings"); PushNotify.registerPush(); StoreSeviceSettings.storeDeviceSettings(); } + }) + .catch((error) => { + displayErrorMsg(error, "Error while while wrting consent to storage"); }); }; From e19a346457af3d97c926b308ecc9133e7a289843 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Fri, 27 Oct 2023 12:28:08 -0600 Subject: [PATCH 25/28] less hacky undefined catch --- www/js/plugin/storage.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/js/plugin/storage.ts b/www/js/plugin/storage.ts index e649d504d..a8c503f0e 100644 --- a/www/js/plugin/storage.ts +++ b/www/js/plugin/storage.ts @@ -25,12 +25,14 @@ const unmungeValue = (key, retData) => { } const localStorageSet = (key: string, value: {[k: string]: any}) => { - localStorage.setItem(key, JSON.stringify(value)); + if (value) { + localStorage.setItem(key, JSON.stringify(value)); + } } const localStorageGet = (key: string) => { const value = localStorage.getItem(key); - if (value && value != "undefined") { + if (value) { return JSON.parse(value); } else { return null; From b2d6aa912f152515d791f136654b696acff125d1 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Mon, 30 Oct 2023 09:42:37 -0600 Subject: [PATCH 26/28] add comment and discussion link --- www/js/plugin/storage.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/js/plugin/storage.ts b/www/js/plugin/storage.ts index a8c503f0e..643e985e1 100644 --- a/www/js/plugin/storage.ts +++ b/www/js/plugin/storage.ts @@ -25,6 +25,9 @@ const unmungeValue = (key, retData) => { } const localStorageSet = (key: string, value: {[k: string]: any}) => { + //checking for a value to prevent storing undefined + //case where local was null and native was undefined stored "undefined" + //see discussion: https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1373753945 if (value) { localStorage.setItem(key, JSON.stringify(value)); } From fcbefb1b4a97605f62a602c309a6c3cea13328d4 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Mon, 30 Oct 2023 10:16:19 -0600 Subject: [PATCH 27/28] add comments about naming --- www/js/splash/pushnotify.js | 4 ++++ www/js/splash/remotenotify.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index dd31811ab..b107349fc 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -1,3 +1,7 @@ +//naming of this file can be a little confusing - "pushnotifysettings" for rewritten file +//https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1375360832 + + /* * This module deals with the interaction with the push plugin, the redirection * of silent push notifications and the re-parsing of iOS pushes. It then diff --git a/www/js/splash/remotenotify.js b/www/js/splash/remotenotify.js index f08921fdd..f67cb9d87 100644 --- a/www/js/splash/remotenotify.js +++ b/www/js/splash/remotenotify.js @@ -1,3 +1,6 @@ +//naming of this module can be confusing "remotenotifyhandler" for rewritten file +//https://github.com/e-mission/e-mission-phone/pull/1072#discussion_r1375360832 + /* * This module deals with handling specific push messages that open web pages * or popups. It does not interface with the push plugin directly. Instead, it From 3c23808bc45a836e056c30998e10fa08dbdbcf1d Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Mon, 30 Oct 2023 11:30:56 -0600 Subject: [PATCH 28/28] remove old imports --- www/js/splash/pushnotify.js | 3 +-- www/js/splash/storedevicesettings.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/www/js/splash/pushnotify.js b/www/js/splash/pushnotify.js index b107349fc..775ddc4bd 100644 --- a/www/js/splash/pushnotify.js +++ b/www/js/splash/pushnotify.js @@ -19,8 +19,7 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; -import { readConsentState, isConsented, startPrefs } from './startprefs'; -import { readIntroDone } from '../onboarding/onboardingHelper'; +import { readConsentState, isConsented } from './startprefs'; angular.module('emission.splash.pushnotify', ['emission.plugin.logger', 'emission.services']) diff --git a/www/js/splash/storedevicesettings.js b/www/js/splash/storedevicesettings.js index c32083295..31543bc6c 100644 --- a/www/js/splash/storedevicesettings.js +++ b/www/js/splash/storedevicesettings.js @@ -1,7 +1,6 @@ import angular from 'angular'; import { updateUser } from '../commHelper'; -import { isConsented, readConsentState, startPrefs } from "./startprefs"; -import { readIntroDone } from '../onboarding/onboardingHelper'; +import { isConsented, readConsentState } from "./startprefs"; angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger', 'emission.services'])