MCPcopy Create free account
hub / github.com/codecombat/codecombat / onLoaded

Method onLoaded

app/views/artisans/BlockTestingView.js:59–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 }
58
59 onLoaded () {
60 super.onLoaded()
61 if (this.campaignsCollection) {
62 this.campaigns = this.campaignsCollection.models.map(m => m.attributes)
63 storage.load('blockly-test-campaigns', this.campaigns, 24 * 60)
64 }
65
66 const levelSlugsSet = new Set()
67 this.levelSlugs = []
68 this.levels = []
69 this.levelsToLoadRemaining = 0
70 for (const campaign of this.campaigns || []) {
71 if (levelTestsAdded) { break }
72 if (['auditions', 'web-dev-1', 'web-dev-2', 'js-primer', 'js-primer-playtest', 'web-dev-1', 'web-dev-2', 'campaign-web-dev-1', 'campaign-web-dev-2'].includes(campaign.slug)) { continue }
73 if (this.focusCampaign && campaign.slug !== this.focusCampaign) { continue }
74 for (const levelInfo of _.values(campaign.levels)) {
75 const levelSlug = levelInfo.slug
76 if (levelSlugsSet.has(levelSlug)) { continue }
77 levelSlugsSet.add(levelSlug)
78 this.levelSlugs.push(levelSlug)
79 let level = storage.load(`blockly-test-level_${levelSlug}`)
80 if (!level) {
81 console.log(`Initial load to localStorage of level ${levelSlug}`)
82 level = new Level({ _id: levelSlug })
83 level.project = ['slug', 'thangs']
84 ++this.levelsToLoadRemaining
85 this.levels.push(level)
86 this.listenToOnce(this.supermodel.loadModel(level).model, 'sync', this.onLevelLoaded)
87 } else {
88 this.levels.push(level)
89 }
90 }
91 }
92 if (this.levelsToLoadRemaining === 0) {
93 this.onAllLevelsLoaded()
94 }
95 }
96
97 levelToCode (level) {
98 const result = {

Callers 1

constructorMethod · 0.95

Calls 3

onAllLevelsLoadedMethod · 0.95
logMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected