add excluded polls

This commit is contained in:
Barry Gitarts 2018-07-16 09:20:42 -04:00
parent 93d02aaa8c
commit 84694d1dd2
2 changed files with 10 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import SNT from 'Embark/contracts/SNT';
import { VotingContext } from './context';
import Web3Render from './components/standard/Web3Render';
import fetchIdeas from './utils/fetchIdeas';
import { getPolls, omitUnvotedDupes } from './utils/polls';
import { getPolls, omitPolls } from './utils/polls';
window['SNT'] = SNT;
import './dapp.css';
@ -44,7 +44,7 @@ class App extends React.Component {
_getPolls = async () => {
const { nPolls, poll } = PollManager.methods;
const polls = await nPolls().call();
if (polls) getPolls(polls, poll).then(omitUnvotedDupes).then(rawPolls => { this.setState({ rawPolls })});
if (polls) getPolls(polls, poll).then(omitPolls).then(rawPolls => { this.setState({ rawPolls })});
else this.setState({ rawPolls: [] });
}

View File

@ -1,3 +1,8 @@
const excluded = {
PROPER_LIGHT_CLIENT_SUPPORT : 3,
IMPLEMENT_SECURITY_PRACTICES : 14,
SHIP_1_0 : 16
};
export const getPolls = (number, pollMethod) => {
const polls = [];
@ -8,6 +13,6 @@ export const getPolls = (number, pollMethod) => {
return Promise.all(polls.reverse());
}
const unVotedDupes = new Set([3]);
const filterDupes = (poll, idx) => !unVotedDupes.has(idx);
export const omitUnvotedDupes = polls => polls.filter(filterDupes);
const excludedPolls = new Set(Object.values(excluded));
const exclusionFilter = (poll, idx) => !excludedPolls.has(idx);
export const omitPolls = polls => polls.filter(exclusionFilter);