Updated Gab Trends api, redux, panel

• Updated:
- Gab Trends api, redux, panel
- GabTrendsController takes in query string for feed type
This commit is contained in:
mgabdev
2020-06-08 22:10:51 -04:00
parent 24ad9b6ff4
commit 4a23c62ec8
4 changed files with 77 additions and 44 deletions

View File

@@ -5,34 +5,37 @@ export const GAB_TRENDS_RESULTS_FETCH_REQUEST = 'GAB_TRENDS_RESULTS_FETCH_REQUES
export const GAB_TRENDS_RESULTS_FETCH_SUCCESS = 'GAB_TRENDS_RESULTS_FETCH_SUCCESS'
export const GAB_TRENDS_RESULTS_FETCH_FAIL = 'GAB_TRENDS_RESULTS_FETCH_FAIL'
export const fetchGabTrends = () => {
export const fetchGabTrends = (feedType) => {
return function (dispatch, getState) {
dispatch(fetchGabTrendsRequest())
dispatch(fetchGabTrendsRequest(feedType))
api(getState).get('/api/v1/gab_trends').then(response => {
dispatch(fetchGabTrendsSuccess(response.data.items))
api(getState).get(`/api/v1/gab_trends?type=${feedType}`).then(response => {
dispatch(fetchGabTrendsSuccess(response.data.items, feedType))
}).catch(function (error) {
dispatch(fetchGabTrendsFail(error))
dispatch(fetchGabTrendsFail(error, feedType))
})
}
}
function fetchGabTrendsRequest() {
function fetchGabTrendsRequest(feedType) {
return {
type: GAB_TRENDS_RESULTS_FETCH_REQUEST,
feedType,
}
}
function fetchGabTrendsSuccess(items) {
function fetchGabTrendsSuccess(items, feedType) {
return {
type: GAB_TRENDS_RESULTS_FETCH_SUCCESS,
items,
feedType,
}
}
function fetchGabTrendsFail(error) {
function fetchGabTrendsFail(error, feedType) {
return {
type: GAB_TRENDS_RESULTS_FETCH_FAIL,
error,
feedType,
}
}