Authored by 于良

下拉刷新和上拉加载优化 review by 阿瑟

... ... @@ -100,7 +100,7 @@ class HomeContainer extends React.Component {
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.bannerNoticeSection();
this.props.actions.bannerNoticeSectionOnlyDispathSuccess();
this.props.actions.getUserInfo(false);
});
... ...
... ... @@ -86,7 +86,7 @@ class SectionContainer extends React.Component {
}
InteractionManager.runAfterInteractions(() => {
this.props.actions.header();
this.props.actions.headerOnlyDispatchSuccess();
});
}
... ...
... ... @@ -67,6 +67,25 @@ export function bannerNoticeSection() {
};
}
export function bannerNoticeSectionOnlyDispathSuccess() {
return (dispatch, getState) => {
let {app, home} = getState();
if (home.isFetching) {
return;
}
// dispatch(bnsRequest());
return new HomeService().bannerNoticeSection(app.container)
.then(json => {
let payload = parseBNS(json);
dispatch(bnsSuccess(payload));
})
.catch(error => {
// dispatch(bnsFailure(error));
});
};
}
export function recommendationRequest(ptr) {
return {
type: HOME_RECOMMENDATION_REQUEST,
... ... @@ -91,7 +110,7 @@ export function recommendationFailure(error) {
export function recommendation(ptr = false) {
return (dispatch, getState) => {
let {home, user} = getState();
if (home.recommendation.isFetching || (!ptr && home.recommendation.endReached)) {
if (home.recommendation.isFetching || (!ptr && home.recommendation.endReached) || home.recommendation.error !== null) {
return;
}
... ...
... ... @@ -24,7 +24,7 @@ let InitialState = Record({
})),
notice: new (Record({
duration: 3,
open: 'Y',
open: 'N',
list: List(),
})),
section: List(),
... ...
... ... @@ -106,10 +106,28 @@ export function header() {
};
}
export function headerOnlyDispatchSuccess() {
return (dispatch, getState) => {
let {section} = getState();
if (section.isFetching) {
return;
}
// dispatch(headerRequest());
return new SectionService().header(section.id)
.then(json => {
let payload = parseHeader(json);
dispatch(headerSuccess(payload));
})
.catch(error => {
// dispatch(headerFailure());
});
};
}
export function newPost(ptr = false) {
return (dispatch, getState) => {
let {section, user} = getState();
if (section.new.isFetching || (!ptr && section.new.endReached)) {
if (section.new.isFetching || (!ptr && section.new.endReached) || section.new.error !== null) {
return;
}
dispatch(newPostRequest(ptr));
... ... @@ -139,7 +157,7 @@ export function newPost(ptr = false) {
export function hotPost(ptr = false) {
return (dispatch, getState) => {
let {section, user} = getState();
if (section.hot.isFetching || (!ptr && section.hot.endReached)) {
if (section.hot.isFetching || (!ptr && section.hot.endReached) || section.hot.error !== null) {
return;
}
dispatch(hotPostRequest(ptr));
... ...
... ... @@ -23,7 +23,7 @@ let InitialState = Record({
ptr: false,
notice: new (Record({
duration: 3,
open: 'Y',
open: 'N',
list: List(),
})),
header: new (Record({
... ...