From ce17d8ab1eed54e5628785af8105ca2e75df8216 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 24 Feb 2016 10:50:21 -0800 Subject: [PATCH] feat(snooze): Add snooze item to sidebar --- .../account-sidebar/lib/sidebar-item.coffee | 14 ++++++++++++++ .../account-sidebar/lib/sidebar-section.coffee | 14 ++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/internal_packages/account-sidebar/lib/sidebar-item.coffee b/internal_packages/account-sidebar/lib/sidebar-item.coffee index 391891dbc..da5e93f64 100644 --- a/internal_packages/account-sidebar/lib/sidebar-item.coffee +++ b/internal_packages/account-sidebar/lib/sidebar-item.coffee @@ -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' diff --git a/internal_packages/account-sidebar/lib/sidebar-section.coffee b/internal_packages/account-sidebar/lib/sidebar-section.coffee index 8f87d2724..9eb22fe54 100644 --- a/internal_packages/account-sidebar/lib/sidebar-section.coffee +++ b/internal_packages/account-sidebar/lib/sidebar-section.coffee @@ -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 {