Fix fetching more channels to join (#2393)
* Fix fetching more channels to join * update snapshot
This commit is contained in:
parent
fc5948fcc8
commit
390fbb039d
2 changed files with 16 additions and 35 deletions
|
|
@ -46,9 +46,9 @@ exports[`MoreChannels should match snapshot 1`] = `
|
|||
},
|
||||
]
|
||||
}
|
||||
extraData={false}
|
||||
extraData={true}
|
||||
listType="flat"
|
||||
loading={false}
|
||||
loading={true}
|
||||
loadingComponent={
|
||||
<View
|
||||
style={
|
||||
|
|
@ -71,29 +71,7 @@ exports[`MoreChannels should match snapshot 1`] = `
|
|||
/>
|
||||
</View>
|
||||
}
|
||||
noResults={
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flexDirection": "row",
|
||||
"flexGrow": 1,
|
||||
"justifyContent": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
<FormattedText
|
||||
defaultMessage="No more channels to join"
|
||||
id="more_channels.noMore"
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(61,60,64,0.5)",
|
||||
"fontSize": 26,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
}
|
||||
noResults={null}
|
||||
onLoadMore={[Function]}
|
||||
onRowPress={[Function]}
|
||||
renderItem={[Function]}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export default class MoreChannels extends PureComponent {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.getChannels();
|
||||
this.doGetChannels();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
|
|
@ -92,7 +92,7 @@ export default class MoreChannels extends PureComponent {
|
|||
}
|
||||
|
||||
if (nextProps.channels !== this.props.channels) {
|
||||
channels = nextProps.channels.slice(0, (this.page + 1) * General.CHANNELS_CHUNK_SIZE);
|
||||
channels = nextProps.channels;
|
||||
if (term) {
|
||||
channels = this.filterChannels(nextProps.channels, term);
|
||||
}
|
||||
|
|
@ -116,15 +116,10 @@ export default class MoreChannels extends PureComponent {
|
|||
this.props.navigator.dismissModal({animationType: 'slide-down'});
|
||||
};
|
||||
|
||||
filterChannels = (channels, term) => {
|
||||
return channels.filter((c) => {
|
||||
return (c.name.toLowerCase().includes(term) || c.display_name.toLowerCase().includes(term));
|
||||
});
|
||||
};
|
||||
|
||||
getChannels = debounce(() => {
|
||||
doGetChannels = () => {
|
||||
const {actions, currentTeamId} = this.props;
|
||||
const {loading, term} = this.state;
|
||||
|
||||
if (this.next && !loading && !term) {
|
||||
this.setState({loading: true}, () => {
|
||||
actions.getChannels(
|
||||
|
|
@ -134,7 +129,15 @@ export default class MoreChannels extends PureComponent {
|
|||
).then(this.loadedChannels);
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
filterChannels = (channels, term) => {
|
||||
return channels.filter((c) => {
|
||||
return (c.name.toLowerCase().includes(term) || c.display_name.toLowerCase().includes(term));
|
||||
});
|
||||
};
|
||||
|
||||
getChannels = debounce(this.doGetChannels, 100);
|
||||
|
||||
headerButtons = (createEnabled) => {
|
||||
const {canCreateChannels} = this.props;
|
||||
|
|
|
|||
Loading…
Reference in a new issue