...
|
...
|
@@ -21,9 +21,6 @@ export default class Message extends Component { |
|
|
super(props);
|
|
|
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
this._onEndReached = this._onEndReached.bind(this);
|
|
|
this._renderFooter = this._renderFooter.bind(this);
|
|
|
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
...
|
...
|
@@ -31,44 +28,17 @@ export default class Message extends Component { |
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
this.trigggePullToRefresh();
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
if (nextProps.data.ptr) {
|
|
|
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false, });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
trigggePullToRefresh() {
|
|
|
if (Platform.OS === 'ios') {
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
this.listView && this.listView.getScrollResponder().startPullToRefresh();
|
|
|
});
|
|
|
} else {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData: object, sectionID: number, rowID: number) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
_onEndReached() {
|
|
|
|
|
|
}
|
|
|
|
|
|
_renderFooter() {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {list, ptr, isFetching, endReached, showLoginTip, cachedList} = this.props.data;
|
|
|
let dataSource = list.size == 0 ? cachedList.toArray() : list.toArray();
|
|
|
|
|
|
let isPullToRefresh = ptr && isFetching;
|
|
|
let isLoadingMore = list.size != 0 && !ptr && isFetching;
|
|
|
|
|
|
let dataSource = [];
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
...
|
...
|
@@ -80,13 +50,6 @@ export default class Message extends Component { |
|
|
dataSource={this.dataSource.cloneWithRows(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
enableEmptySections={true}
|
|
|
enablePullToRefresh={true}
|
|
|
isOnPullToRefresh={isPullToRefresh}
|
|
|
onRefreshData={() => {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}}
|
|
|
onEndReached={this._onEndReached}
|
|
|
renderFooter={this._renderFooter}
|
|
|
/>
|
|
|
</View>
|
|
|
);
|
...
|
...
|
|