Fix display of labels vs. folders in the sidebar

This commit is contained in:
Ben Gotow 2017-06-28 23:01:45 -07:00
parent 73b7fe5553
commit f7f345baf9
7 changed files with 15 additions and 20 deletions

View file

@ -3,6 +3,7 @@ _ = require 'underscore'
SyncbackCategoryTask,
DestroyCategoryTask,
CategoryStore,
Label,
Category,
ExtensionRegistry,
RegExpUtils} = require 'nylas-exports'
@ -165,21 +166,27 @@ class SidebarSection
items.push(item)
seenItems[itemKey] = item
title ?= account.categoryLabel()
CategoryClass = CategoryStore.getInboxCategory(account).constructor
iconName = null
if CategoryClass == Label
title ?= "Labels"
iconName = "tag.png"
else
title ?= "Folders"
iconName = "folder.png"
collapsed = isSectionCollapsed(title)
if collapsible
onCollapseToggled = toggleSectionCollapsed
return {
title: title
iconName: account.categoryIcon()
iconName: iconName
items: items
collapsed: collapsed
onCollapseToggled: onCollapseToggled
onItemCreated: (displayName) ->
return unless displayName
category = new Category
category = new CategoryClass
displayName: displayName
accountId: account.id
Actions.queueTask(new SyncbackCategoryTask({category}))

View file

@ -117,7 +117,7 @@ class SidebarStore extends NylasStore
if multiAccount
opts.title = acc.label
opts.collapsible = true
SidebarSection.forUserCategories(acc, opts)
return SidebarSection.forUserCategories(acc, opts)
@trigger()

View file

@ -14,12 +14,10 @@ describe('MailboxPerspective', function mailboxPerspective() {
a1: {
id: 'a1',
preferredRemovalDestination: () => ({displayName: 'archive'}),
categoryIcon: () => null,
},
a2: {
id: 'a2',
preferredRemovalDestination: () => ({displayName: 'trash2'}),
categoryIcon: () => null,
},
}
this.perspective = new MailboxPerspective(this.accountIds)

View file

@ -119,14 +119,6 @@ export default class Account extends ModelWithMetadata {
return this.me()
}
categoryLabel() {
return 'Unknown';
}
categoryIcon() {
return 'bla.png'
}
// Public: Returns the localized, properly capitalized provider name,
// like Gmail, Exchange, or Outlook 365
displayProvider() {

View file

@ -253,12 +253,10 @@ class CategoryMailboxPerspective extends MailboxPerspective
# Note: We pick the display name and icon assuming that you won't create a
# perspective with Inbox and Sent or anything crazy like that... todo?
@name = @_categories[0].displayName
if @_categories[0].name
@iconName = "#{@_categories[0].name}.png"
if @_categories[0].role
@iconName = "#{@_categories[0].role}.png"
else
account = AccountStore.accountForId(@accountIds[0])
@iconName = "folder.png"
@iconName = account.categoryIcon() if account
@iconName = if @_categories[0] instanceof Label then "label.png" else "folder.png"
@
toJSON: =>

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B