No longer constructing SpellViews for non-readable methods.

This commit is contained in:
Nick Winter 2014-08-24 21:52:33 -07:00
parent 718d586f07
commit 08f2ee248b
3 changed files with 8 additions and 7 deletions
app
models
views/play/level/tome

View file

@ -111,7 +111,7 @@ module.exports = class Level extends CocoModel
visit = (c) ->
return if c in sorted
lc = _.find levelComponents, {original: c.original}
#console.error thang.id or thang.name, 'couldn\'t find lc for', c, 'of', levelComponents unless lc # STREAM: uncomment
console.error thang.id or thang.name, 'couldn\'t find lc for', c, 'of', levelComponents unless lc
return unless lc
if lc.name is 'Programmable'
# Programmable always comes last

View file

@ -40,19 +40,17 @@ module.exports = class Spell
if @permissions.readwrite.length and sessionSource = @session.getSourceFor(@spellKey)
@source = sessionSource
@thangs = {}
if true # @canRead() # Surely we could avoid creating these if we'll never use them? TODO
if @canRead() # We can avoid creating these views if we'll never use them.
@view = new SpellView {spell: @, session: @session, worker: @worker}
@view.render() # Get it ready and code loaded in advance
@tabView = new SpellListTabEntryView spell: @, supermodel: @supermodel, language: @language
@tabView.render()
#else
# @spell.loaded = true
@team = @permissions.readwrite[0] ? 'common'
Backbone.Mediator.publish 'tome:spell-created', spell: @
destroy: ->
@view.destroy()
@tabView.destroy()
@view?.destroy()
@tabView?.destroy()
@thangs = null
@worker = null
@ -75,7 +73,7 @@ module.exports = class Spell
(team ? me.team) in @permissions.readwrite
getSource: ->
@view.getSource()
@view?.getSource() ? @source
transpile: (source) ->
if source

View file

@ -142,6 +142,9 @@ module.exports = class TomeView extends CocoView
else
delete @thangSpells[thangID]
spell.removeThangID thangID for spell in @spells
for spellKey, spell of @spells when not spell.canRead() # Make sure these get transpiled (they have no views).
spell.transpile()
spell.loaded = true
null
onSpellLoaded: (e) ->