mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-06 20:54:26 +08:00
feat(tags): Draft counts num drafts. Remove trash. Remove important
Summary: The Drafts tag now displays the total number of local drafts instead of the number of unread drafts from the server. The Trash label has been removed since there's no way in the UI to add or remove stuff from there. The Important label has been removed since it's a poorly understood Gmail-specific feature and there's no way in the UI to add or remove things from that label. There is no Starred label because there's no UI to indicate whther or not something is starred and no UI interface to add or remove from stars. Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1296
This commit is contained in:
parent
02439f3a28
commit
5a948a7222
3 changed files with 41 additions and 14 deletions
|
@ -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,24 +68,34 @@ 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
|
||||
|
||||
_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,
|
||||
# we debounce aggressively and update only after changes have stopped.
|
||||
# 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 =>
|
||||
|
|
Loading…
Add table
Reference in a new issue