From 2f3bc020a1b6ff42388a35fa57d0300730851f3b Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 13 Apr 2016 14:47:23 -0700 Subject: [PATCH] fix(empty): Use a much faster query for empty perspective --- src/mailbox-perspective.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mailbox-perspective.coffee b/src/mailbox-perspective.coffee index a51d2e02e..b4b981228 100644 --- a/src/mailbox-perspective.coffee +++ b/src/mailbox-perspective.coffee @@ -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: =>