Authored by 于良

优化关注列表下拉刷新逻辑,更新react-native-simple-store至1.1.0 review by 草莓

... ... @@ -29,6 +29,12 @@ export default class Interest extends Component {
});
}
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
this.listView && this.listView.getScrollResponder().startPullToRefresh();
});
}
componentWillReceiveProps(nextProps) {
if (nextProps.data.ptr) {
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false, });
... ... @@ -84,9 +90,7 @@ export default class Interest extends Component {
enablePullToRefresh={true}
isOnPullToRefresh={isPullToRefresh}
onRefreshData={() => {
if (list.size != 0 && !isPullToRefresh) {
this.props.onRefresh && this.props.onRefresh();
}
}}
onEndReached={() => {
if (list.size != 0) {
... ...
... ... @@ -84,7 +84,6 @@ class InterestContainer extends Component {
componentDidMount() {
this.props.actions.loadCachedInterestList();
this.props.actions.interestList(true);
}
componentWillUnmount() {
... ...
... ... @@ -2,6 +2,9 @@
import ReactNative from 'react-native';
import InterestService from '../../services/InterestService';
import store from 'react-native-simple-store';
const YH_RNCacheTypeInterestList = 'YH_RNCacheTypeInterestList';
const {
SET_TYPE,
... ... @@ -37,8 +40,12 @@ export function loadCachedInterestList() {
return;
}
ReactNative.NativeModules.YH_ClassifyHelper.loadCachedInterestData()
store.get(YH_RNCacheTypeInterestList)
.then(data => {
if (!data) {
return;
}
dispatch({
type: LOAD_CACHED_INTEREST_LIST,
payload: data,
... ... @@ -112,12 +119,9 @@ export function interestList(reload=false) {
let list = [...oldList, ...payload.list];
payload.list = list;
} else {
ReactNative.NativeModules.YH_ClassifyHelper.updateCachedInterestData(payload.list)
store.save(YH_RNCacheTypeInterestList, payload.list)
.then(data => {
dispatch({
type: LOAD_CACHED_INTEREST_LIST,
payload: payload.list,
});
})
.catch(error => {
... ...
... ... @@ -22,7 +22,7 @@
"react-native-progress": "^3.0.1",
"react-native-router-flux": "^3.32.0",
"react-native-scrollable-mixin": "^1.0.1",
"react-native-simple-store": "^1.0.1",
"react-native-simple-store": "^1.1.0",
"react-native-swiper": "^1.4.11",
"react-redux": "^4.4.5",
"react-static-container": "^1.0.1",
... ...