diff --git a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee index 56f51ff1a..f07021ae9 100644 --- a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee +++ b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee @@ -1,6 +1,6 @@ Reflux = require 'reflux' _ = require 'underscore-plus' -{DatabaseStore, NamespaceStore, Actions, Tag, Thread} = require 'inbox-exports' +{DatabaseStore, NamespaceStore, Actions, Tag, Message, Thread} = require 'inbox-exports' AccountSidebarStore = Reflux.createStore init: -> @@ -8,6 +8,11 @@ AccountSidebarStore = Reflux.createStore @_registerListeners() @_populate() + # Keep a cache of unread counts since requesting the number from the + # server is a fairly expensive operation. + @_unreadCountCache = {} + @localDraftsTag = new Tag({id: "drafts", name: "Local Drafts"}) + ########### PUBLIC ##################################################### @@ -35,8 +40,16 @@ AccountSidebarStore = Reflux.createStore DatabaseStore.findAll(Tag, namespaceId: namespace.id).then (tags) => # Collect the built-in tags we want to display, and the user tags # (which can be identified by having non-hardcoded IDs) - mainTagIDs = ['inbox', 'important', 'drafts', 'sent', 'archive', 'trash'] + + # We ignore the server drafts so we can use our own localDrafts + tags = _.reject tags, (tag) -> tag.id is "drafts" + tags.push(@localDraftsTag) + + mainTagIDs = ['inbox', 'drafts', 'sent', 'archive'] mainTags = _.filter tags, (tag) -> _.contains(mainTagIDs, tag.id) + + console.log mainTags + userTags = _.filter tags, (tag) -> tag.name != tag.id # Sort the main tags so they always appear in a standard order @@ -55,16 +68,26 @@ AccountSidebarStore = Reflux.createStore namespace = NamespaceStore.current() return unless namespace - @_sections.forEach (section) -> - section.tags.forEach (tag) -> - # Some tags don't have unread counts - return if tag.id in ['archive', 'drafts', 'sent', 'trash'] + @_sections.forEach (section) => + section.tags.forEach (tag) => + if tag.id is "drafts" + @_populateDraftsCount(tag) + else if tag.id in ['drafts', 'sent', 'archive', 'trash'] + return + else + # Make a web request for unread count + atom.inbox.makeRequest + method: 'GET' + path: "/n/#{namespace.id}/tags/#{tag.id}" + returnsModel: true - # Make a web request for unread count - atom.inbox.makeRequest - method: 'GET' - path: "/n/#{namespace.id}/tags/#{tag.id}" - returnsModel: true + _populateDraftsCount: -> + namespace = NamespaceStore.current() + return unless namespace + + DatabaseStore.count(Message, draft: true).then (count) => + @localDraftsTag.unreadCount = count + @trigger(@) # Unfortunately, the joins necessary to compute unread counts are expensive. # Rather than update unread counts every time threads change in the database, @@ -72,7 +95,7 @@ AccountSidebarStore = Reflux.createStore # Remove this when JOIN query speed is fixed! _populateUnreadCountsDebounced: _.debounce -> @_populateUnreadCounts() - , 2000 + , 1000 _refetchFromAPI: -> namespace = NamespaceStore.current() @@ -91,7 +114,10 @@ AccountSidebarStore = Reflux.createStore if change.objectClass == Tag.name @_populate() if change.objectClass == Thread.name + console.log "Thread Changed", change @_populateUnreadCountsDebounced() + if change.objectClass == Message.name + @_populateDraftsCount() _onSelectTagId: (tagId) -> @_selectedId = tagId diff --git a/internal_packages/composer/stylesheets/composer.less b/internal_packages/composer/stylesheets/composer.less index 8bf4214ba..e5d7db488 100644 --- a/internal_packages/composer/stylesheets/composer.less +++ b/internal_packages/composer/stylesheets/composer.less @@ -7,6 +7,7 @@ @import "buttons"; @compose-width: 800px; +@compose-min-height: 250px; .composer-inner-wrap { position: relative; @@ -142,7 +143,7 @@ div[contenteditable] { font-size: @font-size-large; line-height: 1.4; - min-height: 150px; + min-height: @compose-min-height; padding: @spacing-standard; padding-top: @spacing-standard; padding-bottom: 0; diff --git a/internal_packages/message-list/lib/message-list.cjsx b/internal_packages/message-list/lib/message-list.cjsx index 85d096096..65a710e20 100755 --- a/internal_packages/message-list/lib/message-list.cjsx +++ b/internal_packages/message-list/lib/message-list.cjsx @@ -153,7 +153,7 @@ MessageList = React.createClass # of the last message. # # We don't scroll if there's only 1 item. - # We don't screll if you're actively focused somewhere in the message + # We don't scroll if you're actively focused somewhere in the message # list. _scrollToBottom: -> _.defer =>