mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Add browser info to level session
This commit is contained in:
parent
848341dbd1
commit
a092444455
3 changed files with 15 additions and 1 deletions
|
@ -98,6 +98,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
if e.id is modulePath
|
||||
@languageModuleResource.markLoaded()
|
||||
@stopListening application.moduleLoader
|
||||
@addSessionBrowserInfo session
|
||||
|
||||
# hero-ladder games require the correct session team in level:loaded
|
||||
team = @team ? @session.get('team')
|
||||
|
@ -134,6 +135,16 @@ module.exports = class LevelLoader extends CocoClass
|
|||
if _.size(@sessionDependenciesRegistered) is 2 and @checkAllWorldNecessitiesRegisteredAndLoaded()
|
||||
@onWorldNecessitiesLoaded()
|
||||
|
||||
addSessionBrowserInfo: (session) ->
|
||||
return unless $.browser?
|
||||
browser = {}
|
||||
browser['desktop'] = $.browser.desktop if $.browser.desktop
|
||||
browser['name'] = $.browser.name if $.browser.name
|
||||
browser['platform'] = $.browser.platform if $.browser.platform
|
||||
browser['version'] = $.browser.version if $.browser.version
|
||||
session.set 'browser', browser
|
||||
session.patch()
|
||||
|
||||
consolidateFlagHistory: ->
|
||||
state = @session.get('state') ? {}
|
||||
myFlagHistory = _.filter state.flagHistory ? [], team: @session.get('team')
|
||||
|
|
|
@ -29,6 +29,8 @@ LevelSessionSchema = c.object
|
|||
|
||||
_.extend LevelSessionSchema.properties,
|
||||
# denormalization
|
||||
browser:
|
||||
type: 'object'
|
||||
creatorName:
|
||||
type: 'string'
|
||||
levelName:
|
||||
|
|
|
@ -65,7 +65,8 @@ LevelSessionSchema.statics.privateProperties = ['code', 'submittedCode', 'unsubs
|
|||
LevelSessionSchema.statics.editableProperties = ['multiplayer', 'players', 'code', 'codeLanguage', 'completed', 'state',
|
||||
'levelName', 'creatorName', 'levelID', 'screenshot',
|
||||
'chat', 'teamSpells', 'submitted', 'submittedCodeLanguage',
|
||||
'unsubscribed', 'playtime', 'heroConfig', 'team', 'transpiledCode']
|
||||
'unsubscribed', 'playtime', 'heroConfig', 'team', 'transpiledCode',
|
||||
'browser']
|
||||
LevelSessionSchema.statics.jsonSchema = jsonschema
|
||||
|
||||
module.exports = LevelSession = mongoose.model('level.session', LevelSessionSchema, 'level.sessions')
|
||||
|
|
Loading…
Reference in a new issue