From f11bbe313ae6426bfa5b55a9101c6a4eee9a391b Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 13 Jul 2015 16:28:06 -0700 Subject: [PATCH] bump(electron): 0.29.2 and a few minor bug fixes Summary: Saving only 50 models at a time instead of 100 fixes a reproducible issue with database errors during initial sync on my machine. With 100, it reports "unexpected ; on line 2123..." during the query. Only the main window should update the unread badge count. Test Plan: Tests still pass and it seems like everything is still functional. Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1736 --- package.json | 2 +- src/flux/stores/database-store.coffee | 6 +++--- src/flux/stores/unread-count-store.coffee | 25 +++++++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index cfcc1860e..5f5df0126 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "bugs": { "url": "https://github.com/nylas/edgehill/issues" }, - "electronVersion": "0.28.1", + "electronVersion": "0.29.2", "dependencies": { "asar": "^0.5.0", "6to5-core": "^3.5", diff --git a/src/flux/stores/database-store.coffee b/src/flux/stores/database-store.coffee index 5eb381980..e4b8b08fc 100644 --- a/src/flux/stores/database-store.coffee +++ b/src/flux/stores/database-store.coffee @@ -387,10 +387,10 @@ class DatabaseStore extends NylasStore # Avoid trying to write too many objects a time - sqlite can only handle # value sets `(?,?)...` of less than SQLITE_MAX_COMPOUND_SELECT (500), # and we don't know ahead of time whether we'll hit that or not. - if models.length > 100 + if models.length > 50 return Promise.all([ - @_writeModels(models[0..99]) - @_writeModels(models[100..models.length]) + @_writeModels(models[0..49]) + @_writeModels(models[50..models.length]) ]) klass = models[0].constructor diff --git a/src/flux/stores/unread-count-store.coffee b/src/flux/stores/unread-count-store.coffee index cdb22c8e5..587c8bf8c 100644 --- a/src/flux/stores/unread-count-store.coffee +++ b/src/flux/stores/unread-count-store.coffee @@ -29,7 +29,7 @@ UnreadCountStore = Reflux.createStore @_onDataChanged() _onDataChanged: (change) -> - return app.dock?.setBadge?("") unless NamespaceStore.current() + return @_setBadge("") unless NamespaceStore.current() if change && change.objectClass is Thread.name @_fetchCountDebounced ?= _.debounce(@_fetchCount, 5000) @@ -46,14 +46,21 @@ UnreadCountStore = Reflux.createStore ]).then (count) => return if @_count is count @_count = count - - if count > 999 - app.dock?.setBadge?("999+") - else if count > 0 - app.dock?.setBadge?("#{count}") - else - app.dock?.setBadge?("") - + @_updateBadgeForCount(count) @trigger() + .catch (err) => + console.warn("Failed to fetch unread count: #{err}") + + _updateBadgeForCount: (count) -> + return unless atom.isMainWindow() + if count > 999 + @_setBadge("999+") + else if count > 0 + @_setBadge("#{count}") + else + @_setBadge("") + + _setBadge: (val) -> + app.dock?.setBadge?(val) module.exports = UnreadCountStore