 
     _queryRef = 0
     _nextUrl = null
+    _currentUrl = null
     _noMore = false
 
     _currentMessages = Immutable.OrderedMap()


        sequence = _messagesWithInFlights()
        sequence = sequence.filter inMailbox mailboxID

        if _filterType is 'flag'
            sequence = sequence.filter _matchFlag

        else if _filterType is 'date'
            sequence = sequence.filter _matchRangeDate

        # We dont filter for _filterType from and dest because it is
        # complicated by collation and name vs address.

        after: _filterAfter
        hasNextPage: not _noMore

    getCurrentURL: ->
        mailboxID = AccountStore.getSelectedMailbox().get 'id'
        sort = if _filterType in ['from', 'dest']
            encodeURIComponent "+#{_filterType}"
        else
            encodeURIComponent "#{_sortOrder}#{_sortField}"

        url = "mailbox/#{mailboxID}/?sort=#{sort}"
        if _filterType is 'flag' and _filterValue isnt '-'
            url += "&flag=#{_filterValue}"

        if _filterBefore isnt '-'
            url += "&before=#{encodeURIComponent _filterBefore}"

        if _filterAfter isnt '-'
            url += "&after=#{encodeURIComponent _filterAfter}"
        return url

    getNextUrl: ->
        if _nextUrl
            return _nextUrl
        else if _noMore or _currentUrl is (url = @getCurrentURL())
            return null
        else
            _currentUrl = url
            return url


