mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
Merge pull request #1350 from esteemapp/voters-filterbar
fix voters page filterbar
This commit is contained in:
commit
d189ee81b5
@ -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,
|
||||
|
@ -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} />
|
||||
|
Loading…
Reference in New Issue
Block a user