...
|
...
|
@@ -67,7 +67,7 @@ export function pressCategoryBMore(category_id){ |
|
|
};
|
|
|
|
|
|
//设置当前的类别信息
|
|
|
dispatch(setCurrentCateB(category_id, category ? category.get('category_name') : ""));
|
|
|
// dispatch(setCurrentCateB(category_id, category ? category.get('category_name') : ""));
|
|
|
dispatch(jumpToCategory(all, 0, categoryB.currentChannelId));
|
|
|
|
|
|
};
|
...
|
...
|
@@ -89,12 +89,12 @@ export function fetchSubCategory(categoryId, categoryValue, callback) { |
|
|
//检查缓存是否存在数据,如果不存在则获取
|
|
|
let key = getSubDetailCacheKey(currentChannelId, categoryId);
|
|
|
let categoryData = cacheSubCateData ? cacheSubCateData.get(key) : "";
|
|
|
//未命中,访问网络数据
|
|
|
//已命中,展示缓存数据
|
|
|
if (categoryData) {
|
|
|
dispatch(getCategoryBSubDetailFromCache(categoryData));
|
|
|
//曝光从缓存获取的数据
|
|
|
dispatch(dataExposure(currentChannelId, categoryId, categoryValue, categoryData));
|
|
|
//已命中,展示缓存数据
|
|
|
//未命中,访问网络数据
|
|
|
} else {
|
|
|
callback && callback();
|
|
|
}
|
...
|
...
|
@@ -104,24 +104,38 @@ export function fetchSubCategory(categoryId, categoryValue, callback) { |
|
|
/**
|
|
|
* 获取子分类的数据,逻辑上先判断缓存数据是否存在,不存在则从网络获取
|
|
|
**/
|
|
|
export function getCategoryBSubCategoryDetail(category_id, category_value){
|
|
|
export function getCategoryBSubCategoryDetail(categoryId, categoryValue){
|
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
|
let {categoryB} = getState();
|
|
|
|
|
|
let {
|
|
|
currentChannelId,
|
|
|
currentCateId,
|
|
|
currentCateValue,
|
|
|
cacheSubCateData,
|
|
|
} = categoryB;
|
|
|
|
|
|
//检查缓存是否存在数据
|
|
|
let key = getSubDetailCacheKey(currentChannelId, categoryId);
|
|
|
let categoryData = cacheSubCateData ? cacheSubCateData.get(key) : "";
|
|
|
//已有缓存
|
|
|
if (categoryData && categoryData.size > 0) {
|
|
|
let lastTimestamp = categoryData.get('lrts', 0);
|
|
|
let currentTimestamp = new Date().getTime();
|
|
|
let diff = currentTimestamp - lastTimestamp;
|
|
|
if (diff < 250) {
|
|
|
__DEV__ && console.log('timestamp diff < 50, return');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (currentCateId == category_id && categoryB.contentFetching) {
|
|
|
if (currentCateId == categoryId && categoryB.contentFetching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let currentChannelId = categoryB.currentChannelId;
|
|
|
dispatch(getCategoryBSubDetail(currentChannelId, category_id, category_value));
|
|
|
dispatch(getCategoryBSubDetail(currentChannelId, categoryId, categoryValue));
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -182,7 +196,11 @@ export function getCategoryBFirstSubCategoryDetail() { |
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
let {categoryB} = getState();
|
|
|
let {currentChannelId, currentChannelValue, categoryList} = categoryB;
|
|
|
let {currentChannelId, currentChannelValue, categoryList, contentFetching} = categoryB;
|
|
|
if (contentFetching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let category = categoryList.get(currentChannelValue) ? categoryList.get(currentChannelValue).get(0) : "";
|
|
|
|
|
|
let category_id = category ? category.get('category_id') : "";
|
...
|
...
|
@@ -203,7 +221,7 @@ function parseCategoryBSubDetail(channel_id, category_id, subcategory_data, prop |
|
|
if(!subcategory_data || !props_data){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
subcategory_data.lrts = new Date().getTime();
|
|
|
let key = getSubDetailCacheKey(channel_id, category_id);
|
|
|
|
|
|
return {key: key, data: subcategory_data};
|
...
|
...
|
|