@@ -22,17 +22,27 @@ const defaultConfig = {
22
22
routingTypes : [ ]
23
23
}
24
24
25
- // Load user override settings from local storage.
26
- // TODO: Make this work with settings fetched from user profile API service.
27
- const userOverrides = getItem ( 'defaultQuery' )
25
+ // Load user settings from local storage.
26
+ // TODO: Make this work with settings fetched from alternative storage system
27
+ // (e.g., OTP backend middleware containing user profile system).
28
+ // User overrides determine user's default mode/query parameters.
29
+ const userOverrides = getItem ( 'defaultQuery' , { } )
30
+ // Combine user overrides with default query to get default search settings.
28
31
const defaults = Object . assign ( getDefaultQuery ( ) , userOverrides )
29
- const autoRefresh = getItem ( 'autoRefresh' , true )
30
- const home = getItem ( 'home' , true )
31
- const work = getItem ( 'work' , true )
32
- const trackRecent = getItem ( 'trackRecent' , true ) || false
33
- const recentPlaces = getItem ( 'recent' , true ) || [ ]
34
- const favoriteStops = getItem ( 'favoriteStops' , true ) || [ ]
35
- const recentSearches = getItem ( 'recentSearches' , true ) || [ ]
32
+ // Whether to auto-refresh stop arrival times in the Stop Viewer.
33
+ const autoRefreshStopTimes = getItem ( 'autoRefreshStopTimes' , true )
34
+ // User's home and work locations
35
+ const home = getItem ( 'home' )
36
+ const work = getItem ( 'work' )
37
+ // Whether recent searches and places should be tracked in local storage.
38
+ const trackRecent = getItem ( 'trackRecent' , false )
39
+ // Recent places used in trip plan searches.
40
+ const recentPlaces = getItem ( 'recent' , [ ] )
41
+ // List of user's favorite stops.
42
+ const favoriteStops = getItem ( 'favoriteStops' , [ ] )
43
+ // Recent trip plan searches (excluding time/date parameters to avoid complexity).
44
+ const recentSearches = getItem ( 'recentSearches' , [ ] )
45
+ // Filter valid locations found into locations list.
36
46
const locations = [ home , work ] . filter ( p => p )
37
47
const MAX_RECENT_STORAGE = 5
38
48
// TODO: parse and merge URL query params w/ default query
@@ -76,7 +86,7 @@ function createOtpReducer (config, initialQuery) {
76
86
nearbyStops : [ ]
77
87
} ,
78
88
user : {
79
- autoRefresh ,
89
+ autoRefreshStopTimes ,
80
90
// Do not store from/to or date/time in defaults
81
91
defaults : getTripOptionsFromQuery ( defaults ) ,
82
92
favoriteStops,
@@ -605,8 +615,8 @@ function createOtpReducer (config, initialQuery) {
605
615
}
606
616
} )
607
617
case 'TOGGLE_AUTO_REFRESH' :
608
- storeItem ( 'autoRefresh ' , action . payload )
609
- return update ( state , { user : { autoRefresh : { $set : action . payload } } } )
618
+ storeItem ( 'autoRefreshStopTimes ' , action . payload )
619
+ return update ( state , { user : { autoRefreshStopTimes : { $set : action . payload } } } )
610
620
611
621
case 'FIND_ROUTES_RESPONSE' :
612
622
// If routes is undefined, initialize it w/ the full payload
0 commit comments