mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-07 21:24:24 +08:00
feat(all-mail): Add special case *
tag for all mail
Summary: This one is a bit interesting. We want to allow the user to view "All Mail", which is essentially "threads, with no tags query whatsoever." Rather than try to make `null` a valid selected tag Id, I used `*` as a "magic" tag id which is interpreted by the ThreadStore to mean "no tags where clause." Definitely a hack, but simpler than trying to make the account sidebar properly select "all mail" when selectedTagId = null. Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1360
This commit is contained in:
parent
d0d96f90f5
commit
a10f86a3a2
2 changed files with 11 additions and 5 deletions
|
@ -61,6 +61,7 @@ AccountSidebarStore = Reflux.createStore
|
|||
|
||||
# Sort the main tags so they always appear in a standard order
|
||||
mainTags = _.sortBy mainTags, (tag) -> mainTagIDs.indexOf(tag.id)
|
||||
mainTags.push new Tag(name: 'All Mail', id: '*')
|
||||
|
||||
lastSections = @_sections
|
||||
@_sections = [
|
||||
|
|
|
@ -45,10 +45,12 @@ ThreadStore = Reflux.createStore
|
|||
|
||||
start = Date.now()
|
||||
|
||||
DatabaseStore.findAll(Thread, [
|
||||
Thread.attributes.namespaceId.equal(@_namespaceId),
|
||||
Thread.attributes.tags.contains(@_tagId)
|
||||
]).limit(100).then (items) =>
|
||||
matchers = []
|
||||
matchers.push Thread.attributes.namespaceId.equal(@_namespaceId)
|
||||
if @_tagId and @_tagId isnt "*"
|
||||
matchers.push Thread.attributes.tags.contains(@_tagId)
|
||||
|
||||
DatabaseStore.findAll(Thread).where(matchers).limit(100).then (items) =>
|
||||
# Now, fetch the messages for each thread. We could do this with a
|
||||
# complex join, but then we'd get thread columns repeated over and over.
|
||||
# This is reasonably fast because we don't store message bodies in messages
|
||||
|
@ -122,7 +124,10 @@ ThreadStore = Reflux.createStore
|
|||
@_items = items
|
||||
doneLoading()
|
||||
else
|
||||
atom.inbox.getThreads(@_namespaceId, {tag: @_tagId}, {success: doneLoading, error: doneLoading})
|
||||
params = {}
|
||||
if @_tagId and @_tagId isnt "*"
|
||||
params = {tag: @_tagId}
|
||||
atom.inbox.getThreads(@_namespaceId, params, {success: doneLoading, error: doneLoading})
|
||||
|
||||
# Inbound Events
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue