2019-08-06 08:57:52 -07:00
|
|
|
import api from 'flavours/glitch/util/api';
|
2022-02-24 15:34:33 -08:00
|
|
|
import { importFetchedStatuses } from './importer';
|
2019-08-06 08:57:52 -07:00
|
|
|
|
2022-02-24 15:34:33 -08:00
|
|
|
export const TRENDS_TAGS_FETCH_REQUEST = 'TRENDS_TAGS_FETCH_REQUEST';
|
|
|
|
export const TRENDS_TAGS_FETCH_SUCCESS = 'TRENDS_TAGS_FETCH_SUCCESS';
|
|
|
|
export const TRENDS_TAGS_FETCH_FAIL = 'TRENDS_TAGS_FETCH_FAIL';
|
2019-08-06 08:57:52 -07:00
|
|
|
|
2022-02-24 15:34:33 -08:00
|
|
|
export const TRENDS_LINKS_FETCH_REQUEST = 'TRENDS_LINKS_FETCH_REQUEST';
|
|
|
|
export const TRENDS_LINKS_FETCH_SUCCESS = 'TRENDS_LINKS_FETCH_SUCCESS';
|
|
|
|
export const TRENDS_LINKS_FETCH_FAIL = 'TRENDS_LINKS_FETCH_FAIL';
|
|
|
|
|
|
|
|
export const TRENDS_STATUSES_FETCH_REQUEST = 'TRENDS_STATUSES_FETCH_REQUEST';
|
|
|
|
export const TRENDS_STATUSES_FETCH_SUCCESS = 'TRENDS_STATUSES_FETCH_SUCCESS';
|
|
|
|
export const TRENDS_STATUSES_FETCH_FAIL = 'TRENDS_STATUSES_FETCH_FAIL';
|
|
|
|
|
|
|
|
export const fetchTrendingHashtags = () => (dispatch, getState) => {
|
|
|
|
dispatch(fetchTrendingHashtagsRequest());
|
|
|
|
|
|
|
|
api(getState)
|
|
|
|
.get('/api/v1/trends/tags')
|
|
|
|
.then(({ data }) => dispatch(fetchTrendingHashtagsSuccess(data)))
|
|
|
|
.catch(err => dispatch(fetchTrendingHashtagsFail(err)));
|
|
|
|
};
|
|
|
|
|
|
|
|
export const fetchTrendingHashtagsRequest = () => ({
|
|
|
|
type: TRENDS_TAGS_FETCH_REQUEST,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingHashtagsSuccess = trends => ({
|
|
|
|
type: TRENDS_TAGS_FETCH_SUCCESS,
|
|
|
|
trends,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingHashtagsFail = error => ({
|
|
|
|
type: TRENDS_TAGS_FETCH_FAIL,
|
|
|
|
error,
|
|
|
|
skipLoading: true,
|
|
|
|
skipAlert: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingLinks = () => (dispatch, getState) => {
|
|
|
|
dispatch(fetchTrendingLinksRequest());
|
2019-08-06 08:57:52 -07:00
|
|
|
|
|
|
|
api(getState)
|
2022-02-24 15:34:33 -08:00
|
|
|
.get('/api/v1/trends/links')
|
|
|
|
.then(({ data }) => dispatch(fetchTrendingLinksSuccess(data)))
|
|
|
|
.catch(err => dispatch(fetchTrendingLinksFail(err)));
|
2019-08-06 08:57:52 -07:00
|
|
|
};
|
|
|
|
|
2022-02-24 15:34:33 -08:00
|
|
|
export const fetchTrendingLinksRequest = () => ({
|
|
|
|
type: TRENDS_LINKS_FETCH_REQUEST,
|
2019-08-06 08:57:52 -07:00
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
2022-02-24 15:34:33 -08:00
|
|
|
export const fetchTrendingLinksSuccess = trends => ({
|
|
|
|
type: TRENDS_LINKS_FETCH_SUCCESS,
|
2019-08-06 08:57:52 -07:00
|
|
|
trends,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
2022-02-24 15:34:33 -08:00
|
|
|
export const fetchTrendingLinksFail = error => ({
|
|
|
|
type: TRENDS_LINKS_FETCH_FAIL,
|
|
|
|
error,
|
|
|
|
skipLoading: true,
|
|
|
|
skipAlert: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingStatuses = () => (dispatch, getState) => {
|
|
|
|
dispatch(fetchTrendingStatusesRequest());
|
|
|
|
|
|
|
|
api(getState).get('/api/v1/trends/statuses').then(({ data }) => {
|
|
|
|
dispatch(importFetchedStatuses(data));
|
|
|
|
dispatch(fetchTrendingStatusesSuccess(data));
|
|
|
|
}).catch(err => dispatch(fetchTrendingStatusesFail(err)));
|
|
|
|
};
|
|
|
|
|
|
|
|
export const fetchTrendingStatusesRequest = () => ({
|
|
|
|
type: TRENDS_STATUSES_FETCH_REQUEST,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingStatusesSuccess = statuses => ({
|
|
|
|
type: TRENDS_STATUSES_FETCH_SUCCESS,
|
|
|
|
statuses,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const fetchTrendingStatusesFail = error => ({
|
|
|
|
type: TRENDS_STATUSES_FETCH_FAIL,
|
2019-08-06 08:57:52 -07:00
|
|
|
error,
|
|
|
|
skipLoading: true,
|
|
|
|
skipAlert: true,
|
|
|
|
});
|