2014-07-15 10:15:21 -04:00
|
|
|
View = require 'views/kinds/RootView'
|
|
|
|
template = require 'templates/account/home'
|
|
|
|
{me} = require 'lib/auth'
|
|
|
|
User = require 'models/User'
|
2014-07-29 11:28:13 -04:00
|
|
|
AuthModalView = require 'views/modal/AuthModal'
|
2014-07-21 13:06:22 -04:00
|
|
|
RecentlyPlayedCollection = require 'collections/RecentlyPlayedCollection'
|
2014-08-07 16:03:00 -04:00
|
|
|
ThangType = require 'models/ThangType'
|
2014-07-15 10:15:21 -04:00
|
|
|
|
2014-07-21 13:49:16 -04:00
|
|
|
module.exports = class MainAccountView extends View
|
2014-07-15 10:15:21 -04:00
|
|
|
id: 'account-home-view'
|
|
|
|
template: template
|
|
|
|
|
|
|
|
constructor: (options) ->
|
|
|
|
super options
|
|
|
|
return unless me
|
2014-08-07 16:03:00 -04:00
|
|
|
@wizardType = ThangType.loadUniversalWizard()
|
|
|
|
@recentlyPlayed = new RecentlyPlayedCollection me.get('_id')
|
|
|
|
@supermodel.loadModel @wizardType, 'thang'
|
|
|
|
@supermodel.loadCollection @recentlyPlayed, 'recentlyPlayed'
|
|
|
|
|
|
|
|
onLoaded: ->
|
|
|
|
super()
|
2014-07-15 10:15:21 -04:00
|
|
|
|
2014-07-16 06:39:18 -04:00
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
c.subs = {}
|
|
|
|
c.subs[sub] = 1 for sub in c.me.getEnabledEmails()
|
2014-08-07 16:03:00 -04:00
|
|
|
c.hasEmailNotes = _.any c.me.getEnabledEmails(), (sub) -> sub.contains 'Notes'
|
|
|
|
c.hasEmailNews = _.any c.me.getEnabledEmails(), (sub) -> sub.contains 'News'
|
|
|
|
c.wizardSource = @wizardType.getPortraitSource colorConfig: me.get('wizard')?.colorConfig if @wizardType.loaded
|
2014-07-21 13:06:22 -04:00
|
|
|
c.recentlyPlayed = @recentlyPlayed.models
|
2014-07-16 06:39:18 -04:00
|
|
|
c
|
|
|
|
|
2014-07-15 10:15:21 -04:00
|
|
|
afterRender: ->
|
|
|
|
super()
|
2014-08-07 16:03:00 -04:00
|
|
|
@openModalView new AuthModalView if me.isAnonymous()
|