fix(empty): Use a much faster query for empty perspective

This commit is contained in:
Ben Gotow 2016-04-13 14:47:23 -07:00
parent 471bbbe1e3
commit 2f3bc020a1

View file

@ -200,7 +200,11 @@ class EmptyMailboxPerspective extends MailboxPerspective
@accountIds = []
threads: =>
query = DatabaseStore.findAll(Thread).where(accountId: -1).limit(0)
# We need a Thread query that will not return any results and take no time.
# We use lastMessageReceivedTimestamp because it is the first column on an
# index so this returns zero items nearly instantly. In the future, we might
# want to make a Query.forNothing() to go along with MailboxPerspective.forNothing()
query = DatabaseStore.findAll(Thread).where(lastMessageReceivedTimestamp: -1).limit(0)
return new MutableQuerySubscription(query, {asResultSet: true})
canReceiveThreadsFromAccountIds: =>