...
|
...
|
@@ -16,6 +16,11 @@ const { |
|
|
FETCH_CONTENT_LIST_SUCCESS,
|
|
|
FETCH_CONTENT_LIST_FAILURE,
|
|
|
|
|
|
//main评论内容
|
|
|
FETCH_COMMENT_LIST_REQUEST,
|
|
|
FETCH_COMMENT_LIST_SUCCESS,
|
|
|
FETCH_COMMENT_LIST_FAILURE,
|
|
|
|
|
|
//回复评论
|
|
|
ADD_ARTICLE_COMMENT_REQUEST,
|
|
|
ADD_ARTICLE_COMMENT_SUCCESS,
|
...
|
...
|
@@ -41,10 +46,6 @@ const { |
|
|
|
|
|
const initialState = new InitialState;
|
|
|
|
|
|
function getContentListObject(isLatest) {
|
|
|
return isLatest ? 'commentList' : 'contentList';
|
|
|
}
|
|
|
|
|
|
export default function grassReducer(state=initialState, action) {
|
|
|
switch(action.type) {
|
|
|
case SET_CONTENT_LIST_ID: {
|
...
|
...
|
@@ -73,29 +74,54 @@ export default function grassReducer(state=initialState, action) { |
|
|
.setIn(['contentType', 'error'], action.payload)
|
|
|
}
|
|
|
|
|
|
case FETCH_COMMENT_LIST_REQUEST: {
|
|
|
return state.setIn(['commentList', 'isFetching'], true)
|
|
|
.setIn(['commentList', 'isPullToRefresh'], action.isRefresh == true)
|
|
|
}
|
|
|
|
|
|
case FETCH_COMMENT_LIST_SUCCESS: {
|
|
|
state = state
|
|
|
.setIn(['commentList', 'isFetching'], false)
|
|
|
.setIn(['commentList', 'list'], Immutable.fromJS((action.payload.list)))
|
|
|
.setIn(['commentList', 'currentPage'], action.payload.currentPage)
|
|
|
.setIn(['commentList', 'endReached'], action.payload.endReached)
|
|
|
.setIn(['commentList', 'isPullToRefresh'], false)
|
|
|
.setIn(['commentList', 'pageCount'], action.payload.pageCount)
|
|
|
.setIn(['commentList', 'shouldShowEmpty'], action.payload.shouldShowEmpty)
|
|
|
|
|
|
return state;
|
|
|
}
|
|
|
|
|
|
case FETCH_COMMENT_LIST_FAILURE: {
|
|
|
return state.setIn(['commentList', 'isFetching'], false)
|
|
|
.setIn(['commentList', 'isPullToRefresh'], false)
|
|
|
.setIn(['commentList', 'error'], action.payload)
|
|
|
.setIn(['commentList', 'shouldShowEmpty'], true);
|
|
|
}
|
|
|
|
|
|
case FETCH_CONTENT_LIST_REQUEST: {
|
|
|
return state.setIn([getContentListObject(action.isLatest), 'isFetching'], true)
|
|
|
.setIn([getContentListObject(action.isLatest), 'isPullToRefresh'], action.isRefresh == true)
|
|
|
return state.setIn(['contentList', 'isFetching'], true)
|
|
|
.setIn(['contentList', 'isPullToRefresh'], action.isRefresh == true)
|
|
|
}
|
|
|
|
|
|
case FETCH_CONTENT_LIST_SUCCESS: {
|
|
|
state = state
|
|
|
.setIn([getContentListObject(action.isLatest), 'isFetching'], false)
|
|
|
.setIn([getContentListObject(action.isLatest), 'list'], Immutable.fromJS((action.payload.list)))
|
|
|
.setIn([getContentListObject(action.isLatest), 'currentPage'], action.payload.currentPage)
|
|
|
.setIn([getContentListObject(action.isLatest), 'endReached'], action.payload.endReached)
|
|
|
.setIn([getContentListObject(action.isLatest), 'isPullToRefresh'], false)
|
|
|
.setIn([getContentListObject(action.isLatest), 'pageCount'], action.payload.pageCount)
|
|
|
.setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], action.payload.shouldShowEmpty)
|
|
|
.setIn(['contentList', 'isFetching'], false)
|
|
|
.setIn(['contentList', 'list'], Immutable.fromJS((action.payload.list)))
|
|
|
.setIn(['contentList', 'currentPage'], action.payload.currentPage)
|
|
|
.setIn(['contentList', 'endReached'], action.payload.endReached)
|
|
|
.setIn(['contentList', 'isPullToRefresh'], false)
|
|
|
.setIn(['contentList', 'pageCount'], action.payload.pageCount)
|
|
|
.setIn(['contentList', 'shouldShowEmpty'], action.payload.shouldShowEmpty)
|
|
|
|
|
|
return state;
|
|
|
}
|
|
|
|
|
|
case FETCH_CONTENT_LIST_FAILURE: {
|
|
|
return state.setIn([getContentListObject(action.isLatest), 'isFetching'], false)
|
|
|
.setIn([getContentListObject(action.isLatest), 'isPullToRefresh'], false)
|
|
|
.setIn([getContentListObject(action.isLatest), 'error'], action.payload)
|
|
|
.setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], true);
|
|
|
return state.setIn(['contentList', 'isFetching'], false)
|
|
|
.setIn(['contentList', 'isPullToRefresh'], false)
|
|
|
.setIn(['contentList', 'error'], action.payload)
|
|
|
.setIn(['contentList', 'shouldShowEmpty'], true);
|
|
|
}
|
|
|
|
|
|
case ADD_ARTICLE_COMMENT_REQUEST: {
|
...
|
...
|
|