diff --git a/src/app/character.coffee b/src/app/character.coffee index 2f97987d49..5ef7f08005 100644 --- a/src/app/character.coffee +++ b/src/app/character.coffee @@ -7,17 +7,19 @@ _ = require 'underscore' lodash = require 'lodash' derby = require 'derby' +module.exports.username = username = (auth) -> + if auth?.facebook?.displayName? + auth.facebook.displayName + else if auth?.facebook? + fb = auth.facebook + if fb._raw then "#{fb.name.givenName} #{fb.name.familyName}" else fb.name + else if auth?.local? + auth.local.username + else + 'Anonymous' + module.exports.view = (view) -> - view.fn "username", (auth) -> - if auth?.facebook?.displayName? - auth.facebook.displayName - else if auth?.facebook? - fb = auth.facebook - if fb._raw then "#{fb.name.givenName} #{fb.name.familyName}" else fb.name - else if auth?.local? - auth.local.username - else - 'Anonymous' + view.fn "username", (auth) -> username(auth) module.exports.app = (appExports, model) -> user = model.at '_user' diff --git a/src/app/profile.coffee b/src/app/profile.coffee index 68fa0a4bac..d2b78d0aea 100644 --- a/src/app/profile.coffee +++ b/src/app/profile.coffee @@ -1,3 +1,5 @@ +character = require './character' + module.exports.app = (appExports, model) -> user = model.at('_user') @@ -19,4 +21,5 @@ module.exports.app = (appExports, model) -> uid = $(el).attr('data-uid') model.ref '_profileActive', model.at("users.#{uid}") model.set '_profileActiveMain', model.get('_user.id') == uid + model.set '_profileActiveUsername', character.username model.get('_profileActive.auth') diff --git a/views/app/avatar.html b/views/app/avatar.html index 192ab080de..97ab4b549b 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -1,5 +1,5 @@ - + {#if _profileActiveMain} {#with _user.preferences}