Skip to content

Commit 255ac98

Browse files
committed
fix(gtfs-filter): fix bug where feeds are not registered in API on first call
1 parent 4b7853a commit 255ac98

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/gtfs/actions/filter.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { secureFetch } from '../../common/actions'
2-
import { getFeed } from '../../common/util/modules'
1+
import {secureFetch} from '../../common/actions'
2+
import {getFeed, getFeedId} from '../../common/util/modules'
33
import {getActiveProject} from '../../manager/selectors'
44

55
export function updatingGtfsFilter (activeProject, user) {
@@ -27,15 +27,13 @@ export function updateMapState (props) {
2727
export function updateGtfsFilter (activeProject, user) {
2828
return function (dispatch, getState) {
2929
dispatch(updatingGtfsFilter(activeProject, user))
30-
30+
const projectFeeds = getActiveProject(getState()).feedSources
3131
// check GTFS API for feed IDs present in cache
32-
return dispatch(secureFetch('/api/manager/feeds'))
32+
return dispatch(secureFetch(`/api/manager/feeds?id=${projectFeeds.map(f => getFeedId(f)).filter(n => n).join(',')}`))
3333
.then(response => response.json())
3434
.then((feedIds) => {
35-
const activeFeeds = getActiveProject(getState()).feedSources
36-
3735
// filter out null values
38-
const feeds = feedIds ? feedIds.map(id => getFeed(activeFeeds, id)).filter(n => n) : []
36+
const feeds = feedIds ? feedIds.map(id => getFeed(projectFeeds, id)).filter(n => n) : []
3937
dispatch(updateLoadedFeeds(feeds))
4038
})
4139
}

0 commit comments

Comments
 (0)