bigbuffet-rw/app/soapbox/actions/trending_statuses.js

21 lines
794 B
JavaScript
Raw Normal View History

2022-03-21 11:09:01 -07:00
import api from '../api';
import { importFetchedStatuses } from './importer';
export const TRENDING_STATUSES_FETCH_REQUEST = 'TRENDING_STATUSES_FETCH_REQUEST';
export const TRENDING_STATUSES_FETCH_SUCCESS = 'TRENDING_STATUSES_FETCH_SUCCESS';
export const TRENDING_STATUSES_FETCH_FAIL = 'TRENDING_STATUSES_FETCH_FAIL';
export function fetchTrendingStatuses() {
return (dispatch, getState) => {
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
return api(getState).get('/api/v1/truth/trending/truths').then(({ data: statuses }) => {
dispatch(importFetchedStatuses(statuses));
dispatch({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses });
return statuses;
}).catch(error => {
dispatch({ type: TRENDING_STATUSES_FETCH_FAIL, error });
});
};
}