2014-07-15 10:15:21 -04:00
|
|
|
View = require 'views/kinds/RootView'
|
2014-11-25 13:19:38 -05:00
|
|
|
template = require 'templates/account/main-account-view'
|
2014-07-15 10:15:21 -04:00
|
|
|
{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-11-25 13:19:38 -05:00
|
|
|
id: 'main-account-view'
|
2014-07-15 10:15:21 -04:00
|
|
|
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 = {}
|
2014-08-12 07:41:14 -04:00
|
|
|
enabledEmails = c.me.getEnabledEmails()
|
|
|
|
c.subs[sub] = 1 for sub in enabledEmails
|
|
|
|
c.hasEmailNotes = _.any enabledEmails, (sub) -> sub.contains 'Notes'
|
|
|
|
c.hasEmailNews = _.any enabledEmails, (sub) -> sub.contains('News') and sub isnt 'generalNews'
|
|
|
|
c.hasGeneralNews = 'generalNews' in enabledEmails
|
2014-08-07 16:03:00 -04:00
|
|
|
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()
|