 JView = require '../../jview'
 LinkView = require '../linkviews/linkview'
 isKoding = require '../../util/isKoding'
-
+TeamFlux = require 'app/flux/teams'
 
 module.exports = class AvatarView extends LinkView
 


  pistachio: ->
    '''
    {{> @gravatar}}
    {{> @cite}}
    '''


    kd.getSingleton('groupsController').ready =>

      { _id } = @getData()

      nickname = profile?.nickname

      options =
        limit : 10
        sort  : { timestamp: -1 } # timestamp is at relationship collection
        skip  : 0
      TeamFlux.actions.fetchMembers(options).then =>
        TeamFlux.actions.fetchMembersRole().then =>

          { reactor } = kd.singletons

          teamMemberRoles = reactor.evaluate ['TeamMembersRoleStore']
          myRole = teamMemberRoles.toJS()[_id]

          myRole = 'member' unless myRole
          cssClass = "badge #{myRole}"

          @badge.setClass cssClass
          @badge.setAttribute 'title', myRole

      href = if payload?.channelIntegrationId
        "/Admin/Integrations/Configure/#{payload.channelIntegrationId}"
