mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
feat(snooze): Add snooze item to sidebar
This commit is contained in:
parent
3125d4d2ff
commit
ce17d8ab1e
|
@ -5,6 +5,7 @@ _str = require 'underscore.string'
|
|||
FocusedPerspectiveStore,
|
||||
SyncbackCategoryTask,
|
||||
DestroyCategoryTask,
|
||||
CategoryStore,
|
||||
Actions,
|
||||
Utils} = require 'nylas-exports'
|
||||
{OutlineViewItem} = require 'nylas-component-kit'
|
||||
|
@ -107,6 +108,19 @@ class SidebarItem
|
|||
opts.contextMenuLabel = contextMenuLabel
|
||||
@forPerspective(id, perspective, opts)
|
||||
|
||||
@forSnoozed: (accountIds, opts = {}) ->
|
||||
# TODO This constant should be available elsewhere
|
||||
displayName = require('../../thread-snooze/lib/snooze-constants').SNOOZE_CATEGORY_NAME
|
||||
id = displayName
|
||||
id += "-#{opts.name}" if opts.name
|
||||
opts.name = "Snoozed" unless opts.name
|
||||
opts.iconName= 'snooze.png'
|
||||
categories = accountIds.map (accId) =>
|
||||
_.findWhere CategoryStore.userCategories(accId), {displayName}
|
||||
|
||||
perspective = MailboxPerspective.forCategories(categories)
|
||||
@forPerspective(id, perspective, opts)
|
||||
|
||||
@forStarred: (accountIds, opts = {}) ->
|
||||
perspective = MailboxPerspective.forStarred(accountIds)
|
||||
id = 'Starred'
|
||||
|
|
|
@ -39,9 +39,10 @@ class SidebarSection
|
|||
|
||||
starredItem = SidebarItem.forStarred([account.id])
|
||||
draftsItem = SidebarItem.forDrafts([account.id])
|
||||
snoozedItem = SidebarItem.forSnoozed([account.id])
|
||||
|
||||
# Order correctly: Inbox, Starred, rest... , Drafts
|
||||
items.splice(1, 0, starredItem)
|
||||
items.splice(1, 0, starredItem, snoozedItem)
|
||||
items.push(draftsItem)
|
||||
|
||||
return {
|
||||
|
@ -77,15 +78,20 @@ class SidebarSection
|
|||
|
||||
items.push SidebarItem.forCategories(categories, {children, editable: false, deletable: false})
|
||||
|
||||
starredItem = SidebarItem.forStarred(_.pluck(accounts, 'id'),
|
||||
accountIds = _.pluck(accounts, 'id')
|
||||
|
||||
starredItem = SidebarItem.forStarred(accountIds,
|
||||
children: accounts.map (acc) -> SidebarItem.forStarred([acc.id], name: acc.label)
|
||||
)
|
||||
draftsItem = SidebarItem.forDrafts(_.pluck(accounts, 'id'),
|
||||
draftsItem = SidebarItem.forDrafts(accountIds,
|
||||
children: accounts.map (acc) -> SidebarItem.forDrafts([acc.id], name: acc.label)
|
||||
)
|
||||
snoozedItem = SidebarItem.forSnoozed(accountIds,
|
||||
children: accounts.map (acc) -> SidebarItem.forSnoozed([acc.id], name: acc.label)
|
||||
)
|
||||
|
||||
# Order correctly: Inbox, Starred, rest... , Drafts
|
||||
items.splice(1, 0, starredItem)
|
||||
items.splice(1, 0, starredItem, snoozedItem)
|
||||
items.push(draftsItem)
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue