Fix room’s list order and load more
This commit is contained in:
parent
d522292a98
commit
03b97c25b1
|
@ -98,12 +98,15 @@ export default class RoomView extends React.Component {
|
|||
}
|
||||
|
||||
onEndReached = () => {
|
||||
if (this.state.dataSource.length && this.state.loaded && this.state.loadingMore !== true && this.state.end !== true) {
|
||||
const rowCount = this.state.dataSource.getRowCount();
|
||||
if (rowCount && this.state.loaded && this.state.loadingMore !== true && this.state.end !== true) {
|
||||
this.setState({
|
||||
// ...this.state,
|
||||
loadingMore: true
|
||||
});
|
||||
RocketChat.loadMessagesForRoom(this.rid, this.state.dataSource[this.state.dataSource.length - 1].ts, ({ end }) => {
|
||||
|
||||
const lastRowData = this.data[rowCount - 1];
|
||||
RocketChat.loadMessagesForRoom(this.rid, lastRowData.ts, ({ end }) => {
|
||||
this.setState({
|
||||
// ...this.state,
|
||||
loadingMore: false,
|
||||
|
@ -196,8 +199,8 @@ export default class RoomView extends React.Component {
|
|||
<ListView
|
||||
enableEmptySections
|
||||
style={styles.list}
|
||||
onEndReachedThreshold={0.1}
|
||||
ListFooterComponent={this.renderHeader()}
|
||||
onEndReachedThreshold={10}
|
||||
renderFooter={this.renderHeader}
|
||||
onEndReached={this.onEndReached}
|
||||
dataSource={this.state.dataSource}
|
||||
renderRow={item => this.renderItem({ item })}
|
||||
|
|
|
@ -110,9 +110,9 @@ export default class RoomsListView extends React.Component {
|
|||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.data = realm.objects('subscriptions').filtered('_server.id = $0', this.props.server).sorted('_updatedAt', true);
|
||||
this.data = realm.objects('subscriptions').filtered('_server.id = $0', this.props.server);
|
||||
this.state = {
|
||||
dataSource: ds.cloneWithRows(this.data.sorted('_updatedAt', true).slice(0, 10)),
|
||||
dataSource: ds.cloneWithRows([]),
|
||||
searching: false,
|
||||
searchDataSource: [],
|
||||
searchText: ''
|
||||
|
@ -244,7 +244,7 @@ export default class RoomsListView extends React.Component {
|
|||
|
||||
updateState = debounce(() => {
|
||||
this.setState({
|
||||
dataSource: ds.cloneWithRows(this.data.filtered('_server.id = $0', this.props.server))
|
||||
dataSource: ds.cloneWithRows(this.data.filtered('_server.id = $0', this.props.server).sorted('ls', true))
|
||||
});
|
||||
}, 500);
|
||||
|
||||
|
|
Loading…
Reference in New Issue