mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
fix voters page filterbar
This commit is contained in:
parent
148a428222
commit
2a72608654
@ -15,7 +15,7 @@ class AccountListContainer extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
data: props.data,
|
data: props.data,
|
||||||
filterResult: null,
|
filterResult: null,
|
||||||
filterIndex: '0',
|
filterIndex: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class AccountListContainer extends Component {
|
|||||||
return itemName.indexOf(_text) > -1;
|
return itemName.indexOf(_text) > -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filterIndex !== '0') {
|
if (filterIndex !== 0) {
|
||||||
this._handleOnVotersDropdownSelect(filterIndex, '', newData);
|
this._handleOnVotersDropdownSelect(filterIndex, '', newData);
|
||||||
} else {
|
} else {
|
||||||
this.setState({ filterResult: newData });
|
this.setState({ filterResult: newData });
|
||||||
@ -45,13 +45,13 @@ class AccountListContainer extends Component {
|
|||||||
const _data = Object.assign([], oldData || data);
|
const _data = Object.assign([], oldData || data);
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case '0':
|
case 0:
|
||||||
_data.sort((a, b) => Number(b.value) - Number(a.value));
|
_data.sort((a, b) => Number(b.value) - Number(a.value));
|
||||||
break;
|
break;
|
||||||
case '1':
|
case 1:
|
||||||
_data.sort((a, b) => b.percent - a.percent);
|
_data.sort((a, b) => b.percent - a.percent);
|
||||||
break;
|
break;
|
||||||
case '2':
|
case 2:
|
||||||
_data.sort((a, b) => (isBefore(a.time, b.time) ? 1 : -1));
|
_data.sort((a, b) => (isBefore(a.time, b.time) ? 1 : -1));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -74,7 +74,7 @@ class AccountListContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data, filterResult } = this.state;
|
const { data, filterResult, filterIndex } = this.state;
|
||||||
const { children } = this.props;
|
const { children } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -82,6 +82,7 @@ class AccountListContainer extends Component {
|
|||||||
children({
|
children({
|
||||||
data,
|
data,
|
||||||
filterResult,
|
filterResult,
|
||||||
|
filterIndex,
|
||||||
handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect,
|
handleOnVotersDropdownSelect: this._handleOnVotersDropdownSelect,
|
||||||
handleSearch: this._handleSearch,
|
handleSearch: this._handleSearch,
|
||||||
handleOnUserPress: this._handleOnUserPress,
|
handleOnUserPress: this._handleOnUserPress,
|
||||||
|
@ -23,7 +23,7 @@ const VotersScreen = ({ navigation }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountListContainer data={activeVotes}>
|
<AccountListContainer data={activeVotes}>
|
||||||
{({ data, filterResult, handleOnVotersDropdownSelect, handleSearch }) => (
|
{({ data, filterResult, filterIndex, handleOnVotersDropdownSelect, handleSearch }) => (
|
||||||
<SafeAreaView style={globalStyles.container}>
|
<SafeAreaView style={globalStyles.container}>
|
||||||
<BasicHeader
|
<BasicHeader
|
||||||
title={`${headerTitle} (${data && data.length})`}
|
title={`${headerTitle} (${data && data.length})`}
|
||||||
@ -37,7 +37,10 @@ const VotersScreen = ({ navigation }) => {
|
|||||||
id: `voters_dropdown.${item}`,
|
id: `voters_dropdown.${item}`,
|
||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
defaultText={intl.formatMessage({ id: `voters_dropdown.${filterOptions[0]}` })}
|
defaultText={intl.formatMessage({
|
||||||
|
id: `voters_dropdown.${filterOptions[filterIndex]}`,
|
||||||
|
})}
|
||||||
|
selectedOptionIndex={filterIndex}
|
||||||
onDropdownSelect={handleOnVotersDropdownSelect}
|
onDropdownSelect={handleOnVotersDropdownSelect}
|
||||||
/>
|
/>
|
||||||
<VotersDisplay votes={filterResult || data} />
|
<VotersDisplay votes={filterResult || data} />
|
||||||
|
Loading…
Reference in New Issue
Block a user