From 30b102ff7f228f6bc5aad17bc23009e5b96090f7 Mon Sep 17 00:00:00 2001 From: Big Bad Waffle Date: Sat, 25 Feb 2017 10:04:43 +0200 Subject: [PATCH] Fixes #80 --- src/client/js/components/spellbook.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/js/components/spellbook.js b/src/client/js/components/spellbook.js index 080e9548..3c863d15 100644 --- a/src/client/js/components/spellbook.js +++ b/src/client/js/components/spellbook.js @@ -72,10 +72,14 @@ define([ if (blueprint.getSpells) { blueprint.getSpells.forEach(function(s) { - if (this.spells.find(function(spell) { + var existIndex = this.spells.firstIndex(function(spell) { return (spell.id == s.id); - })) + }); + + if (existIndex > -1) { + this.spells.splice(existIndex, 1, s); return; + } if (this.spells.length - 1 >= s.id) this.spells.splice(s.id, 0, s);