2020-09-10 23:21:39 +01:00
|
|
|
import api from '../api'
|
2020-07-09 01:36:50 +01:00
|
|
|
import axios from 'axios'
|
2020-04-04 00:18:26 +01:00
|
|
|
|
|
|
|
export const GAB_TRENDS_RESULTS_FETCH_REQUEST = 'GAB_TRENDS_RESULTS_FETCH_REQUEST'
|
|
|
|
export const GAB_TRENDS_RESULTS_FETCH_SUCCESS = 'GAB_TRENDS_RESULTS_FETCH_SUCCESS'
|
|
|
|
export const GAB_TRENDS_RESULTS_FETCH_FAIL = 'GAB_TRENDS_RESULTS_FETCH_FAIL'
|
|
|
|
|
2020-09-10 23:21:39 +01:00
|
|
|
export const GAB_NEWS_RESULTS_FETCH_REQUEST = 'GAB_NEWS_RESULTS_FETCH_REQUEST'
|
|
|
|
export const GAB_NEWS_RESULTS_FETCH_SUCCESS = 'GAB_NEWS_RESULTS_FETCH_SUCCESS'
|
|
|
|
export const GAB_NEWS_RESULTS_FETCH_FAIL = 'GAB_NEWS_RESULTS_FETCH_FAIL'
|
|
|
|
|
2020-06-09 03:10:51 +01:00
|
|
|
export const fetchGabTrends = (feedType) => {
|
2020-04-04 00:18:26 +01:00
|
|
|
return function (dispatch, getState) {
|
2020-06-09 03:10:51 +01:00
|
|
|
dispatch(fetchGabTrendsRequest(feedType))
|
2020-04-04 00:18:26 +01:00
|
|
|
|
2020-07-09 01:36:50 +01:00
|
|
|
const url = feedType === 'partner' ? 'https://trends.gab.com/partner' : 'https://trends.gab.com/trend-feed/json'
|
|
|
|
|
|
|
|
axios.get(url).then((response) => {
|
2020-07-02 03:39:43 +01:00
|
|
|
dispatch(fetchGabTrendsSuccess(response.data, feedType))
|
2020-04-04 00:18:26 +01:00
|
|
|
}).catch(function (error) {
|
2020-06-09 03:10:51 +01:00
|
|
|
dispatch(fetchGabTrendsFail(error, feedType))
|
2020-04-04 00:18:26 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:10:51 +01:00
|
|
|
function fetchGabTrendsRequest(feedType) {
|
2020-04-04 00:18:26 +01:00
|
|
|
return {
|
|
|
|
type: GAB_TRENDS_RESULTS_FETCH_REQUEST,
|
2020-06-09 03:10:51 +01:00
|
|
|
feedType,
|
2020-04-04 00:18:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:10:51 +01:00
|
|
|
function fetchGabTrendsSuccess(items, feedType) {
|
2020-04-04 00:18:26 +01:00
|
|
|
return {
|
|
|
|
type: GAB_TRENDS_RESULTS_FETCH_SUCCESS,
|
|
|
|
items,
|
2020-06-09 03:10:51 +01:00
|
|
|
feedType,
|
2020-04-04 00:18:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:10:51 +01:00
|
|
|
function fetchGabTrendsFail(error, feedType) {
|
2020-04-04 00:18:26 +01:00
|
|
|
return {
|
|
|
|
type: GAB_TRENDS_RESULTS_FETCH_FAIL,
|
|
|
|
error,
|
2020-06-09 03:10:51 +01:00
|
|
|
feedType,
|
2020-04-04 00:18:26 +01:00
|
|
|
}
|
2020-09-10 23:21:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const fetchGabNews = () => {
|
|
|
|
return function (dispatch) {
|
|
|
|
dispatch(fetchGabNewsRequest())
|
|
|
|
|
|
|
|
axios.get('https://news.gab.com/feed/json').then((response) => {
|
|
|
|
dispatch(fetchGabNewsSuccess(response.data))
|
|
|
|
}).catch(function (error) {
|
|
|
|
dispatch(fetchGabNewsFail(error))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchGabNewsRequest() {
|
|
|
|
return {
|
|
|
|
type: GAB_NEWS_RESULTS_FETCH_REQUEST,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchGabNewsSuccess(items) {
|
|
|
|
return {
|
|
|
|
type: GAB_NEWS_RESULTS_FETCH_SUCCESS,
|
|
|
|
items,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchGabNewsFail(error) {
|
|
|
|
return {
|
|
|
|
type: GAB_NEWS_RESULTS_FETCH_FAIL,
|
|
|
|
error,
|
|
|
|
}
|
2020-04-04 00:18:26 +01:00
|
|
|
}
|