Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #54 from tkshnwesper/fix
Browse files Browse the repository at this point in the history
added filterDupes... to filter out dupes?
  • Loading branch information
tahnik authored Apr 22, 2017
2 parents 7233ee9 + 32cf04a commit 6c9d049
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/src/main/js/reducers/rants.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ function breakDownRants(prevRants, newRants) {
return ([column0, column1]);
}

function filterDuplicate(orants, newRants) {
const ids = [];
orants.map(rs => rs.map(r => ids.push(r.id)));
return newRants.filter(rant => ids.indexOf(rant.id) === -1);
}

export default function rants(state = DEFAULT_STATE, action) {
switch (action.type) {
case FETCH_RANTS:
Expand All @@ -116,7 +122,9 @@ export default function rants(state = DEFAULT_STATE, action) {
case STATE.SUCCESS: {
return {
...state,
currentRants: breakDownRants(state.currentRants, action.payload),
currentRants: breakDownRants(
state.currentRants, filterDuplicate(state.currentRants, action.payload),
),
state: action.state,
feedType: action.feedType,
page: state.page + 1,
Expand Down

0 comments on commit 6c9d049

Please sign in to comment.