fix(labels): Allow user to label as spam or trash from the dropdown

Also fixes the sort ordering of standard labels in the category picker. Fixes #555
This commit is contained in:
Ben Gotow 2015-12-02 11:43:37 -08:00
parent f95a5a3548
commit bc839fb541
2 changed files with 17 additions and 15 deletions

View file

@ -252,9 +252,12 @@ class CategoryPicker extends React.Component
@_account = AccountStore.current()
return unless @_account
categories = CategoryStore.getStandardCategories()
.concat([{divider: true, id: "category-divider"}])
.concat(CategoryStore.getUserCategories())
if @_account.usesLabels()
categories = CategoryStore.getCategories()
else
categories = CategoryStore.getStandardCategories()
.concat([{divider: true, id: "category-divider"}])
.concat(CategoryStore.getUserCategories())
usageCount = @_categoryUsageCount(props, categories)
@ -292,9 +295,8 @@ class CategoryPicker extends React.Component
currentCategoryId = FocusedMailViewStore.mailView()?.categoryId()
if @_account?.usesLabels()
hiddenCategories = ["all", "spam", "trash", "drafts", "sent"]
if allInInbox
hiddenCategories.push("inbox")
hiddenCategories = ["all", "drafts", "sent", "archive", "starred", "important"]
hiddenCategories.push("inbox") if allInInbox
return false if category.divider
else if @_account?.usesFolders()
hiddenCategories = ["drafts", "sent"]

View file

@ -144,13 +144,7 @@ class CategoryStore extends NylasStore
return unless categoryClass
DatabaseStore.findAll(categoryClass).where(categoryClass.attributes.accountId.equal(account.id)).then (categories=[]) =>
@_categoryCache = {}
@_categoryCache[category.id] = category for category in categories
# Compute user categories
userCategories = _.reject _.values(@_categoryCache), (cat) =>
cat.name in @StandardCategoryNames or cat.name in @HiddenCategoryNames
userCategories = userCategories.sort (catA, catB) =>
categories = categories.sort (catA, catB) ->
nameA = catA.displayName
nameB = catB.displayName
@ -161,10 +155,16 @@ class CategoryStore extends NylasStore
nameA.localeCompare(nameB)
@_userCategories = _.compact(userCategories)
@_categoryCache = {}
for category in categories
@_categoryCache[category.id] = category
# Compute user categories
@_userCategories = _.compact _.reject categories, (cat) =>
cat.name in @StandardCategoryNames or cat.name in @HiddenCategoryNames
# Compute hidden categories
@_hiddenCategories = _.filter _.values(@_categoryCache), (cat) =>
@_hiddenCategories = _.filter categories, (cat) =>
cat.name in @HiddenCategoryNames
# Compute standard categories