-kd              = require 'kd'
-AppFlux         = require 'app/flux'
-actions         = require '../actiontypes'
-isPublicChannel = require 'app/util/isPublicChannel'
+kd                   = require 'kd'
+AppFlux              = require 'app/flux'
+whoami               = require 'app/util/whoami'
+actions              = require '../actiontypes'
+isPublicChannel      = require 'app/util/isPublicChannel'
+desktopNotifications = require './desktopnotifications'
 
 dispatch = (args...) -> kd.singletons.reactor.dispatch args...
 

  kd.singletons.socialapi.onChannelReady channel, ->

    channel.on 'MessageAdded', (message) ->
      bindMessageEvents message

      _channel = kd.singletons.socialapi.retrieveCachedItemById message.initialChannelId


  kd.singletons.notificationController
    .on 'MessageAddedToChannel', (payload) ->

      { channel : { id, name }, channelMessage, unreadCount } = payload
      if _isChannelInitiationEvent payload.channelMessage
        { addedBy } = channelMessage.payload

        desktopNotifications.postAddedToChannelNotification name, addedBy

      # TODO: FIXME
      # The reason we are doing these extra fetches is that right now backend
