Authored by 于良

切换品牌时,消息加载优化 review by yewanwan

... ... @@ -64,6 +64,7 @@ class DrawerContainer extends Component {
this.props.actions.overview(brand.get('shopsId'));
this.props.actions.brandRank(brand.get('shopsId'));
this.props.actions.requestUnreadMsgNum(brand.get('shopsId'), 'N');
this.props.actions.getMsgList(brand.get('shopsId'));
}
render() {
... ...
... ... @@ -56,19 +56,11 @@ class MessageContainer extends Component {
}
componentDidMount() {
// console.log('yeww componentDidMount');
this.props.actions.getMsgList(this.props.home.brandId);
}
componentWillReceiveProps() {
if (!this.props.message.isFetching && this.props.message.messageList.size == 0) {
// console.log('yeww componentWillReceiveProps');
this.props.actions.getMsgList(this.props.home.brandId);
}
}
pressRow(rowID){
this.props.actions.checkMessageDetail(rowID);
this.props.actions.checkMessageDetail(rowID);
}
render() {
... ...
... ... @@ -54,7 +54,12 @@ export function requestMsgListFailure(error) {
}
export function getMsgList(brandId) {
return dispatch => {
return (dispatch, getState) => {
const {message} = getState();
if (!shouldRequestMsgList(message)) {
return;
}
dispatch(requestMsgList(brandId));
return new MessageService().getMsgList(brandId)
.then(json => {
... ... @@ -66,6 +71,14 @@ export function getMsgList(brandId) {
};
}
export function shouldRequestMsgList(message) {
if (message.isFetching || message.messageList.size != 0) {
return false;
}
return true;
}
export function setMsgIsRead(brandId, messageId) {
return dispatch => {
dispatch(batchSetMsgRead());
... ...