Authored by 孙凯

add 分类 多次刷新的bug review by hongmo

... ... @@ -275,7 +275,7 @@ export default class Brand extends Component {
Platform.OS === 'ios' ?
<ListView
ref={(ref)=>this.listView=ref}
initialListSize={initialListSize}
initialListSize={2000}
contentContainerStyle={contentContainerStyle}
enableEmptySections={true}
dataSource={listDataSource}
... ...
... ... @@ -41,7 +41,7 @@ export function getCategoryBList() {
return new CategoryBService(app.host).getCategoryBList()
.then(json => {
dispatch(getCategoryBListSuccess(json));
dispatch(getCategoryBFirstSubCategoryDetail(categoryB.currentChannelId));
})
.catch(error => {
... ... @@ -61,7 +61,7 @@ export function pressCategoryBMore(category_id){
let categoryData = categoryB.categoryList ? categoryB.categoryList.get(categoryB.currentChannelValue) : [];
//获取指定category_id分类信息
let category = null;
let category = null;
categoryData.map((item, i) => {
if(item && (category_id == item.get('category_id'))){
category = item;
... ... @@ -78,7 +78,7 @@ export function pressCategoryBMore(category_id){
//设置当前的类别信息
// dispatch(setCurrentCateB(category_id, category ? category.get('category_name') : ""));
dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
};
}
... ... @@ -130,6 +130,7 @@ export function getCategoryBSubCategoryDetail(categoryId, categoryValue){
currentCateId,
currentCateValue,
cacheSubCateData,
contentError,
} = categoryB;
//检查缓存是否存在数据
... ... @@ -140,16 +141,24 @@ export function getCategoryBSubCategoryDetail(categoryId, categoryValue){
let lastTimestamp = categoryData.get('lrts', 0);
let currentTimestamp = new Date().getTime();
let diff = currentTimestamp - lastTimestamp;
if (diff < 250) {
if (diff < 400) {
__DEV__ && console.log('timestamp diff < 50, return');
return;
}
}
if (contentError) {
let lastTimestamp = contentError.lrts;
let currentTimestamp = new Date().getTime();
let diff = currentTimestamp - lastTimestamp;
if (diff < 400) {
__DEV__ && console.log('timestamp diff < 50, return');
return;
}
}
if (currentCateId == categoryId && categoryB.contentFetching) {
return;
}
dispatch(getCategoryBSubDetail(currentChannelId, categoryId, categoryValue));
};
}
... ... @@ -201,9 +210,10 @@ export function getCategoryBSubDetail(channel_id, category_id, category_value) {
//曝光从网络获取的数据
dispatch(dataExposure(channel_id, category_id, category_value, json));
}
})
.catch(error => {
error.lrts = new Date().getTime();
dispatch(getCategoryBSubDetailFailure(error));
});
};
... ... @@ -432,4 +442,4 @@ function dataExposure(channel_id, category_id, category_value, json) {
}
};
}
\ No newline at end of file
}
... ...
... ... @@ -14,6 +14,7 @@ let InitialStateB = Record({
categoryList: Map(),
contentFetching: false,
delayExposeData: true,
contentError: null,
});
export default InitialStateB;
... ...
... ... @@ -53,11 +53,12 @@ export default function categoryBReducer(state=initialStateB, action) {
let {key, data} = action.payload;
return state.set('contentFetching', false)
.set('currentSubCateData', Immutable.fromJS(data))
.set('contentError', null)
.setIn(['cacheSubCateData', key], Immutable.fromJS(data));
}
case GET_CATEGORY_B_SUBDETAIL_FAILURE: {
return state.set('contentFetching', false);
return state.set('contentFetching', false).set('contentError', action.payload);
}
case SET_CURRENT_CATEGORY_B:{
return state.set('currentCateId',action.payload.id)
... ...
... ... @@ -50,7 +50,7 @@ export default class CouponCell extends React.Component {
let backgroundHeigth = showDetail ? topBackgroundHeigth + detailBackgroundHeigth + 20 : topBackgroundHeigth + 20;
return (
<View style={{width: width, height: backgroundHeigth}}>
<View style={{width: width, height: backgroundHeigth,backgroundColor: 'white'}}>
<View style={{width: width,height: 20,backgroundColor: 'white',}}/>
<Image source={require('../../image/coupon1_tip_bg.png')} style={styles.couponBackgroundImage}></Image>
<View style={styles.topContent}>
... ...