mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
More switching of user objects from save to patch.
This commit is contained in:
parent
4ecbc73c1c
commit
8a728cbb64
6 changed files with 9 additions and 10 deletions
app
|
@ -104,14 +104,14 @@ class CocoModel extends Backbone.Model
|
|||
options.patch = true
|
||||
|
||||
attrs = {_id: @id}
|
||||
anythingChanged = false
|
||||
keys = []
|
||||
for key in _.keys @attributes
|
||||
unless _.isEqual @attributes[key], @_revertAttributes[key]
|
||||
attrs[key] = @attributes[key]
|
||||
anythingChanged = true
|
||||
keys.push key
|
||||
|
||||
return unless anythingChanged
|
||||
console.debug 'Patching', @, attrs
|
||||
return unless keys.length
|
||||
console.debug 'Patching', @get('name') or @, keys
|
||||
@save(attrs, options)
|
||||
|
||||
fetch: ->
|
||||
|
@ -120,7 +120,6 @@ class CocoModel extends Backbone.Model
|
|||
@jqxhr
|
||||
|
||||
markToRevert: ->
|
||||
console.debug "Saving _revertAttributes for #{@constructor.className}: '#{@get('name')}'"
|
||||
if @type() is 'ThangType'
|
||||
@_revertAttributes = _.clone @attributes # No deep clones for these!
|
||||
else
|
||||
|
|
|
@ -79,7 +79,7 @@ module.exports = class EditorConfigModal extends View
|
|||
Backbone.Mediator.publish 'tome:change-config'
|
||||
Backbone.Mediator.publish 'tome:change-language', language: newLanguage unless newLanguage is oldLanguage
|
||||
@session.save() unless newLanguage is oldLanguage
|
||||
me.save()
|
||||
me.patch()
|
||||
|
||||
destroy: ->
|
||||
super()
|
||||
|
|
|
@ -81,7 +81,7 @@ module.exports = class VictoryModal extends View
|
|||
if enough and not me.get('hourOfCodeComplete')
|
||||
$('body').append($("<img src='http://code.org/api/hour/finish_codecombat.png' style='visibility: hidden;'>"))
|
||||
me.set 'hourOfCodeComplete', true
|
||||
me.save()
|
||||
me.patch()
|
||||
window.tracker?.trackEvent 'Hour of Code Finish', {}
|
||||
# Show the "I'm done" button if they get to the end, unless it's been over two hours
|
||||
tooMuch = elapsed >= 120 * 60 * 1000
|
||||
|
|
|
@ -355,7 +355,7 @@ module.exports = class PlaybackView extends View
|
|||
onToggleMusic: (e) ->
|
||||
e?.preventDefault()
|
||||
me.set('music', not me.get('music'))
|
||||
me.save()
|
||||
me.patch()
|
||||
$(document.activeElement).blur()
|
||||
|
||||
destroy: ->
|
||||
|
|
|
@ -97,7 +97,7 @@ module.exports = class CastButtonView extends View
|
|||
return unless delay
|
||||
@autocastDelay = delay = parseInt delay
|
||||
me.set('autocastDelay', delay)
|
||||
me.save()
|
||||
me.patch()
|
||||
spell.view.setAutocastDelay delay for spellKey, spell of @spells
|
||||
@castOptions.find('a').each ->
|
||||
$(@).toggleClass('selected', parseInt($(@).attr('data-delay')) is delay)
|
||||
|
|
|
@ -93,7 +93,7 @@ module.exports = class PlayLevelView extends View
|
|||
|
||||
setUpHourOfCode: ->
|
||||
me.set 'hourOfCode', true
|
||||
me.save()
|
||||
me.patch()
|
||||
$('body').append($("<img src='http://code.org/api/hour/begin_codecombat.png' style='visibility: hidden;'>"))
|
||||
application.tracker?.trackEvent 'Hour of Code Begin', {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue