From d78206d4df27e029b192d938ac5c2cbbe769ad93 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 24 Mar 2016 16:48:15 -0700 Subject: [PATCH] fix(counts): Collect metrics about -unread, reset when found --- src/flux/stores/thread-counts-store.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/flux/stores/thread-counts-store.coffee b/src/flux/stores/thread-counts-store.coffee index df6fb9bb2..3bd0f19b6 100644 --- a/src/flux/stores/thread-counts-store.coffee +++ b/src/flux/stores/thread-counts-store.coffee @@ -89,8 +89,19 @@ class ThreadCountsStore extends NylasStore _onCountsChanged: => DatabaseStore._query(ReadCountsQuery()).then (results) => @_counts = {} + + foundNegative = false for {category_id, unread, total} in results + unread = -1 @_counts[category_id] = {unread, total} + if unread < 0 or total < 0 + foundNegative = true + + if foundNegative + NylasEnv.reportError(new Error('Assertion Failure: Negative Count')); + @reset() + return + @trigger() unreadCountForCategoryId: (catId) =>