 getFavoritesName = require './get-favorites-name'
 alert = require '../lib/alert'
 SignInPrompt = require '../partials/sign-in-prompt'
-PromiseRenderer = require '../components/promise-renderer'
 
 module.exports = React.createClass
   displayName: 'CollectionFavoritesButton'

      favorites.get('subjects', id: @props.subject.id)
        .then ([subject]) -> subject?
    else
      Promise.resolve(false)

  componentWillMount: ->
    # see if the subject is in the project's favorites collection
    # to see if it's favorites
    favoritesPromise = @findFavoriteCollection()
    favoritedPromise = favoritesPromise.then (favs) => @findSubjectInCollection(favs)

    @setState {favoritesPromise, favoritedPromise}

  addSubjectTo: (collection) ->
    collection.addLink('subjects', [@props.subject.id.toString()])
      .then (collection) => @setState favoritedPromise: Promise.resolve(true)

  removeSubjectFrom: (collection) ->
    collection.removeLink('subjects', [@props.subject.id.toString()])
      .then (collection) => @setState favoritedPromise: Promise.resolve(false)

  createFavorites: ->
    display_name = getFavoritesName(@props.project)

    user: null

  getInitialState: ->
    favorites: null
    favorited: false

  contextTypes:
    geordi: React.PropTypes.object 

  logSubjLike: (liked) ->
    @context.geordi?.logEvent
