mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 16:25:52 +08:00
fix(compose): "compose in trash", additional specs #2026
This commit is contained in:
parent
4ea8b9622c
commit
6b12f833d7
2 changed files with 45 additions and 6 deletions
|
@ -1,7 +1,9 @@
|
|||
_ = require 'underscore'
|
||||
Thread = require '../../src/flux/models/thread'
|
||||
Category = require '../../src/flux/models/category'
|
||||
Message = require '../../src/flux/models/message'
|
||||
FocusedContentStore = require '../../src/flux/stores/focused-content-store'
|
||||
FocusedPerspectiveStore = require '../../src/flux/stores/focused-perspective-store'
|
||||
MessageStore = require '../../src/flux/stores/message-store'
|
||||
DatabaseStore = require '../../src/flux/stores/database-store'
|
||||
ChangeUnreadTask = require '../../src/flux/tasks/change-unread-task'
|
||||
|
@ -53,6 +55,40 @@ describe "MessageStore", ->
|
|||
FocusedContentStore.trigger(impactsCollection: (c) -> true )
|
||||
expect(MessageStore._onApplyFocusChange.callCount).toBe(5)
|
||||
|
||||
describe "items", ->
|
||||
beforeEach ->
|
||||
MessageStore._showingHiddenItems = false
|
||||
MessageStore._items = [
|
||||
new Message(categories: [new Category(displayName: 'bla'), new Category(name: 'trash')]),
|
||||
new Message(categories: [new Category(name: 'inbox')]),
|
||||
new Message(categories: [new Category(name: 'bla'), new Category(name: 'spam')]),
|
||||
new Message(categories: []),
|
||||
new Message(categories: [], draft: true),
|
||||
]
|
||||
|
||||
describe "when showing hidden items", ->
|
||||
it "should return the entire items array", ->
|
||||
MessageStore._showingHiddenItems = true
|
||||
expect(MessageStore.items().length).toBe(5)
|
||||
|
||||
describe "when in trash or spam", ->
|
||||
it "should show only the message which are in trash or spam, and drafts", ->
|
||||
spyOn(FocusedPerspectiveStore, 'current').andReturn({categoriesSharedName: => 'trash'})
|
||||
expect(MessageStore.items()).toEqual([
|
||||
MessageStore._items[0],
|
||||
MessageStore._items[2],
|
||||
MessageStore._items[4],
|
||||
])
|
||||
|
||||
describe "when in another folder", ->
|
||||
it "should hide all of the messages which are in trash or spam", ->
|
||||
spyOn(FocusedPerspectiveStore, 'current').andReturn({categoriesSharedName: => 'inbox'})
|
||||
expect(MessageStore.items()).toEqual([
|
||||
MessageStore._items[1],
|
||||
MessageStore._items[3],
|
||||
MessageStore._items[4],
|
||||
])
|
||||
|
||||
describe "when applying focus changes", ->
|
||||
beforeEach ->
|
||||
MessageStore._lastLoadedThreadId = null
|
||||
|
|
|
@ -27,13 +27,16 @@ class MessageStore extends NylasStore
|
|||
return @_items if @_showingHiddenItems
|
||||
|
||||
viewing = FocusedPerspectiveStore.current().categoriesSharedName()
|
||||
viewingHidden = viewing in CategoryNamesHiddenByDefault
|
||||
viewingHiddenCategory = viewing in CategoryNamesHiddenByDefault
|
||||
|
||||
return @_items.filter (item) ->
|
||||
inHidden = _.any item.categories, (cat) -> cat.name in CategoryNamesHiddenByDefault
|
||||
return false if viewingHidden and not inHidden
|
||||
return false if not viewingHidden and inHidden
|
||||
return true
|
||||
if viewingHiddenCategory
|
||||
return @_items.filter (item) ->
|
||||
inHidden = _.any item.categories, (cat) -> cat.name in CategoryNamesHiddenByDefault
|
||||
return inHidden or item.draft is true
|
||||
else
|
||||
return @_items.filter (item) ->
|
||||
inHidden = _.any item.categories, (cat) -> cat.name in CategoryNamesHiddenByDefault
|
||||
return not inHidden
|
||||
|
||||
threadId: -> @_thread?.id
|
||||
|
||||
|
|
Loading…
Reference in a new issue