mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
Fix sidebar when an account doesn't have a standard category
This commit is contained in:
parent
e29335ae91
commit
a77c9548d1
1 changed files with 9 additions and 3 deletions
|
@ -27,8 +27,12 @@ class SidebarSection
|
||||||
}
|
}
|
||||||
|
|
||||||
@standardSectionForAccount: (account) ->
|
@standardSectionForAccount: (account) ->
|
||||||
return @empty('Mailboxes') if CategoryStore.categories().length is 0
|
if not account
|
||||||
|
throw new Error("standardSectionForAccount: You must pass an account.")
|
||||||
|
|
||||||
cats = CategoryStore.standardCategories(account)
|
cats = CategoryStore.standardCategories(account)
|
||||||
|
return @empty('Mailboxes') if cats.length is 0
|
||||||
|
|
||||||
items = _
|
items = _
|
||||||
.reject(cats, (cat) -> cat.name is 'drafts')
|
.reject(cats, (cat) -> cat.name is 'drafts')
|
||||||
.map (cat) => SidebarItem.forCategories([cat])
|
.map (cat) => SidebarItem.forCategories([cat])
|
||||||
|
@ -63,11 +67,13 @@ class SidebarSection
|
||||||
categories = CategoryStore.getStandardCategories(accounts, names...)
|
categories = CategoryStore.getStandardCategories(accounts, names...)
|
||||||
continue if categories.length is 0
|
continue if categories.length is 0
|
||||||
|
|
||||||
children = accounts.map (acc) ->
|
children = []
|
||||||
|
accounts.forEach (acc) ->
|
||||||
cat = _.first(_.compact(
|
cat = _.first(_.compact(
|
||||||
names.map((name) -> CategoryStore.getStandardCategory(acc, name))
|
names.map((name) -> CategoryStore.getStandardCategory(acc, name))
|
||||||
))
|
))
|
||||||
SidebarItem.forCategories([cat], name: acc.label)
|
return unless cat
|
||||||
|
children.push(SidebarItem.forCategories([cat], name: acc.label))
|
||||||
|
|
||||||
items.push SidebarItem.forCategories(categories, {children})
|
items.push SidebarItem.forCategories(categories, {children})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue