forked from vergnet/application-amicale
Improved planex group search performance
This commit is contained in:
parent
0b7191887d
commit
ea16a1f50f
2 changed files with 24 additions and 19 deletions
|
@ -63,7 +63,9 @@ class AnimatedAccordion extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State): boolean {
|
||||
return nextState.expanded !== this.state.expanded;
|
||||
if (nextProps.opened != null && nextProps.opened !== this.props.opened)
|
||||
this.state.expanded = nextProps.opened;
|
||||
return true;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -23,10 +23,6 @@ const LIST_ITEM_HEIGHT = 64;
|
|||
|
||||
class GroupListAccordion extends React.Component<Props> {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: Props) {
|
||||
return (nextProps.currentSearchString !== this.props.currentSearchString)
|
||||
|| (nextProps.favoriteNumber !== this.props.favoriteNumber)
|
||||
|
@ -36,7 +32,6 @@ class GroupListAccordion extends React.Component<Props> {
|
|||
keyExtractor = (item: group) => item.id.toString();
|
||||
|
||||
renderItem = ({item}: { item: group }) => {
|
||||
if (stringMatchQuery(item.name, this.props.currentSearchString)) {
|
||||
const onPress = () => this.props.onGroupPress(item);
|
||||
const onStarPress = () => this.props.onFavoritePress(item);
|
||||
return (
|
||||
|
@ -46,8 +41,16 @@ class GroupListAccordion extends React.Component<Props> {
|
|||
onPress={onPress}
|
||||
onStarPress={onStarPress}/>
|
||||
);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
getData() {
|
||||
const originalData = this.props.item.content;
|
||||
let displayData = [];
|
||||
for (let i = 0; i < originalData.length; i++) {
|
||||
if (stringMatchQuery(originalData[i].name, this.props.currentSearchString))
|
||||
displayData.push(originalData[i]);
|
||||
}
|
||||
return displayData;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -73,7 +76,7 @@ class GroupListAccordion extends React.Component<Props> {
|
|||
>
|
||||
{/*$FlowFixMe*/}
|
||||
<FlatList
|
||||
data={item.content}
|
||||
data={this.getData()}
|
||||
extraData={this.props.currentSearchString}
|
||||
renderItem={this.renderItem}
|
||||
keyExtractor={this.keyExtractor}
|
||||
|
|
Loading…
Reference in a new issue