Skip to content

Commit cb1473f

Browse files
committed
Prevent same doc from being enabled twice
Fixes freeCodeCamp#301.
1 parent 37454b1 commit cb1473f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

assets/javascripts/app/app.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
return
101101

102102
enableDoc: (doc, _onSuccess, onError) ->
103+
return if @docs.contains(doc)
103104
onSuccess = =>
104105
@disabledDocs.remove(doc)
105106
@docs.add(doc)

assets/javascripts/collections/collection.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class app.Collection
3838
all: ->
3939
@models
4040

41+
contains: (model) ->
42+
@models.indexOf(model) >= 0
43+
4144
findBy: (attr, value) ->
4245
for model in @models
4346
return model if model[attr] is value

0 commit comments

Comments
 (0)