@@ -11,12 +11,12 @@ export let storedConfig = null;
1111export let configChanged = false ;
1212export const setConfigChanged = ( b ) => ( configChanged = b ) ;
1313
14- //used test multiple configs, not used outside of test
15- export const resetStoredConfig = function ( ) {
14+ // used to test multiple configs, not used outside of test
15+ export const _test_resetStoredConfig = ( ) => {
1616 storedConfig = null ;
1717} ;
1818
19- const _getStudyName = function ( connectUrl ) {
19+ function _getStudyName ( connectUrl ) {
2020 const orig_host = new URL ( connectUrl ) . hostname ;
2121 const first_domain = orig_host . split ( '.' ) [ 0 ] ;
2222 if ( first_domain == 'openpath-stage' ) {
@@ -28,18 +28,18 @@ const _getStudyName = function (connectUrl) {
2828 }
2929 const study_name = first_domain . substr ( 0 , openpath_index ) ;
3030 return study_name ;
31- } ;
31+ }
3232
33- const _fillStudyName = ( config : Partial < AppConfig > ) : AppConfig => {
33+ function _fillStudyName ( config : Partial < AppConfig > ) : AppConfig {
3434 if ( config . name ) return config as AppConfig ;
3535 if ( config . server ) {
3636 return { ...config , name : _getStudyName ( config . server . connectUrl ) } as AppConfig ;
3737 } else {
3838 return { ...config , name : 'dev' } as AppConfig ;
3939 }
40- } ;
40+ }
4141
42- const _backwardsCompatSurveyFill = ( config : Partial < AppConfig > ) : AppConfig => {
42+ function _backwardsCompatSurveyFill ( config : Partial < AppConfig > ) : AppConfig {
4343 if ( config . survey_info ) return config as AppConfig ;
4444 return {
4545 ...config ,
@@ -59,13 +59,13 @@ const _backwardsCompatSurveyFill = (config: Partial<AppConfig>): AppConfig => {
5959 'trip-labels' : 'MULTILABEL' ,
6060 } ,
6161 } as AppConfig ;
62- } ;
62+ }
6363
6464/* Fetch and cache any surveys resources that are referenced by URL in the config,
6565 as well as the label_options config if it is present.
6666 This way they will be available when the user needs them, and we won't have to
6767 fetch them again unless local storage is cleared. */
68- const cacheResourcesFromConfig = ( config ) => {
68+ function cacheResourcesFromConfig ( config ) {
6969 if ( config . survey_info ?. surveys ) {
7070 Object . values ( config . survey_info . surveys ) . forEach ( ( survey ) => {
7171 if ( ! survey ?. [ 'formPath' ] ) throw new Error ( i18next . t ( 'config.survey-missing-formpath' ) ) ;
@@ -75,9 +75,9 @@ const cacheResourcesFromConfig = (config) => {
7575 if ( config . label_options ) {
7676 fetchUrlCached ( config . label_options ) ;
7777 }
78- } ;
78+ }
7979
80- const readConfigFromServer = async ( label ) => {
80+ async function readConfigFromServer ( label ) {
8181 const fetchedConfig = await fetchConfig ( label ) ;
8282 logDebug ( `Successfully found config,
8383 fetchedConfig = ${ JSON . stringify ( fetchedConfig ) . substring ( 0 , 10 ) } ` ) ;
@@ -94,9 +94,9 @@ const readConfigFromServer = async (label) => {
9494 deployment_name = ${ filledConfig . intro . translated_text . en . deployment_name } ;
9595 connectionURL = ${ fetchedConfig . server ? fetchedConfig . server . connectUrl : 'dev defaults' } ` ) ;
9696 return filledConfig ;
97- } ;
97+ }
9898
99- const fetchConfig = async ( label , alreadyTriedLocal = false ) => {
99+ async function fetchConfig ( label , alreadyTriedLocal = false ) {
100100 logDebug ( 'Received request to join ' + label ) ;
101101 const downloadURL = `https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/${ label } .nrel-op.json` ;
102102 if ( ! __DEV__ || alreadyTriedLocal ) {
@@ -115,7 +115,7 @@ const fetchConfig = async (label, alreadyTriedLocal = false) => {
115115 return fetchConfig ( label , true ) ;
116116 }
117117 }
118- } ;
118+ }
119119
120120/*
121121 * We want to support both old style and new style tokens.
0 commit comments