This commit is contained in:
mgabdev
2020-02-19 18:57:07 -05:00
parent be3daea78b
commit e37500c0cf
105 changed files with 1975 additions and 1393 deletions

View File

@@ -0,0 +1,39 @@
import api from '../api';
export const HASHTAGS_FETCH_REQUEST = 'HASHTAGS_FETCH_REQUEST';
export const HASHTAGS_FETCH_SUCCESS = 'HASHTAGS_FETCH_SUCCESS';
export const HASHTAGS_FETCH_FAIL = 'HASHTAGS_FETCH_FAIL';
export function fetchHashtags() {
return (dispatch, getState) => {
dispatch(fetchHashtagsRequest());
api(getState).get('/api/v1/trends').then(response => {
dispatch(fetchHashtagsSuccess(response.data));
}).catch(error => dispatch(fetchHashtagsFail(error)));
};
};
export function fetchHashtagsRequest() {
return {
type: HASHTAGS_FETCH_REQUEST,
skipLoading: true,
};
};
export function fetchHashtagsSuccess(tags) {
return {
tags,
type: HASHTAGS_FETCH_SUCCESS,
skipLoading: true,
};
};
export function fetchHashtagsFail(error) {
return {
error,
type: HASHTAGS_FETCH_FAIL,
skipLoading: true,
skipAlert: true,
};
};

View File

@@ -81,13 +81,17 @@ export const fetchListFail = (id, error) => ({
});
export const fetchLists = () => (dispatch, getState) => {
if (!me) return;
dispatch(fetchListsRequest());
api(getState).get('/api/v1/lists')
.then(({ data }) => dispatch(fetchListsSuccess(data)))
.catch(err => dispatch(fetchListsFail(err)));
return new Promise((resolve, reject) => {
dispatch(fetchListsRequest());
if (!me) return reject()
api(getState).get('/api/v1/lists').then(({ data }) => {
dispatch(fetchListsSuccess(data))
return resolve()
}).catch((err) => {
dispatch(fetchListsFail(err))
return reject()
});
})
};
export const fetchListsRequest = () => ({

View File

@@ -1,39 +0,0 @@
import api from '../api';
export const TRENDS_FETCH_REQUEST = 'TRENDS_FETCH_REQUEST';
export const TRENDS_FETCH_SUCCESS = 'TRENDS_FETCH_SUCCESS';
export const TRENDS_FETCH_FAIL = 'TRENDS_FETCH_FAIL';
export function fetchTrends() {
return (dispatch, getState) => {
dispatch(fetchTrendsRequest());
api(getState).get('/api/v1/trends').then(response => {
dispatch(fetchTrendsSuccess(response.data));
}).catch(error => dispatch(fetchTrendsFail(error)));
};
};
export function fetchTrendsRequest() {
return {
type: TRENDS_FETCH_REQUEST,
skipLoading: true,
};
};
export function fetchTrendsSuccess(tags) {
return {
type: TRENDS_FETCH_SUCCESS,
tags,
skipLoading: true,
};
};
export function fetchTrendsFail(error) {
return {
type: TRENDS_FETCH_FAIL,
error,
skipLoading: true,
skipAlert: true,
};
};