 immutable                  = require 'immutable'
 isPublicChatChannel        = require 'activity/util/isPublicChatChannel'
 whoami                     = require 'app/util/whoami'
+isPublicChannel            = require 'app/util/isPublicChannel'
 calculateListSelectedIndex = require 'activity/util/calculateListSelectedIndex'
 getListSelectedItem        = require 'activity/util/getListSelectedItem'
 

# Following will be transformations of the store datas for other parts (mainly
# visual components) to use.

# Maps followed public channel ids with relevant channel instances.
followedPublicChannels = [
  FollowedPublicChannelIdsStore
  allChannels
  (ids, channels) -> ids.map (id) -> channels.get id
]

# Maps followed private channel ids with relevant channel instances.
followedPrivateChannels = [
  FollowedPrivateChannelIdsStore

  allChannels
  selectedChannelThreadId
  (channels, id) -> if id then channels.get id else null
]

# Maps followed public channel ids with relevant channel instances.
followedPublicChannels = [
  FollowedPublicChannelIdsStore
  selectedChannel
  allChannels
  (ids, channel, channels) ->
    if channel
      channelId = channel.get 'id'
      ids = ids.set channelId, channelId  if isPublicChannel(channel.toJS())
    ids.map (id) -> channels.get id
]

# Returns the selected thread mapped with selected channel instance.
