2014-01-03 13:32:13 -05:00
|
|
|
View = require 'views/kinds/RootView'
|
|
|
|
template = require 'templates/account/profile'
|
|
|
|
User = require 'models/User'
|
|
|
|
|
|
|
|
module.exports = class ProfileView extends View
|
|
|
|
id: "profile-view"
|
|
|
|
template: template
|
|
|
|
loading: true
|
|
|
|
|
|
|
|
constructor: (options, @userID) ->
|
|
|
|
super options
|
|
|
|
@user = User.getByID(@userID)
|
|
|
|
@loading = false if 'gravatarProfile' of @user
|
2014-03-24 02:53:41 -04:00
|
|
|
@listenTo(@user, 'change', @userChanged)
|
|
|
|
@listenTo(@user, 'error', @userError)
|
2014-01-03 13:32:13 -05:00
|
|
|
|
2014-03-24 02:53:41 -04:00
|
|
|
userChanged: (user) ->
|
2014-01-03 13:32:13 -05:00
|
|
|
@loading = false if 'gravatarProfile' of user
|
|
|
|
@render()
|
|
|
|
|
2014-03-24 02:53:41 -04:00
|
|
|
userError: (user) ->
|
2014-01-03 13:32:13 -05:00
|
|
|
@loading = false
|
|
|
|
@render()
|
|
|
|
|
|
|
|
getRenderData: ->
|
|
|
|
context = super()
|
|
|
|
grav = @user.gravatarProfile
|
|
|
|
grav = grav.entry[0] if grav
|
|
|
|
addedContext =
|
|
|
|
user: @user
|
|
|
|
loading: @loading
|
|
|
|
myProfile: @user.id is context.me.id
|
|
|
|
grav: grav
|
|
|
|
photoURL: @user.getPhotoURL()
|
|
|
|
context[key] = addedContext[key] for key of addedContext
|
|
|
|
context
|