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

Method onNextGamePressed

app/views/play/SpectateView.js:417–440  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

415 }
416
417 onNextGamePressed (e) {
418 return this.fetchRandomSessionPair((err, data) => {
419 const leagueID = utils.getQueryVariable('league')
420 if (this.destroyed) { return }
421 if (err) { return console.log(`There was an error fetching the random session pair: ${data}`) }
422 this.setSessions(data[0]._id, data[1]._id)
423 let url = `/play/spectate/${this.levelID}?session-one=${this.sessionOne}&session-two=${this.sessionTwo}`
424 if (leagueID) {
425 url += '&league=' + leagueID
426 }
427 Backbone.Mediator.publish('router:navigate', {
428 route: url,
429 viewClass: SpectateLevelView,
430 viewArgs: [
431 {
432 spectateSessions: { sessionOne: this.sessionOne, sessionTwo: this.sessionTwo },
433 supermodel: this.supermodel
434 },
435 this.levelID
436 ]
437 })
438 return __guardMethod__(history, 'pushState', o => o.pushState({}, '', url))
439 }) // Backbone won't update the URL if just query parameters change
440 }
441
442 fetchRandomSessionPair (cb) {
443 const leagueID = utils.getQueryVariable('league')

Callers

nothing calls this directly

Calls 5

setSessionsMethod · 0.95
logMethod · 0.80
publishMethod · 0.80
__guardMethod__Function · 0.70

Tested by

no test coverage detected