Skip to content

Commit

Permalink
fix(gtfs-filter): fix bug where feeds are not registered in API on fi…
Browse files Browse the repository at this point in the history
…rst call
  • Loading branch information
landonreed committed May 30, 2017
1 parent 4b7853a commit 255ac98
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/gtfs/actions/filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { secureFetch } from '../../common/actions'
import { getFeed } from '../../common/util/modules'
import {secureFetch} from '../../common/actions'
import {getFeed, getFeedId} from '../../common/util/modules'
import {getActiveProject} from '../../manager/selectors'

export function updatingGtfsFilter (activeProject, user) {
Expand Down Expand Up @@ -27,15 +27,13 @@ export function updateMapState (props) {
export function updateGtfsFilter (activeProject, user) {
return function (dispatch, getState) {
dispatch(updatingGtfsFilter(activeProject, user))

const projectFeeds = getActiveProject(getState()).feedSources
// check GTFS API for feed IDs present in cache
return dispatch(secureFetch('/api/manager/feeds'))
return dispatch(secureFetch(`/api/manager/feeds?id=${projectFeeds.map(f => getFeedId(f)).filter(n => n).join(',')}`))
.then(response => response.json())
.then((feedIds) => {
const activeFeeds = getActiveProject(getState()).feedSources

// filter out null values
const feeds = feedIds ? feedIds.map(id => getFeed(activeFeeds, id)).filter(n => n) : []
const feeds = feedIds ? feedIds.map(id => getFeed(projectFeeds, id)).filter(n => n) : []
dispatch(updateLoadedFeeds(feeds))
})
}
Expand Down

0 comments on commit 255ac98

Please sign in to comment.