 
 AccountStore  = require '../stores/account_store'
 LayoutStore   = require '../stores/layout_store'
+MessageStore  = require '../stores/message_store'
 
 AppDispatcher = require '../app_dispatcher'
 

        if not selectedAccount? or selectedAccount.get('id') isnt accountID
            AccountActionCreator.selectAccount accountID

        query = {}
        ['sort', 'after', 'before', 'flag', 'pageAfter'].forEach (param) ->
            value = panelInfo.parameters[param]
            if value? and value isnt ''
                query[param] = value

        XHRUtils.fetchMessagesByFolder mailboxID, query, (err, rawMessages) ->
            if err?
                LayoutActionCreator.alertError err
            else
                MessageActionCreator.receiveRawMessages rawMessages

    showMessage: (panelInfo, direction) ->
        LayoutActionCreator.hideReponsiveMenu()
        messageID = panelInfo.parameters.messageID
        XHRUtils.fetchMessage messageID, (err, rawMessage) ->

            if err?
                LayoutActionCreator.alertError err
            else
                MessageActionCreator.receiveRawMessage rawMessage
                # if there isn't a selected account (page loaded directly),
                # select the message's account
                selectedAccount = AccountStore.getSelected()
                if  not selectedAccount? and rawMessage?.mailbox
                    AccountActionCreator.selectAccount rawMessage.mailbox

    showConversation: (panelInfo, direction) ->
        LayoutActionCreator.hideReponsiveMenu()

AccountActionCreator = require './account_action_creator'
MessageActionCreator = require './message_action_creator'
SearchActionCreator = require './search_action_creator'

_cachedQuery = {}

module.exports = LayoutActionCreator =

