Fixed a bug with the new race condition fix. Moving the schemas to the application would be good.

This commit is contained in:
Scott Erickson 2014-03-08 13:52:34 -08:00
parent ad6317434d
commit afbe2200a6
2 changed files with 4 additions and 4 deletions

View file

@ -16,6 +16,7 @@ class CocoModel extends Backbone.Model
initialize: -> initialize: ->
super() super()
@constructor.schema ?= new CocoSchema(@urlRoot)
if not @constructor.className if not @constructor.className
console.error("#{@} needs a className set.") console.error("#{@} needs a className set.")
@markToRevert() @markToRevert()
@ -52,10 +53,8 @@ class CocoModel extends Backbone.Model
@backedUp = {} @backedUp = {}
loadSchema: -> loadSchema: ->
unless @constructor.schema return if @constructor.schema.loading
@constructor.schema = new CocoSchema(@urlRoot) @constructor.schema.fetch()
@constructor.schema.fetch()
@constructor.schema.once 'sync', => @constructor.schema.once 'sync', =>
@constructor.schema.loaded = true @constructor.schema.loaded = true
@addSchemaDefaults() @addSchemaDefaults()

View file

@ -42,6 +42,7 @@ module.exports = class ThangTypeEditView extends View
@thangType = new ThangType(_id: @thangTypeID) @thangType = new ThangType(_id: @thangTypeID)
@thangType.saveBackups = true @thangType.saveBackups = true
@thangType.fetch() @thangType.fetch()
@thangType.loadSchema()
@thangType.schema().once 'sync', @onThangTypeSync, @ @thangType.schema().once 'sync', @onThangTypeSync, @
@thangType.once 'sync', @onThangTypeSync, @ @thangType.once 'sync', @onThangTypeSync, @
@refreshAnimation = _.debounce @refreshAnimation, 500 @refreshAnimation = _.debounce @refreshAnimation, 500