Merge pull request #1350 from esteemapp/voters-filterbar

fix voters page filterbar
This commit is contained in:
Feruz M 2019-12-03 19:51:02 +02:00 committed by GitHub
commit d189ee81b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -15,7 +15,7 @@ class AccountListContainer extends Component {
this.state = {
data: props.data,
filterResult: null,
filterIndex: '0',
filterIndex: 0,
};
}
@ -33,7 +33,7 @@ class AccountListContainer extends Component {
return itemName.indexOf(_text) > -1;
});
if (filterIndex !== '0') {
if (filterIndex !== 0) {
this._handleOnVotersDropdownSelect(filterIndex, '', newData);
} else {
this.setState({ filterResult: newData });
@ -45,13 +45,13 @@ class AccountListContainer extends Component {
const _data = Object.assign([], oldData || data);
switch (index) {
case '0':
case 0:
_data.sort((a, b) => Number(b.value) - Number(a.value));
break;
case '1':
case 1:
_data.sort((a, b) => b.percent - a.percent);
break;
case '2':
case 2:
_data.sort((a, b) => (isBefore(a.time, b.time) ? 1 : -1));
break;
default:
@ -74,7 +74,7 @@ class AccountListContainer extends Component {
};
render() {
const { data, filterResult } = this.state;
const { data, filterResult, filterIndex } = this.state;
const { children } = this.props;
return (
@ -82,6 +82,7 @@ class AccountListContainer extends Component {
children({
data,
filterResult,
filterIndex,
handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect,
handleSearch: this._handleSearch,
handleOnUserPress: this._handleOnUserPress,

View File

@ -23,7 +23,7 @@ const VotersScreen = ({ navigation }) => {
return (
<AccountListContainer data={activeVotes}>
{({ data, filterResult, handleOnVotersDropdownSelect, handleSearch }) => (
{({ data, filterResult, filterIndex, handleOnVotersDropdownSelect, handleSearch }) => (
<SafeAreaView style={globalStyles.container}>
<BasicHeader
title={`${headerTitle} (${data && data.length})`}
@ -37,7 +37,10 @@ const VotersScreen = ({ navigation }) => {
id: `voters_dropdown.${item}`,
}),
)}
defaultText={intl.formatMessage({ id: `voters_dropdown.${filterOptions[0]}` })}
defaultText={intl.formatMessage({
id: `voters_dropdown.${filterOptions[filterIndex]}`,
})}
selectedOptionIndex={filterIndex}
onDropdownSelect={handleOnVotersDropdownSelect}
/>
<VotersDisplay votes={filterResult || data} />