(state, subreddit)
| 33 | } |
| 34 | |
| 35 | const shouldFetchPosts = (state, subreddit) => { |
| 36 | const posts = state.postsBySubreddit[subreddit] |
| 37 | if (!posts) { |
| 38 | return true |
| 39 | } |
| 40 | if (posts.isFetching) { |
| 41 | return false |
| 42 | } |
| 43 | return posts.didInvalidate |
| 44 | } |
| 45 | |
| 46 | export const fetchPostsIfNeeded = subreddit => (dispatch, getState) => { |
| 47 | if (shouldFetchPosts(getState(), subreddit)) { |
no outgoing calls
no test coverage detected