   channelThreads
   selectedChannel
   (threads, channel) ->
-    return immutable.Map()  unless channel
+    return null  unless channel
     thread = threads.get channel.get('id')
     return thread.set 'channel', channel
 ]

  MessagesStore
  (threads, messages) ->
    threads.map (thread) ->
      # replace messageIds in list with message instances.

      messages = thread.get('messages').map (messageId) ->

        message = messages.get messageId
        if message.has('__editedBody')
          message = message.set 'body', message.get '__editedBody'
          message = message.set 'payload', message.get '__editedPayload'

        return message

      thread.set 'messages', messages
]

channelPopularMessages = [

selectedChannelThreadMessages = [
  selectedChannelThread
  (thread) ->
    return null  unless thread
    thread.get 'messages'
]

selectedChannelPopularMessages = [
  channelPopularMessages
  selectedChannelThreadId
