Skip to content

Commit

Permalink
Empty deck before importing
Browse files Browse the repository at this point in the history
Empties the deck before importing to ensure no extra cards are added
  • Loading branch information
yoganlava committed Jan 17, 2023
1 parent 0436fae commit 564cd0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/ui/models/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ var DeckModel = Backbone.Model.extend({
return changed;
},

emptyDeck: function () {
this.set('cards', []);
this._cardModels.reset();
},

getCountForBaseCardId: function (cardId) {
var count = 0;

Expand Down
1 change: 1 addition & 0 deletions app/ui/views2/collection/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ var DeckLayout = Backbone.Marionette.LayoutView.extend({

// convert card data from base 64 into array of [count:id][count:id]...
val = atob(val);
this.model.emptyDeck();
var cardsData = val.split(',');
var cardIdsToAdd = [];
var phantomCardIdsToAdd = [];
Expand Down

0 comments on commit 564cd0d

Please sign in to comment.