...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
import ReactNative from 'react-native';
|
|
|
import ListService from '../../services/ListService';
|
|
|
import DetailService from '../../services/DetailService';
|
|
|
|
|
|
const {
|
|
|
SET_LIST_TYPE,
|
...
|
...
|
@@ -13,6 +14,10 @@ const { |
|
|
GET_ARTICLE_LIST_FAILURE,
|
|
|
|
|
|
LIKE_ARTICLE,
|
|
|
|
|
|
GET_AUTHOR_REQUEST,
|
|
|
GET_AUTHOR_SUCCESS,
|
|
|
GET_AUTHOR_FAILURE,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
export function setListType(type) {
|
...
|
...
|
@@ -169,3 +174,46 @@ function parseArticleList(json) { |
|
|
total,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function getAuthorRequest() {
|
|
|
return {
|
|
|
type: GET_AUTHOR_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function getAuthorSuccess(json) {
|
|
|
return {
|
|
|
type: GET_AUTHOR_SUCCESS,
|
|
|
payload: json
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function getAuthorFailure(error) {
|
|
|
return {
|
|
|
type: GET_AUTHOR_FAILURE,
|
|
|
payload: error
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function getAuthor() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, list} = getState();
|
|
|
let {type, authorId, tag, articles} = list;
|
|
|
|
|
|
if (!authorId) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
dispatch(getAuthorRequest());
|
|
|
return new DetailService(app.serviceHost).getAuthor(authorId)
|
|
|
.then(json => {
|
|
|
let payload = json;
|
|
|
|
|
|
dispatch(getAuthorSuccess(json));
|
|
|
// dispatch(dataExposure(payload.logFloors));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getAuthorFailure(error));
|
|
|
});
|
|
|
};
|
|
|
} |
...
|
...
|
|