Skip to content

Commit fa8753f

Browse files
committed
filtering cards that are already available when adding new cards as this will lead to a react error
1 parent 7657777 commit fa8753f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/helpers/LaneHelper.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ const LaneHelper = {
1717
},
1818

1919
appendCardsToLane: (state, {laneId, newCards, index}) => {
20-
newCards = newCards.map(c => update(c, {laneId: {$set: laneId}}))
20+
const lane = state.lanes.find(lane => lane.id === laneId)
21+
newCards = newCards
22+
.map(c => update(c, {laneId: {$set: laneId}}))
23+
.filter(c => lane.cards.find(card => card.id === c.id) == null)
2124
return state.lanes.map(lane => {
2225
if (lane.id === laneId) {
2326
if (index !== undefined) {
2427
return update(lane, {cards: {$splice: [[index, 0, ...newCards]]}})
2528
} else {
26-
const cardsToUpdate = [...lane.cards, ...newCards]
27-
return update(lane, {cards: {$set: cardsToUpdate}})
29+
const cardsToUpdate = [...lane.cards, ...newCards]
30+
return update(lane, {cards: {$set: cardsToUpdate}})
2831
}
2932
} else {
3033
return lane

0 commit comments

Comments
 (0)