$ = jQuery
context = window
logger = context.JK.logger
rest = context.JK.Rest()
FriendActions = @FriendActions

@FriendStore = Reflux.createStore(
  {
    listenables: FriendActions

    friends: []

    init: ->
      # Register with the app store to get @app
      this.listenTo(context.AppStore, this.onAppInit)

    onAppInit: (@app) ->
      return

    updateFriends: (friends) ->
      @friends = friends

    issueChange: (type) ->
      @trigger({friends: @friends})

    isFriend: (userId) ->

      found = false
      for friend in @friends
        if friend.id == userId
          found = true
          break
      found
  }
)