Authored by 盖剑秋

Fix some bugs on my collection goods. reviewed by redding.

... ... @@ -34,10 +34,10 @@ export default class Product extends Component {
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
this.state = {
currentlyOpenSwipeable: null,
isSwiping: false,
showFooter: false,
};
this.listView = null;
... ... @@ -58,7 +58,11 @@ export default class Product extends Component {
if (currentlyOpenSwipeable) {
currentlyOpenSwipeable.recenter();
}
this.props.setEditedIndex && this.props.setEditedIndex(-1);
let {editing,commonProduct, globalProduct} = this.props.data;
if (editing &&(commonProduct.get('editedIndex') >= 0 || globalProduct.get('editedIndex') >= 0 )) {
this.props.setEditedIndex && this.props.setEditedIndex(-1);
}
}
onOpen(event, gestureState, swipeable) {
... ... @@ -148,7 +152,7 @@ export default class Product extends Component {
<NoDataView type={'product'} onPressGuangGuang={this.props.onPressGuangGuang}/>
);
}
if (currentTab == 'global') {
if (currentTab == 'global' && this.state.showFooter) {
return(
<View style={styles.footerContainer}>
<Image style={styles.footerImage} resizeMode={'contain'} source={require('../../images/product/shared_bottom.png')}/>
... ... @@ -220,10 +224,11 @@ export default class Product extends Component {
editing,
currentTab,
} = this.props.data;
let dataArray = [];
let isLoading = false;
let showList = (commonProduct.get('productList').size && !commonProduct.get('isFetching')) || (globalProduct.get('productList').size && !commonProduct.get('isFetching'));
let showEmpty = commonProduct.get('showEmpty') && globalProduct.get('showEmpty');
if (currentTab == 'common') {
let {isFetching, selectedProductList, categoryList, selectedCategoryIndex, isDeleting} = commonProduct;
isLoading = (selectedProductList.size == 0 && isFetching) || isDeleting;
... ... @@ -251,8 +256,11 @@ export default class Product extends Component {
renderFooter={this.renderFooter}
bounces={dataArray.length > 0}
scrollEnabled={!this.state.isSwiping}
onContentSizeChange={(contentWidth, contentHeight) => {
this.setState({showFooter: contentHeight >= height - 64})
}}
/> : null}
{showEmpty ? <NoDataView type={'product'} onPressGuangGuang={this.props.onPressGuangGuang}/> : null}
<LoadingIndicator
isVisible={isLoading}
/>
... ...
... ... @@ -64,6 +64,10 @@ class ProductContainer extends Component {
if (!edit) {
this.props.actions.setEditedIndex(-1);
}
let {currentTab} = this.props.product;
if (currentTab == 'global' && edit) {
NativeModules.YH_CommonHelper.logEvent('YB_GLOBAL_MY_FAVPRD_EDIT', {});
}
}
);
}
... ... @@ -140,6 +144,11 @@ class ProductContainer extends Component {
let show = commonProduct.get('productList').size > 0;
ReactNative.NativeModules.YH_RecorderHelper.setRightEditButtonVisiblity(show);
}
if (tab == 'global') {
let {globalProduct} = this.props.product;
let show = globalProduct.get('productList').size > 0;
ReactNative.NativeModules.YH_RecorderHelper.setRightEditButtonVisiblity(show);
}
}
setEditedIndex(rowID) {
... ...
... ... @@ -343,7 +343,8 @@ export function deleteGlobal(skn, index) {
dispatch(setProductTab('common'));
}
dispatch(setEditedIndex(-1));
let show = productList.size > 0;
ReactNative.NativeModules.YH_RecorderHelper.setRightEditButtonVisiblity(show);
})
.catch(error => {
dispatch(globalDeleteFailure(error));
... ...
... ... @@ -14,6 +14,7 @@ let commonProduct = new(Record({
isDeleting: false,
editedIndex: -1,
showEmpty: false,
}));
let globalProduct = new(Record({
... ... @@ -25,6 +26,7 @@ let globalProduct = new(Record({
isDeleting: false,
editedIndex: -1,
showEmpty: false,
}));
let InitialState = Record({
... ...
... ... @@ -94,7 +94,8 @@ export default function productReducer(state=initialState, action) {
.set('productList', Immutable.fromJS(productList))
.set('selectedProductList', Immutable.fromJS(productList))
.set('currentPage', currentPage)
.set('selectedCategoryIndex', 0);
.set('selectedCategoryIndex', 0)
.set('showEmpty', productList.length == 0);
let newState = state.set('commonProduct', newProduct);
return newState;
... ... @@ -141,7 +142,8 @@ export default function productReducer(state=initialState, action) {
let newProduct = globalProduct.set('isFetching', false)
.set('error', null)
.set('productList', Immutable.fromJS(productList))
.set('currentPage', currentPage);
.set('currentPage', currentPage)
.set('showEmpty', productList.length == 0);
let newState = state.set('globalProduct', newProduct);
return newState;
... ... @@ -169,9 +171,12 @@ export default function productReducer(state=initialState, action) {
let {productList, selectedProductList} = action.payload;
let {commonProduct} = state;
let newProduct = commonProduct.set('isDeleting', false)
.set('productList', productList)
.set('selectedProductList', selectedProductList);
.set('selectedProductList', selectedProductList)
.set('showEmpty', productList.size == 0);
let newState = state.set('commonProduct', newProduct).set('isDeleting', false);
return newState;
... ... @@ -211,6 +216,7 @@ export default function productReducer(state=initialState, action) {
let {globalProduct} = state;
let newProduct = globalProduct.set('isDeleting', false)
.set('productList', productList)
.set('showEmpty', productList.size == 0);
let newState = state.set('globalProduct', newProduct).set('isDeleting', false);
return newState;
... ...